X-Git-Url: https://ruin.nu/git/?p=germs.git;a=blobdiff_plain;f=src%2Fsortaction.h;h=d1a3f7bca68e3fe5a11c94631f117123c10295fe;hp=a71a533cf70ec981f10d32527053e58cdf0a609b;hb=3fff88637ec7e806f19e613051f31ca5178d2cf5;hpb=3401199b1ce268dd6465f09abf6264592b989140 diff --git a/src/sortaction.h b/src/sortaction.h index a71a533..d1a3f7b 100644 --- a/src/sortaction.h +++ b/src/sortaction.h @@ -21,30 +21,42 @@ #ifndef __SORTACTION_H__ #define __SORTACTION_H__ +#include class GeneOrder; /** - * Abstraction of a sort action + * Abstraction of a sort action, all child actions has to be immutable. * * \author Michael Andreen */ class SortAction{ public: + typedef std::tr1::shared_ptr ActionPointer; + /** + * Creates a new sort action, given a specified action. + * SortAction promises to remove the given action. + */ + SortAction(SortAction* sa): _action(sa){ + } + virtual ~SortAction(){}; /** * Applies the action on the GeneOrder and returning it. */ virtual GeneOrder& operator()(GeneOrder& go) const{ - return go; + return (*_action)(go); } /** * Compares sort actions. */ virtual bool operator==(const SortAction& sa) const{ - return false; + return (*_action) == (sa._action.get() == 0 ? sa : *sa._action); } + private: + ActionPointer _action; + }; #endif