X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=src%2Fsortaction.h;h=0e59cd385e1701eff4b2a592fbd0dc9aae2c73bb;hb=1c14858d7eb8283d147fbe11963d7b32b221a98b;hp=b6c5df74278f85d08540678674ffb6c7d384a650;hpb=47b1f5c0294e079bc120dc8366977951aa0778bf;p=germs.git diff --git a/src/sortaction.h b/src/sortaction.h index b6c5df7..0e59cd3 100644 --- a/src/sortaction.h +++ b/src/sortaction.h @@ -21,20 +21,51 @@ #ifndef __SORTACTION_H__ #define __SORTACTION_H__ +#include +class GeneOrder; /** - * Abstraction of a sort action, keeping track of score + * 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){ + } + + SortAction(const SortAction& sa): _action(sa._action){ + } + + virtual const SortAction& operator=(const SortAction& sa){ + if (this != &sa) + _action = sa._action; + return *this; + } + virtual ~SortAction(){}; /** - * Sort SortActions by score + * Applies the action on the GeneOrder and returning it. */ - virtual operator<(const SortAction& sa) const; + virtual GeneOrder& operator()(GeneOrder& go) const{ + return (*_action)(go); + } + + /** + * Compares sort actions. + */ + virtual bool operator==(const SortAction& sa) const{ + return (*_action) == (sa._action.get() == 0 ? sa : *sa._action); + } + private: + ActionPointer _action; + }; #endif