X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;ds=sidebyside;f=src%2Fsortaction.h;h=a1c5566acb16673368d5c3fc9260f9c68a055311;hb=6ce65cd9df9c007b0c7ad0e37fb82ac04a802a90;hp=c56d0ee42a304bdf26db992f36d4c61a5f374f7a;hpb=efe42ca948704593c847996d0ae8da71d15bb75b;p=germs.git diff --git a/src/sortaction.h b/src/sortaction.h index c56d0ee..a1c5566 100644 --- a/src/sortaction.h +++ b/src/sortaction.h @@ -21,11 +21,15 @@ #ifndef __SORTACTION_H__ #define __SORTACTION_H__ -#include +#include "shared_ptr.h" #include class GeneOrder; +/** + * Abstraction for a sort action implementation, this is the base that other + * actions inherits from. + */ class SortActionImpl{ public: @@ -40,7 +44,12 @@ class SortActionImpl{ * Compares sort actions. */ virtual bool operator==(const SortActionImpl& sa) const = 0; - + + /** + * Compares sort actions. + */ + virtual bool operator<(const SortActionImpl& sa) const = 0; + /** * Gives a string representation of the action, for output */ @@ -48,13 +57,13 @@ class SortActionImpl{ }; /** - * Abstraction of a sort action, all child actions has to be immutable. + * Abstraction of a sort action, all SortActionImpls has to be immutable. * * \author Michael Andreen */ class SortAction{ public: - typedef std::tr1::shared_ptr ActionPointer; + typedef shared_ptr ActionPointer; /** * Creates a new sort action, given a specified action. @@ -88,6 +97,13 @@ class SortAction{ return (*_action) == (*sa._action); } + /** + * Compares sort actions. + */ + bool operator<(const SortAction& sa) const{ + return (*_action) < (*sa._action); + } + /** * Compares sort actions. */ @@ -101,6 +117,13 @@ class SortAction{ std::string toString() const{ return _action->toString(); } + + /** + * Gives access to the implementation + */ + const SortActionImpl& impl() const{ + return *_action; + } private: ActionPointer _action;