X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fprops%2Fcondition.hxx;h=719f68795411ad609664557e4079d5494f3be63f;hb=708ae35068499af33329f9db91f55441f4956acb;hp=b314cc4ed017f3430219852d0d40ddb4b07834b7;hpb=d8a75897526f2ba2a030225a22dfbd93c7c39a7e;p=simgear.git diff --git a/simgear/props/condition.hxx b/simgear/props/condition.hxx index b314cc4e..719f6879 100644 --- a/simgear/props/condition.hxx +++ b/simgear/props/condition.hxx @@ -13,7 +13,7 @@ #include #include #include - +#include //////////////////////////////////////////////////////////////////////// // Conditions. @@ -28,7 +28,7 @@ * * This class should migrate to somewhere more general. */ -class SGCondition +class SGCondition : public SGReferenced { public: SGCondition (); @@ -37,108 +37,6 @@ public: }; -/** - * Condition for a single property. - * - * This condition is true only if the property returns a boolean - * true value. - */ -class SGPropertyCondition : public SGCondition -{ -public: - SGPropertyCondition ( SGPropertyNode *prop_root, - const char * propname ); - virtual ~SGPropertyCondition (); - virtual bool test () const { return _node->getBoolValue(); } -private: - const SGPropertyNode * _node; -}; - - -/** - * Condition for a 'not' operator. - * - * This condition is true only if the child condition is false. - */ -class SGNotCondition : public SGCondition -{ -public: - // transfer pointer ownership - SGNotCondition (SGCondition * condition); - virtual ~SGNotCondition (); - virtual bool test () const; -private: - SGCondition * _condition; -}; - - -/** - * Condition for an 'and' group. - * - * This condition is true only if all of the conditions - * in the group are true. - */ -class SGAndCondition : public SGCondition -{ -public: - SGAndCondition (); - virtual ~SGAndCondition (); - virtual bool test () const; - // transfer pointer ownership - virtual void addCondition (SGCondition * condition); -private: - vector _conditions; -}; - - -/** - * Condition for an 'or' group. - * - * This condition is true if at least one of the conditions in the - * group is true. - */ -class SGOrCondition : public SGCondition -{ -public: - SGOrCondition (); - virtual ~SGOrCondition (); - virtual bool test () const; - // transfer pointer ownership - virtual void addCondition (SGCondition * condition); -private: - vector _conditions; -}; - - -/** - * Abstract base class for property comparison conditions. - */ -class SGComparisonCondition : public SGCondition -{ -public: - enum Type { - LESS_THAN, - GREATER_THAN, - EQUALS - }; - SGComparisonCondition (Type type, bool reverse = false); - virtual ~SGComparisonCondition (); - virtual bool test () const; - virtual void setLeftProperty( SGPropertyNode *prop_root, - const char * propname ); - virtual void setRightProperty( SGPropertyNode *prop_root, - const char * propname ); - // will make a local copy - virtual void setRightValue (const SGPropertyNode * value); -private: - Type _type; - bool _reverse; - const SGPropertyNode * _left_property; - const SGPropertyNode * _right_property; - const SGPropertyNode * _right_value; -}; - - /** * Base class for a conditional components. * @@ -146,7 +44,7 @@ private: * invoke the test() method whenever it needs to decide whether to * active itself, draw itself, and so on. */ -class SGConditional +class SGConditional : public SGReferenced { public: SGConditional (); @@ -156,7 +54,7 @@ public: virtual const SGCondition * getCondition () const { return _condition; } virtual bool test () const; private: - SGCondition * _condition; + SGSharedPtr _condition; };