3 * Declarations and inline methods for property conditions.
4 * Written by David Megginson, started 2000.
5 * CLO May 2003 - Split out condition specific code.
7 * This file is in the Public Domain, and comes with no warranty.
10 #ifndef __SG_CONDITION_HXX
11 #define __SG_CONDITION_HXX
14 #include <simgear/structure/SGReferenced.hxx>
15 #include <simgear/structure/SGSharedPtr.hxx>
19 ////////////////////////////////////////////////////////////////////////
21 ////////////////////////////////////////////////////////////////////////
25 * An encoded condition.
27 * This class encodes a single condition of some sort, possibly
28 * connected with properties.
30 * This class should migrate to somewhere more general.
32 class SGCondition : public SGReferenced
36 virtual ~SGCondition ();
37 virtual bool test () const = 0;
38 virtual void collectDependentProperties(std::set<const SGPropertyNode*>& props) const { }
43 * Base class for a conditional components.
45 * This class manages the conditions and tests; the component should
46 * invoke the test() method whenever it needs to decide whether to
47 * active itself, draw itself, and so on.
49 class SGConditional : public SGReferenced
53 virtual ~SGConditional ();
54 // transfer pointer ownership
55 virtual void setCondition (SGCondition * condition);
56 virtual const SGCondition * getCondition () const { return _condition; }
57 virtual bool test () const;
59 SGSharedPtr<SGCondition> _condition;
64 * Global function to make a condition out of properties.
66 * The top-level is always an implicit 'and' group, whatever the
67 * node's name (it should usually be "condition").
69 * @param node The top-level condition node (usually named "condition").
70 * @return A pointer to a newly-allocated condition; it is the
71 * responsibility of the caller to delete the condition when
72 * it is no longer needed.
74 SGCondition *sgReadCondition( SGPropertyNode *prop_root,
75 const SGPropertyNode *node );
78 #endif // __SG_CONDITION_HXX