]> git.mxchange.org Git - flightgear.git/blob - src/Main/fg_props.hxx
Latest JSBSim changes, mostly to support yaw and roll trim.
[flightgear.git] / src / Main / fg_props.hxx
1 // fg_props.hxx - Declarations and inline methods for property handling.
2 // Written by David Megginson, started 2000.
3 //
4 // This file is in the Public Domain, and comes with no warranty.
5
6 #ifndef __FG_PROPS_HXX
7 #define __FG_PROPS_HXX 1
8
9 #include <simgear/debug/logstream.hxx>
10 #include <simgear/misc/props.hxx>
11 #include "globals.hxx"
12
13 \f
14 ////////////////////////////////////////////////////////////////////////
15 // Property management.
16 ////////////////////////////////////////////////////////////////////////
17
18
19 /**
20  * Initialize the default FlightGear properties.
21  *
22  * These are mostly properties that haven't been claimed by a
23  * specific module yet.  This function should be invoked once,
24  * while the program is starting (and after the global property
25  * tree has been created).
26  */
27 extern void fgInitProps ();     // fixme: how are they untied?
28
29
30 /**
31  * Update the default FlightGear properties.
32  *
33  * This function should be invoked once in each loop to update all
34  * of the default properties.
35  */
36 extern void fgUpdateProps ();
37
38
39 /**
40  * Save a flight to disk.
41  *
42  * This function saves all of the archivable properties to a stream
43  * so that the current flight can be restored later.
44  *
45  * @param output The output stream to write the XML save file to.
46  * @return true if the flight was saved successfully.
47  */
48 extern bool fgSaveFlight (ostream &output);
49
50
51 /**
52  * Load a flight from disk.
53  *
54  * This function loads an XML save file from a stream to restore
55  * a flight.
56  *
57  * @param input The input stream to read the XML from.
58  * @return true if the flight was restored successfully.
59  */
60 extern bool fgLoadFlight (istream &input);
61
62
63 \f
64 ////////////////////////////////////////////////////////////////////////
65 // Convenience functions for getting property values.
66 ////////////////////////////////////////////////////////////////////////
67
68
69 /**
70  * Get a property node.
71  *
72  * @param path The path of the node, relative to root.
73  * @param create true to create the node if it doesn't exist.
74  * @return The node, or 0 if none exists and none was created.
75  */
76 inline SGPropertyNode * 
77 fgGetNode (const string &path, bool create = false)
78 {
79   return globals->get_props()->getNode(path, create);
80 }
81
82
83 /**
84  * Test whether a given node exists.
85  *
86  * @param path The path of the node, relative to root.
87  * @return true if the node exists, false otherwise.
88  */
89 inline bool
90 fgHasNode (const string &path)
91 {
92   return (fgGetNode(path, false) != 0);
93 }
94
95
96 /**
97  * Get a bool value for a property.
98  *
99  * This method is convenient but inefficient.  It should be used
100  * infrequently (i.e. for initializing, loading, saving, etc.),
101  * not in the main loop.  If you need to get a value frequently,
102  * it is better to look up the node itself using fgGetNode and then
103  * use the node's getBoolValue() method, to avoid the lookup overhead.
104  *
105  * @param name The property name.
106  * @param defaultValue The default value to return if the property
107  *        does not exist.
108  * @return The property's value as a bool, or the default value provided.
109  */
110 inline bool fgGetBool (const string &name, bool defaultValue = false)
111 {
112   return globals->get_props()->getBoolValue(name, defaultValue);
113 }
114
115
116 /**
117  * Get an int value for a property.
118  *
119  * This method is convenient but inefficient.  It should be used
120  * infrequently (i.e. for initializing, loading, saving, etc.),
121  * not in the main loop.  If you need to get a value frequently,
122  * it is better to look up the node itself using fgGetNode and then
123  * use the node's getIntValue() method, to avoid the lookup overhead.
124  *
125  * @param name The property name.
126  * @param defaultValue The default value to return if the property
127  *        does not exist.
128  * @return The property's value as an int, or the default value provided.
129  */
130 inline int fgGetInt (const string &name, int defaultValue = 0)
131 {
132   return globals->get_props()->getIntValue(name, defaultValue);
133 }
134
135
136 /**
137  * Get a long value for a property.
138  *
139  * This method is convenient but inefficient.  It should be used
140  * infrequently (i.e. for initializing, loading, saving, etc.),
141  * not in the main loop.  If you need to get a value frequently,
142  * it is better to look up the node itself using fgGetNode and then
143  * use the node's getLongValue() method, to avoid the lookup overhead.
144  *
145  * @param name The property name.
146  * @param defaultValue The default value to return if the property
147  *        does not exist.
148  * @return The property's value as a long, or the default value provided.
149  */
150 inline int fgGetLong (const string &name, long defaultValue = 0L)
151 {
152   return globals->get_props()->getLongValue(name, defaultValue);
153 }
154
155
156 /**
157  * Get a float value for a property.
158  *
159  * This method is convenient but inefficient.  It should be used
160  * infrequently (i.e. for initializing, loading, saving, etc.),
161  * not in the main loop.  If you need to get a value frequently,
162  * it is better to look up the node itself using fgGetNode and then
163  * use the node's getFloatValue() method, to avoid the lookup overhead.
164  *
165  * @param name The property name.
166  * @param defaultValue The default value to return if the property
167  *        does not exist.
168  * @return The property's value as a float, or the default value provided.
169  */
170 inline float fgGetFloat (const string &name, float defaultValue = 0.0)
171 {
172   return globals->get_props()->getFloatValue(name, defaultValue);
173 }
174
175
176 /**
177  * Get a double value for a property.
178  *
179  * This method is convenient but inefficient.  It should be used
180  * infrequently (i.e. for initializing, loading, saving, etc.),
181  * not in the main loop.  If you need to get a value frequently,
182  * it is better to look up the node itself using fgGetNode and then
183  * use the node's getDoubleValue() method, to avoid the lookup overhead.
184  *
185  * @param name The property name.
186  * @param defaultValue The default value to return if the property
187  *        does not exist.
188  * @return The property's value as a double, or the default value provided.
189  */
190 inline double fgGetDouble (const string &name, double defaultValue = 0.0)
191 {
192   return globals->get_props()->getDoubleValue(name, defaultValue);
193 }
194
195
196 /**
197  * Get a string value for a property.
198  *
199  * This method is convenient but inefficient.  It should be used
200  * infrequently (i.e. for initializing, loading, saving, etc.),
201  * not in the main loop.  If you need to get a value frequently,
202  * it is better to look up the node itself using fgGetNode and then
203  * use the node's getStringValue() method, to avoid the lookup overhead.
204  *
205  * @param name The property name.
206  * @param defaultValue The default value to return if the property
207  *        does not exist.
208  * @return The property's value as a string, or the default value provided.
209  */
210 inline string fgGetString (const string &name, string defaultValue = "")
211 {
212   return globals->get_props()->getStringValue(name, defaultValue);
213 }
214
215
216 /**
217  * Set a bool value for a property.
218  *
219  * Assign a bool value to a property.  If the property does not
220  * yet exist, it will be created and its type will be set to
221  * BOOL; if it has a type of UNKNOWN, the type will also be set to
222  * BOOL; otherwise, the bool value will be converted to the property's
223  * type.
224  *
225  * @param name The property name.
226  * @param val The new value for the property.
227  * @return true if the assignment succeeded, false otherwise.
228  */
229 inline bool fgSetBool (const string &name, bool val)
230 {
231   return globals->get_props()->setBoolValue(name, val);
232 }
233
234
235 /**
236  * Set an int value for a property.
237  *
238  * Assign an int value to a property.  If the property does not
239  * yet exist, it will be created and its type will be set to
240  * INT; if it has a type of UNKNOWN, the type will also be set to
241  * INT; otherwise, the bool value will be converted to the property's
242  * type.
243  *
244  * @param name The property name.
245  * @param val The new value for the property.
246  * @return true if the assignment succeeded, false otherwise.
247  */
248 inline bool fgSetInt (const string &name, int val)
249 {
250   return globals->get_props()->setIntValue(name, val);
251 }
252
253
254 /**
255  * Set a long value for a property.
256  *
257  * Assign a long value to a property.  If the property does not
258  * yet exist, it will be created and its type will be set to
259  * LONG; if it has a type of UNKNOWN, the type will also be set to
260  * LONG; otherwise, the bool value will be converted to the property's
261  * type.
262  *
263  * @param name The property name.
264  * @param val The new value for the property.
265  * @return true if the assignment succeeded, false otherwise.
266  */
267 inline bool fgSetLong (const string &name, long val)
268 {
269   return globals->get_props()->setLongValue(name, val);
270 }
271
272
273 /**
274  * Set a float value for a property.
275  *
276  * Assign a float value to a property.  If the property does not
277  * yet exist, it will be created and its type will be set to
278  * FLOAT; if it has a type of UNKNOWN, the type will also be set to
279  * FLOAT; otherwise, the bool value will be converted to the property's
280  * type.
281  *
282  * @param name The property name.
283  * @param val The new value for the property.
284  * @return true if the assignment succeeded, false otherwise.
285  */
286 inline bool fgSetFloat (const string &name, float val)
287 {
288   return globals->get_props()->setFloatValue(name, val);
289 }
290
291
292 /**
293  * Set a double value for a property.
294  *
295  * Assign a double value to a property.  If the property does not
296  * yet exist, it will be created and its type will be set to
297  * DOUBLE; if it has a type of UNKNOWN, the type will also be set to
298  * DOUBLE; otherwise, the double value will be converted to the property's
299  * type.
300  *
301  * @param name The property name.
302  * @param val The new value for the property.
303  * @return true if the assignment succeeded, false otherwise.
304  */
305 inline bool fgSetDouble (const string &name, double val)
306 {
307   return globals->get_props()->setDoubleValue(name, val);
308 }
309
310
311 /**
312  * Set a string value for a property.
313  *
314  * Assign a string value to a property.  If the property does not
315  * yet exist, it will be created and its type will be set to
316  * STRING; if it has a type of UNKNOWN, the type will also be set to
317  * STRING; otherwise, the string value will be converted to the property's
318  * type.
319  *
320  * @param name The property name.
321  * @param val The new value for the property.
322  * @return true if the assignment succeeded, false otherwise.
323  */
324 inline bool fgSetString (const string &name, const string &val)
325 {
326   return globals->get_props()->setStringValue(name, val);
327 }
328
329
330 \f
331 ////////////////////////////////////////////////////////////////////////
332 // Convenience functions for setting property attributes.
333 ////////////////////////////////////////////////////////////////////////
334
335
336 /**
337  * Set the state of the archive attribute for a property.
338  *
339  * If the archive attribute is true, the property will be written
340  * when a flight is saved; if it is false, the property will be
341  * skipped.
342  *
343  * A warning message will be printed if the property does not exist.
344  *
345  * @param name The property name.
346  * @param state The state of the archive attribute (defaults to true).
347  */
348 inline void
349 fgSetArchivable (const string &name, bool state = true)
350 {
351   SGPropertyNode * node = globals->get_props()->getNode(name);
352   if (node == 0)
353     SG_LOG(SG_GENERAL, SG_ALERT,
354            "Attempt to set archive flag for non-existant property "
355            << name);
356   else
357     node->setAttribute(SGPropertyNode::ARCHIVE, state);
358 }
359
360
361 /**
362  * Set the state of the read attribute for a property.
363  *
364  * If the read attribute is true, the property value will be readable;
365  * if it is false, the property value will always be the default value
366  * for its type.
367  *
368  * A warning message will be printed if the property does not exist.
369  *
370  * @param name The property name.
371  * @param state The state of the read attribute (defaults to true).
372  */
373 inline void
374 fgSetReadable (const string &name, bool state = true)
375 {
376   SGPropertyNode * node = globals->get_props()->getNode(name);
377   if (node == 0)
378     SG_LOG(SG_GENERAL, SG_ALERT,
379            "Attempt to set read flag for non-existant property "
380            << name);
381   else
382     node->setAttribute(SGPropertyNode::READ, state);
383 }
384
385
386 /**
387  * Set the state of the write attribute for a property.
388  *
389  * If the write attribute is true, the property value may be modified
390  * (depending on how it is tied); if the write attribute is false, the
391  * property value may not be modified.
392  *
393  * A warning message will be printed if the property does not exist.
394  *
395  * @param name The property name.
396  * @param state The state of the write attribute (defaults to true).
397  */
398 inline void
399 fgSetWritable (const string &name, bool state = true)
400 {
401   SGPropertyNode * node = globals->get_props()->getNode(name);
402   if (node == 0)
403     SG_LOG(SG_GENERAL, SG_ALERT,
404            "Attempt to set write flag for non-existant property "
405            << name);
406   else
407     node->setAttribute(SGPropertyNode::WRITE, state);
408 }
409
410
411 \f
412 ////////////////////////////////////////////////////////////////////////
413 // Convenience functions for tying properties, with logging.
414 ////////////////////////////////////////////////////////////////////////
415
416
417 /**
418  * Untie a property from an external data source.
419  *
420  * Classes should use this function to release control of any
421  * properties they are managing.
422  */
423 inline void
424 fgUntie (const string &name)
425 {
426   if (!globals->get_props()->untie(name))
427     SG_LOG(SG_GENERAL, SG_WARN, "Failed to untie property " << name);
428 }
429
430
431                                 // Templates cause ambiguity here
432
433 /**
434  * Tie a property to an external bool variable.
435  *
436  * The property's value will automatically mirror the variable's
437  * value, and vice-versa, until the property is untied.
438  *
439  * @param name The property name to tie (full path).
440  * @param pointer A pointer to the variable.
441  * @param useDefault true if any existing property value should be
442  *        copied to the variable; false if the variable should not
443  *        be modified; defaults to true.
444  */
445 inline void
446 fgTie (const string &name, bool *pointer, bool useDefault = true)
447 {
448   if (!globals->get_props()->tie(name, SGRawValuePointer<bool>(pointer),
449                                  useDefault))
450     SG_LOG(SG_GENERAL, SG_WARN,
451            "Failed to tie property " << name << " to a pointer");
452 }
453
454
455 /**
456  * Tie a property to an external int variable.
457  *
458  * The property's value will automatically mirror the variable's
459  * value, and vice-versa, until the property is untied.
460  *
461  * @param name The property name to tie (full path).
462  * @param pointer A pointer to the variable.
463  * @param useDefault true if any existing property value should be
464  *        copied to the variable; false if the variable should not
465  *        be modified; defaults to true.
466  */
467 inline void
468 fgTie (const string &name, int *pointer, bool useDefault = true)
469 {
470   if (!globals->get_props()->tie(name, SGRawValuePointer<int>(pointer),
471                                  useDefault))
472     SG_LOG(SG_GENERAL, SG_WARN,
473            "Failed to tie property " << name << " to a pointer");
474 }
475
476
477 /**
478  * Tie a property to an external long variable.
479  *
480  * The property's value will automatically mirror the variable's
481  * value, and vice-versa, until the property is untied.
482  *
483  * @param name The property name to tie (full path).
484  * @param pointer A pointer to the variable.
485  * @param useDefault true if any existing property value should be
486  *        copied to the variable; false if the variable should not
487  *        be modified; defaults to true.
488  */
489 inline void
490 fgTie (const string &name, long *pointer, bool useDefault = true)
491 {
492   if (!globals->get_props()->tie(name, SGRawValuePointer<long>(pointer),
493                                  useDefault))
494     SG_LOG(SG_GENERAL, SG_WARN,
495            "Failed to tie property " << name << " to a pointer");
496 }
497
498
499 /**
500  * Tie a property to an external float variable.
501  *
502  * The property's value will automatically mirror the variable's
503  * value, and vice-versa, until the property is untied.
504  *
505  * @param name The property name to tie (full path).
506  * @param pointer A pointer to the variable.
507  * @param useDefault true if any existing property value should be
508  *        copied to the variable; false if the variable should not
509  *        be modified; defaults to true.
510  */
511 inline void
512 fgTie (const string &name, float *pointer, bool useDefault = true)
513 {
514   if (!globals->get_props()->tie(name, SGRawValuePointer<float>(pointer),
515                                  useDefault))
516     SG_LOG(SG_GENERAL, SG_WARN,
517            "Failed to tie property " << name << " to a pointer");
518 }
519
520
521 /**
522  * Tie a property to an external double variable.
523  *
524  * The property's value will automatically mirror the variable's
525  * value, and vice-versa, until the property is untied.
526  *
527  * @param name The property name to tie (full path).
528  * @param pointer A pointer to the variable.
529  * @param useDefault true if any existing property value should be
530  *        copied to the variable; false if the variable should not
531  *        be modified; defaults to true.
532  */
533 inline void
534 fgTie (const string &name, double *pointer, bool useDefault = true)
535 {
536   if (!globals->get_props()->tie(name, SGRawValuePointer<double>(pointer),
537                                  useDefault))
538     SG_LOG(SG_GENERAL, SG_WARN,
539            "Failed to tie property " << name << " to a pointer");
540 }
541
542
543 /**
544  * Tie a property to an external string variable.
545  *
546  * The property's value will automatically mirror the variable's
547  * value, and vice-versa, until the property is untied.
548  *
549  * @param name The property name to tie (full path).
550  * @param pointer A pointer to the variable.
551  * @param useDefault true if any existing property value should be
552  *        copied to the variable; false if the variable should not
553  *        be modified; defaults to true.
554  */
555 inline void
556 fgTie (const string &name, string *pointer, bool useDefault = true)
557 {
558   if (!globals->get_props()->tie(name, SGRawValuePointer<string>(pointer),
559                                  useDefault))
560     SG_LOG(SG_GENERAL, SG_WARN,
561            "Failed to tie property " << name << " to a pointer");
562 }
563
564
565 /**
566  * Tie a property to a pair of simple functions.
567  *
568  * Every time the property value is queried, the getter (if any) will
569  * be invoked; every time the property value is modified, the setter
570  * (if any) will be invoked.  The getter can be 0 to make the property
571  * unreadable, and the setter can be 0 to make the property
572  * unmodifiable.
573  *
574  * @param name The property name to tie (full path).
575  * @param getter The getter function, or 0 if the value is unreadable.
576  * @param setter The setter function, or 0 if the value is unmodifiable.
577  * @param useDefault true if the setter should be invoked with any existing 
578  *        property value should be; false if the old value should be
579  *        discarded; defaults to true.
580  */
581 template <class V>
582 inline void
583 fgTie (const string &name, V (*getter)(), void (*setter)(V) = 0,
584        bool useDefault = true)
585 {
586   if (!globals->get_props()->tie(name, SGRawValueFunctions<V>(getter, setter),
587                                  useDefault))
588     SG_LOG(SG_GENERAL, SG_WARN,
589            "Failed to tie property " << name << " to functions");
590 }
591
592
593 /**
594  * Tie a property to a pair of indexed functions.
595  *
596  * Every time the property value is queried, the getter (if any) will
597  * be invoked with the index provided; every time the property value
598  * is modified, the setter (if any) will be invoked with the index
599  * provided.  The getter can be 0 to make the property unreadable, and
600  * the setter can be 0 to make the property unmodifiable.
601  *
602  * @param name The property name to tie (full path).
603  * @param index The integer argument to pass to the getter and
604  *        setter functions.
605  * @param getter The getter function, or 0 if the value is unreadable.
606  * @param setter The setter function, or 0 if the value is unmodifiable.
607  * @param useDefault true if the setter should be invoked with any existing 
608  *        property value should be; false if the old value should be
609  *        discarded; defaults to true.
610  */
611 template <class V>
612 inline void
613 fgTie (const string &name, int index, V (*getter)(int),
614        void (*setter)(int, V) = 0, bool useDefault = true)
615 {
616   if (!globals->get_props()->tie(name,
617                                  SGRawValueFunctionsIndexed<V>(index,
618                                                                getter,
619                                                                setter),
620                                  useDefault))
621     SG_LOG(SG_GENERAL, SG_WARN,
622            "Failed to tie property " << name << " to indexed functions");
623 }
624
625
626 /**
627  * Tie a property to a pair of object methods.
628  *
629  * Every time the property value is queried, the getter (if any) will
630  * be invoked; every time the property value is modified, the setter
631  * (if any) will be invoked.  The getter can be 0 to make the property
632  * unreadable, and the setter can be 0 to make the property
633  * unmodifiable.
634  *
635  * @param name The property name to tie (full path).
636  * @param obj The object whose methods should be invoked.
637  * @param getter The object's getter method, or 0 if the value is
638  *        unreadable.
639  * @param setter The object's setter method, or 0 if the value is
640  *        unmodifiable.
641  * @param useDefault true if the setter should be invoked with any existing 
642  *        property value should be; false if the old value should be
643  *        discarded; defaults to true.
644  */
645 template <class T, class V>
646 inline void
647 fgTie (const string &name, T * obj, V (T::*getter)() const,
648        void (T::*setter)(V) = 0, bool useDefault = true)
649 {
650   if (!globals->get_props()->tie(name,
651                                  SGRawValueMethods<T,V>(*obj, getter, setter),
652                                  useDefault))
653     SG_LOG(SG_GENERAL, SG_WARN,
654            "Failed to tie property " << name << " to object methods");
655 }
656
657
658 /**
659  * Tie a property to a pair of indexed object methods.
660  *
661  * Every time the property value is queried, the getter (if any) will
662  * be invoked with the index provided; every time the property value
663  * is modified, the setter (if any) will be invoked with the index
664  * provided.  The getter can be 0 to make the property unreadable, and
665  * the setter can be 0 to make the property unmodifiable.
666  *
667  * @param name The property name to tie (full path).
668  * @param obj The object whose methods should be invoked.
669  * @param index The integer argument to pass to the getter and
670  *        setter methods.
671  * @param getter The getter method, or 0 if the value is unreadable.
672  * @param setter The setter method, or 0 if the value is unmodifiable.
673  * @param useDefault true if the setter should be invoked with any existing 
674  *        property value should be; false if the old value should be
675  *        discarded; defaults to true.
676  */
677 template <class T, class V>
678 inline void 
679 fgTie (const string &name, T * obj, int index,
680        V (T::*getter)(int) const, void (T::*setter)(int, V) = 0,
681        bool useDefault = true)
682 {
683   if (!globals->get_props()->tie(name,
684                                  SGRawValueMethodsIndexed<T,V>(*obj,
685                                                                index,
686                                                                getter,
687                                                                setter),
688                                  useDefault))
689     SG_LOG(SG_GENERAL, SG_WARN,
690            "Failed to tie property " << name << " to indexed object methods");
691 }
692
693
694 \f
695 ////////////////////////////////////////////////////////////////////////
696 // Conditions.
697 ////////////////////////////////////////////////////////////////////////
698
699
700 /**
701  * An encoded condition.
702  *
703  * This class encodes a single condition of some sort, possibly
704  * connected with properties.
705  *
706  * This class should migrate to somewhere more general.
707  */
708 class FGCondition
709 {
710 public:
711   FGCondition ();
712   virtual ~FGCondition ();
713   virtual bool test () const = 0;
714 };
715
716
717 /**
718  * Condition for a single property.
719  *
720  * This condition is true only if the property returns a boolean
721  * true value.
722  */
723 class FGPropertyCondition : public FGCondition
724 {
725 public:
726   FGPropertyCondition (const string &propname);
727   virtual ~FGPropertyCondition ();
728   virtual bool test () const { return _node->getBoolValue(); }
729 private:
730   const SGPropertyNode * _node;
731 };
732
733
734 /**
735  * Condition for a 'not' operator.
736  *
737  * This condition is true only if the child condition is false.
738  */
739 class FGNotCondition : public FGCondition
740 {
741 public:
742                                 // transfer pointer ownership
743   FGNotCondition (FGCondition * condition);
744   virtual ~FGNotCondition ();
745   virtual bool test () const;
746 private:
747   FGCondition * _condition;
748 };
749
750
751 /**
752  * Condition for an 'and' group.
753  *
754  * This condition is true only if all of the conditions
755  * in the group are true.
756  */
757 class FGAndCondition : public FGCondition
758 {
759 public:
760   FGAndCondition ();
761   virtual ~FGAndCondition ();
762   virtual bool test () const;
763                                 // transfer pointer ownership
764   virtual void addCondition (FGCondition * condition);
765 private:
766   vector<FGCondition *> _conditions;
767 };
768
769
770 /**
771  * Condition for an 'or' group.
772  *
773  * This condition is true if at least one of the conditions in the
774  * group is true.
775  */
776 class FGOrCondition : public FGCondition
777 {
778 public:
779   FGOrCondition ();
780   virtual ~FGOrCondition ();
781   virtual bool test () const;
782                                 // transfer pointer ownership
783   virtual void addCondition (FGCondition * condition);
784 private:
785   vector<FGCondition *> _conditions;
786 };
787
788
789 /**
790  * Abstract base class for property comparison conditions.
791  */
792 class FGComparisonCondition : public FGCondition
793 {
794 public:
795   enum Type {
796     LESS_THAN,
797     GREATER_THAN,
798     EQUALS
799   };
800   FGComparisonCondition (Type type, bool reverse = false);
801   virtual ~FGComparisonCondition ();
802   virtual bool test () const;
803   virtual void setLeftProperty (const string &propname);
804   virtual void setRightProperty (const string &propname);
805                                 // will make a local copy
806   virtual void setRightValue (const SGPropertyNode * value);
807 private:
808   Type _type;
809   bool _reverse;
810   const SGPropertyNode * _left_property;
811   const SGPropertyNode * _right_property;
812   const SGPropertyNode * _right_value;
813 };
814
815
816 /**
817  * Base class for a conditional components.
818  *
819  * This class manages the conditions and tests; the component should
820  * invoke the test() method whenever it needs to decide whether to
821  * active itself, draw itself, and so on.
822  */
823 class FGConditional
824 {
825 public:
826   FGConditional ();
827   virtual ~FGConditional ();
828                                 // transfer pointer ownership
829   virtual void setCondition (FGCondition * condition);
830   virtual const FGCondition * getCondition () const { return _condition; }
831   virtual bool test () const;
832 private:
833   FGCondition * _condition;
834 };
835
836
837 /**
838  * Global function to make a condition out of properties.
839  *
840  * The top-level is always an implicit 'and' group, whatever the
841  * node's name (it should usually be "condition").
842  *
843  * @param node The top-level condition node (usually named "condition").
844  * @return A pointer to a newly-allocated condition; it is the
845  *         responsibility of the caller to delete the condition when
846  *         it is no longer needed.
847  */
848 FGCondition * fgReadCondition (const SGPropertyNode * node);
849
850
851 #endif // __FG_PROPS_HXX
852