X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fprops%2Fcondition.hxx;h=128cdfaf0c85fd374c723616af6335712a2c9f12;hb=1a5467aec86437001faf009310c54c2b2a7851a6;hp=5f06a5e5b2a5ce670478f55c13193a1fbc330c65;hpb=a3bc2eb836466a141ab48efa05b2c3d34c4d383b;p=simgear.git diff --git a/simgear/props/condition.hxx b/simgear/props/condition.hxx index 5f06a5e5..128cdfaf 100644 --- a/simgear/props/condition.hxx +++ b/simgear/props/condition.hxx @@ -10,12 +10,12 @@ #ifndef __SG_CONDITION_HXX #define __SG_CONDITION_HXX -#include -#include -#include +#include #include +#include + +class SGPropertyNode; - //////////////////////////////////////////////////////////////////////// // Conditions. //////////////////////////////////////////////////////////////////////// @@ -35,107 +35,7 @@ public: SGCondition (); virtual ~SGCondition (); virtual bool test () const = 0; -}; - - -/** - * 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: - SGConstPropertyNode_ptr _node; -}; - - -/** - * Condition for a 'not' operator. - * - * This condition is true only if the child condition is false. - */ -class SGNotCondition : public SGCondition -{ -public: - SGNotCondition (SGCondition * condition); - virtual ~SGNotCondition (); - virtual bool test () const; -private: - SGSharedPtr _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: - std::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: - std::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; - SGConstPropertyNode_ptr _left_property; - SGConstPropertyNode_ptr _right_property; - SGConstPropertyNode_ptr _right_value; + virtual void collectDependentProperties(std::set& props) const { } }; @@ -146,7 +46,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 ();