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
13 #include <simgear/structure/SGReferenced.hxx>
14 #include <simgear/structure/SGSharedPtr.hxx>
18 ////////////////////////////////////////////////////////////////////////
20 ////////////////////////////////////////////////////////////////////////
24 * An encoded condition.
26 * This class encodes a single condition of some sort, possibly
27 * connected with properties.
29 * This class should migrate to somewhere more general.
31 class SGCondition : public SGReferenced
35 virtual ~SGCondition ();
36 virtual bool test () const = 0;
41 * Base class for a conditional components.
43 * This class manages the conditions and tests; the component should
44 * invoke the test() method whenever it needs to decide whether to
45 * active itself, draw itself, and so on.
47 class SGConditional : public SGReferenced
51 virtual ~SGConditional ();
52 // transfer pointer ownership
53 virtual void setCondition (SGCondition * condition);
54 virtual const SGCondition * getCondition () const { return _condition; }
55 virtual bool test () const;
57 SGSharedPtr<SGCondition> _condition;
62 * Global function to make a condition out of properties.
64 * The top-level is always an implicit 'and' group, whatever the
65 * node's name (it should usually be "condition").
67 * @param node The top-level condition node (usually named "condition").
68 * @return A pointer to a newly-allocated condition; it is the
69 * responsibility of the caller to delete the condition when
70 * it is no longer needed.
72 SGCondition *sgReadCondition( SGPropertyNode *prop_root,
73 const SGPropertyNode *node );
76 #endif // __SG_CONDITION_HXX