]> ruin.nu Git - germs.git/commitdiff
toString for actions
authorMichael Andreen <harv@ruin.nu>
Wed, 27 Jun 2007 06:03:23 +0000 (06:03 +0000)
committerMichael Andreen <harv@ruin.nu>
Wed, 27 Jun 2007 06:03:23 +0000 (06:03 +0000)
src/genesorter.cpp
src/reverseaction.h
src/sortaction.h

index d73f176eb01465b2b717283b59015167f921cc7a..755368812614cae8063633d31b30971674e3fbf5 100644 (file)
@@ -41,6 +41,7 @@ GeneSorter::ActionList GeneSorter::sort(const GeneOrder& go){
                ActionList safe = safeActions(temp);
                if (safe.size() > 0){
                        safe[0](temp);
                ActionList safe = safeActions(temp);
                if (safe.size() > 0){
                        safe[0](temp);
+                       cout << "Action: " << safe[0].toString() << " ";
                        al.push_back(safe[0]);
                }else
                        return ActionList(); //TODO: Need to handle hurdles.
                        al.push_back(safe[0]);
                }else
                        return ActionList(); //TODO: Need to handle hurdles.
index 76ab6660da377187420f268ce6dda84825ef3361..006c9eb4de9df4446b27ccaee6da4068d435a4a2 100644 (file)
@@ -25,6 +25,7 @@
 #include "genealgorithms.h"
 
 #include <algorithm>
 #include "genealgorithms.h"
 
 #include <algorithm>
+#include <sstream>
 
 /**
  * Reverses an interval
 
 /**
  * Reverses an interval
@@ -59,6 +60,15 @@ class ReverseAction : public SortAction{
                        }
                        return false;
                }
                        }
                        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;
        private:
                size_t _i;
                size_t _j;
index 0e59cd385e1701eff4b2a592fbd0dc9aae2c73bb..66c337ca625cac468b113debc86c1cd224029a76 100644 (file)
@@ -22,6 +22,7 @@
 #define __SORTACTION_H__
 
 #include <tr1/memory>
 #define __SORTACTION_H__
 
 #include <tr1/memory>
+#include <string>
 class GeneOrder;
 /**
  * Abstraction of a sort action, all child actions has to be immutable.
 class GeneOrder;
 /**
  * Abstraction of a sort action, all child actions has to be immutable.
@@ -63,6 +64,13 @@ class SortAction{
                virtual bool operator==(const SortAction& sa) const{
                        return (*_action) == (sa._action.get() == 0 ? sa : *sa._action);
                }
                virtual bool operator==(const SortAction& sa) const{
                        return (*_action) == (sa._action.get() == 0 ? sa : *sa._action);
                }
+               
+               /**
+                * Gives a string representation of the action, for output
+                */
+               virtual std::string toString() const{
+                       return _action->toString();
+               }
        private:
                ActionPointer _action;
 
        private:
                ActionPointer _action;