]> ruin.nu Git - germs.git/blobdiff - src/reverseaction.h
genesorter now uses models to score actions, specific actions are now derived from...
[germs.git] / src / reverseaction.h
index 76ab6660da377187420f268ce6dda84825ef3361..d69af75b16f96e2f76728cb80efd88ecf933325f 100644 (file)
 
 #include "sortaction.h"
 #include "genealgorithms.h"
+#include "geneorder.h"
 
 #include <algorithm>
+#include <sstream>
 
 /**
  * Reverses an interval
  *
  * \author Michael Andreen
  */
-class ReverseAction : public SortAction{
+class ReverseAction : public SortActionImpl{
        public:
 
                /**
                 * Creates a new reverse action for the interval [i,j]
                 */
-               ReverseAction(size_t i, size_t j): SortAction(0),_i(i),_j(j){
+               ReverseAction(size_t i, size_t j): _i(i),_j(j){
                }
-               ReverseAction(Interval i): SortAction(0){
+
+               ReverseAction(Interval i){
                        _i = std::min(i.first,i.second);
                        _j = std::max(i.first,i.second)-1;
                }
@@ -52,13 +55,22 @@ class ReverseAction : public SortAction{
                        return go;
                }
 
-               virtual bool operator==(const SortAction& sa) const{
+               virtual bool operator==(const SortActionImpl& sa) const{
                        if (const ReverseAction* psa = dynamic_cast<const ReverseAction*>(&sa)){
                                if (_i == psa->_i && _j == psa->_j)
                                        return true;
                        }
                        return false;
                }
+
+               /**
+                * Gives a string representation of the action, for output
+                */
+               virtual std::string toString() const{
+                       std::ostringstream os;
+                       os << "[" << _i << "," << _j << "]";
+                       return os.str();
+               }
        private:
                size_t _i;
                size_t _j;