1 // fg_props.cxx -- support for FlightGear properties.
3 // Written by David Megginson, started 2000.
5 // Copyright (C) 2000, 2001 David Megginson - david@megginson.com
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 # include <simgear/compiler.h>
27 #include <simgear/misc/exception.hxx>
28 #include <simgear/magvar/magvar.hxx>
29 #include <simgear/timing/sg_time.hxx>
33 #include <ATC/ATCdisplay.hxx>
34 #include <Aircraft/aircraft.hxx>
35 #include <Time/tmp.hxx>
36 #include <FDM/UIUCModel/uiuc_aircraftdir.h>
37 #ifndef FG_NEW_ENVIRONMENT
38 # include <WeatherCM/FGLocalWeatherDatabase.h>
40 # include <Environment/environment.hxx>
41 #endif // FG_NEW_ENVIRONMENT
42 #include <Objects/matlib.hxx>
46 #include "globals.hxx"
48 #include "fg_props.hxx"
50 #if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
51 SG_USING_STD(istream);
52 SG_USING_STD(ostream);
55 #if !defined(FG_NEW_ENVIRONMENT)
56 static double getWindNorth ();
57 static double getWindEast ();
58 static double getWindDown ();
59 #endif // FG_NEW_ENVIRONMENT
61 static bool winding_ccw = true; // FIXME: temporary
63 static bool fdm_data_logging = false; // FIXME: temporary
67 ////////////////////////////////////////////////////////////////////////
68 // Default property bindings (not yet handled by any module).
69 ////////////////////////////////////////////////////////////////////////
71 struct LogClassMapping {
74 LogClassMapping(sgDebugClass cc, string nname) { c = cc; name = nname; }
77 LogClassMapping log_class_mappings [] = {
78 LogClassMapping(SG_NONE, "none"),
79 LogClassMapping(SG_TERRAIN, "terrain"),
80 LogClassMapping(SG_ASTRO, "astro"),
81 LogClassMapping(SG_FLIGHT, "flight"),
82 LogClassMapping(SG_INPUT, "input"),
83 LogClassMapping(SG_GL, "gl"),
84 LogClassMapping(SG_VIEW, "view"),
85 LogClassMapping(SG_COCKPIT, "cockpit"),
86 LogClassMapping(SG_GENERAL, "general"),
87 LogClassMapping(SG_MATH, "math"),
88 LogClassMapping(SG_EVENT, "event"),
89 LogClassMapping(SG_AIRCRAFT, "aircraft"),
90 LogClassMapping(SG_AUTOPILOT, "autopilot"),
91 LogClassMapping(SG_IO, "io"),
92 LogClassMapping(SG_CLIPPER, "clipper"),
93 LogClassMapping(SG_NETWORK, "network"),
94 LogClassMapping(SG_UNDEFD, "")
99 * Get the logging classes.
104 sgDebugClass classes = logbuf::get_log_classes();
106 for (int i = 0; log_class_mappings[i].c != SG_UNDEFD; i++) {
107 if ((classes&log_class_mappings[i].c) > 0) {
108 if (result != (string)"")
110 result += log_class_mappings[i].name;
113 return result.c_str();
118 addLoggingClass (const string &name)
120 sgDebugClass classes = logbuf::get_log_classes();
121 for (int i = 0; log_class_mappings[i].c != SG_UNDEFD; i++) {
122 if (name == log_class_mappings[i].name) {
123 logbuf::set_log_classes(sgDebugClass(classes|log_class_mappings[i].c));
127 SG_LOG(SG_GENERAL, SG_ALERT, "Unknown logging class: " << name);
132 * Set the logging classes.
135 setLoggingClasses (const char * c)
138 logbuf::set_log_classes(SG_NONE);
140 if (classes == "none") {
141 SG_LOG(SG_GENERAL, SG_INFO, "Disabled all logging classes");
145 if (classes == "" || classes == "all") { // default
146 logbuf::set_log_classes(SG_ALL);
147 SG_LOG(SG_GENERAL, SG_INFO, "Enabled all logging classes: "
148 << getLoggingClasses());
152 string rest = classes;
154 int sep = rest.find('|');
156 name = rest.substr(0, sep);
157 rest = rest.substr(sep+1);
158 addLoggingClass(name);
159 sep = rest.find('|');
161 addLoggingClass(rest);
162 SG_LOG(SG_GENERAL, SG_INFO, "Set logging classes to "
163 << getLoggingClasses());
168 * Get the logging priority.
171 getLoggingPriority ()
173 switch (logbuf::get_log_priority()) {
185 SG_LOG(SG_GENERAL, SG_WARN, "Internal: Unknown logging priority number: "
186 << logbuf::get_log_priority());
193 * Set the logging priority.
196 setLoggingPriority (const char * p)
199 if (priority == "bulk") {
200 logbuf::set_log_priority(SG_BULK);
201 } else if (priority == "debug") {
202 logbuf::set_log_priority(SG_DEBUG);
203 } else if (priority == "" || priority == "info") { // default
204 logbuf::set_log_priority(SG_INFO);
205 } else if (priority == "warn") {
206 logbuf::set_log_priority(SG_WARN);
207 } else if (priority == "alert") {
208 logbuf::set_log_priority(SG_ALERT);
210 SG_LOG(SG_GENERAL, SG_WARN, "Unknown logging priority " << priority);
212 SG_LOG(SG_GENERAL, SG_INFO, "Logging priority is " << getLoggingPriority());
217 * Return the current aircraft directory (UIUC) as a string.
222 return aircraft_dir.c_str();
227 * Set the current aircraft directory (UIUC).
230 setAircraftDir (const char * dir)
237 * Return the number of milliseconds elapsed since simulation started.
242 return globals->get_elapsed_time_ms();
247 * Return the current Zulu time.
254 struct tm * t = globals->get_time_params()->getGmt();
255 sprintf(buf, "%.4d-%.2d-%.2dT%.2d:%.2d:%.2d",
256 t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
257 t->tm_hour, t->tm_min, t->tm_sec);
264 * Set the current Zulu time.
267 setDateString (const char * date_string)
269 static const SGPropertyNode *cur_time_override
270 = fgGetNode("/sim/time/cur-time-override", true);
272 SGTime * st = globals->get_time_params();
273 struct tm * current_time = st->getGmt();
276 // Scan for basic ISO format
277 // YYYY-MM-DDTHH:MM:SS
278 int ret = sscanf(date_string, "%d-%d-%dT%d:%d:%d",
279 &(new_time.tm_year), &(new_time.tm_mon),
280 &(new_time.tm_mday), &(new_time.tm_hour),
281 &(new_time.tm_min), &(new_time.tm_sec));
283 // Be pretty picky about this, so
284 // that strange things don't happen
285 // if the save file has been edited
288 SG_LOG(SG_INPUT, SG_ALERT, "Date/time string " << date_string
289 << " not in YYYY-MM-DDTHH:MM:SS format; skipped");
293 // OK, it looks like we got six
294 // values, one way or another.
295 new_time.tm_year -= 1900;
296 new_time.tm_mon -= 1;
298 // Now, tell flight gear to use
299 // the new time. This was far
300 // too difficult, by the way.
302 mktime(&new_time) - mktime(current_time) + globals->get_warp();
303 double lon = current_aircraft.fdm_state->get_Longitude();
304 double lat = current_aircraft.fdm_state->get_Latitude();
305 globals->set_warp(warp);
306 st->update(lon, lat, cur_time_override->getLongValue(), warp);
307 fgUpdateSkyAndLightingParams();
311 * Return the GMT as a string.
318 struct tm *t = globals->get_time_params()->getGmt();
319 sprintf(buf, " %.2d:%.2d:%.2d",
320 t->tm_hour, t->tm_min, t->tm_sec);
321 // cout << t << " " << buf << endl;
328 * Get the texture rendering state.
333 return (material_lib.get_step() == 0);
338 * Set the texture rendering state.
341 setTextures (bool textures)
344 material_lib.set_step(0);
346 material_lib.set_step(1);
351 * Return the magnetic variation
356 return globals->get_mag()->get_magvar() * SGD_RADIANS_TO_DEGREES;
361 * Return the magnetic dip
366 return globals->get_mag()->get_magdip() * SGD_RADIANS_TO_DEGREES;
371 * Return the current heading in degrees.
376 return current_aircraft.fdm_state->get_Psi() * SGD_RADIANS_TO_DEGREES - getMagVar();
380 #if !defined(FG_NEW_ENVIRONMENT)
383 * Get the current visibility (meters).
388 return WeatherDatabase->getWeatherVisibility();
393 * Set the current visibility (meters).
396 setVisibility (double visibility)
398 WeatherDatabase->setWeatherVisibility(visibility);
402 * Get the current wind north velocity (feet/second).
407 return current_aircraft.fdm_state->get_V_north_airmass();
412 * Set the current wind north velocity (feet/second).
415 setWindNorth (double speed)
417 current_aircraft.fdm_state
418 ->set_Velocities_Local_Airmass(speed, getWindEast(), getWindDown());
423 * Get the current wind east velocity (feet/second).
428 return current_aircraft.fdm_state->get_V_east_airmass();
433 * Set the current wind east velocity (feet/second).
436 setWindEast (double speed)
438 cout << "Set wind-east to " << speed << endl;
439 current_aircraft.fdm_state->set_Velocities_Local_Airmass(getWindNorth(),
446 * Get the current wind down velocity (feet/second).
451 return current_aircraft.fdm_state->get_V_down_airmass();
456 * Set the current wind down velocity (feet/second).
459 setWindDown (double speed)
461 current_aircraft.fdm_state->set_Velocities_Local_Airmass(getWindNorth(),
466 #endif // FG_NEW_ENVIRONMENT
471 return globals->get_warp();
477 globals->set_warp(warp);
483 return globals->get_warp_delta();
487 setWarpDelta (long delta)
489 globals->set_warp_delta(delta);
499 setWindingCCW (bool state)
503 glFrontFace ( GL_CCW );
505 glFrontFace ( GL_CW );
511 #if defined(FX) && !defined(WIN32)
512 return globals->get_fullscreen();
519 setFullScreen (bool state)
521 #if defined(FX) && !defined(WIN32)
522 globals->set_fullscreen(state);
523 # if defined(XMESA_FX_FULLSCREEN) && defined(XMESA_FX_WINDOW)
524 XMesaSetFXmode( state ? XMESA_FX_FULLSCREEN : XMESA_FX_WINDOW );
532 return fdm_data_logging;
536 setFDMDataLogging (bool state)
538 // kludge; no getter or setter available
539 if (state != fdm_data_logging) {
540 fgToggleFDMdataLogging();
541 fdm_data_logging = state;
546 ////////////////////////////////////////////////////////////////////////
547 // Tie the properties.
548 ////////////////////////////////////////////////////////////////////////
554 fgTie("/sim/logging/priority", getLoggingPriority, setLoggingPriority);
555 fgTie("/sim/logging/classes", getLoggingClasses, setLoggingClasses);
556 // fgTie("/sim/freeze", getFreeze, setFreeze);
557 fgTie("/sim/aircraft-dir", getAircraftDir, setAircraftDir);
559 fgTie("/sim/time/elapsed-ms", getElapsedTime_ms);
560 fgTie("/sim/time/gmt", getDateString, setDateString);
561 fgSetArchivable("/sim/time/gmt");
562 fgTie("/sim/time/gmt-string", getGMTString);
563 fgTie("/sim/rendering/textures", getTextures, setTextures);
566 fgTie("/orientation/heading-magnetic-deg", getHeadingMag);
569 #if !defined(FG_NEW_ENVIRONMENT)
570 fgTie("/environment/visibility-m", getVisibility, setVisibility);
571 fgSetArchivable("/environment/visibility-m");
572 fgTie("/environment/wind-from-north-fps", getWindNorth, setWindNorth);
573 fgSetArchivable("/environment/wind-from-north-fps");
574 fgTie("/environment/wind-from-east-fps", getWindEast, setWindEast);
575 fgSetArchivable("/environment/wind-from-east-fps");
576 fgTie("/environment/wind-from-down-fps", getWindDown, setWindDown);
577 fgSetArchivable("/environment/wind-from-down-fps");
580 fgTie("/environment/magnetic-variation-deg", getMagVar);
581 fgTie("/environment/magnetic-dip-deg", getMagDip);
583 fgTie("/sim/time/warp", getWarp, setWarp, false);
584 fgTie("/sim/time/warp-delta", getWarpDelta, setWarpDelta);
586 // Misc. Temporary junk.
587 fgTie("/sim/temp/winding-ccw", getWindingCCW, setWindingCCW, false);
588 fgTie("/sim/temp/full-screen", getFullScreen, setFullScreen);
589 fgTie("/sim/temp/fdm-data-logging", getFDMDataLogging, setFDMDataLogging);
601 ////////////////////////////////////////////////////////////////////////
603 ////////////////////////////////////////////////////////////////////////
607 * Save the current state of the simulator to a stream.
610 fgSaveFlight (ostream &output, bool write_all)
613 fgSetBool("/sim/startup/onground", false);
614 fgSetArchivable("/sim/startup/onground");
615 fgSetBool("/sim/startup/trim", false);
616 fgSetArchivable("/sim/startup/trim");
617 fgSetString("/sim/startup/speed-set", "UVW");
618 fgSetArchivable("/sim/startup/speed-set");
621 writeProperties(output, globals->get_props(), write_all);
622 } catch (const sg_exception &e) {
623 guiErrorMessage("Error saving flight: ", e);
631 * Restore the current state of the simulator from a stream.
634 fgLoadFlight (istream &input)
636 SGPropertyNode props;
638 readProperties(input, &props);
639 } catch (const sg_exception &e) {
640 guiErrorMessage("Error reading saved flight: ", e);
644 fgSetBool("/sim/startup/onground", false);
645 fgSetBool("/sim/startup/trim", false);
646 fgSetString("/sim/startup/speed-set", "UVW");
648 copyProperties(&props, globals->get_props());
649 // When loading a flight, make it the
650 // new initial state.
651 globals->saveInitialState();
657 ////////////////////////////////////////////////////////////////////////
658 // Property convenience functions.
659 ////////////////////////////////////////////////////////////////////////
662 fgGetNode (const char * path, bool create)
664 return globals->get_props()->getNode(path, create);
668 fgGetNode (const char * path, int index, bool create)
670 return globals->get_props()->getNode(path, index, create);
674 fgHasNode (const char * path)
676 return (fgGetNode(path, false) != 0);
680 fgGetBool (const char * name, bool defaultValue)
682 return globals->get_props()->getBoolValue(name, defaultValue);
686 fgGetInt (const char * name, int defaultValue)
688 return globals->get_props()->getIntValue(name, defaultValue);
692 fgGetLong (const char * name, long defaultValue)
694 return globals->get_props()->getLongValue(name, defaultValue);
698 fgGetFloat (const char * name, float defaultValue)
700 return globals->get_props()->getFloatValue(name, defaultValue);
704 fgGetDouble (const char * name, double defaultValue)
706 return globals->get_props()->getDoubleValue(name, defaultValue);
710 fgGetString (const char * name, const char * defaultValue)
712 return globals->get_props()->getStringValue(name, defaultValue);
716 fgSetBool (const char * name, bool val)
718 return globals->get_props()->setBoolValue(name, val);
722 fgSetInt (const char * name, int val)
724 return globals->get_props()->setIntValue(name, val);
728 fgSetLong (const char * name, long val)
730 return globals->get_props()->setLongValue(name, val);
734 fgSetFloat (const char * name, float val)
736 return globals->get_props()->setFloatValue(name, val);
740 fgSetDouble (const char * name, double val)
742 return globals->get_props()->setDoubleValue(name, val);
746 fgSetString (const char * name, const char * val)
748 return globals->get_props()->setStringValue(name, val);
752 fgSetArchivable (const char * name, bool state)
754 SGPropertyNode * node = globals->get_props()->getNode(name);
756 SG_LOG(SG_GENERAL, SG_ALERT,
757 "Attempt to set archive flag for non-existant property "
760 node->setAttribute(SGPropertyNode::ARCHIVE, state);
764 fgSetReadable (const char * name, bool state)
766 SGPropertyNode * node = globals->get_props()->getNode(name);
768 SG_LOG(SG_GENERAL, SG_ALERT,
769 "Attempt to set read flag for non-existant property "
772 node->setAttribute(SGPropertyNode::READ, state);
776 fgSetWritable (const char * name, bool state)
778 SGPropertyNode * node = globals->get_props()->getNode(name);
780 SG_LOG(SG_GENERAL, SG_ALERT,
781 "Attempt to set write flag for non-existant property "
784 node->setAttribute(SGPropertyNode::WRITE, state);
788 fgUntie (const char * name)
790 if (!globals->get_props()->untie(name))
791 SG_LOG(SG_GENERAL, SG_WARN, "Failed to untie property " << name);
797 ////////////////////////////////////////////////////////////////////////
798 // Implementation of FGCondition.
799 ////////////////////////////////////////////////////////////////////////
801 FGCondition::FGCondition ()
805 FGCondition::~FGCondition ()
811 ////////////////////////////////////////////////////////////////////////
812 // Implementation of FGPropertyCondition.
813 ////////////////////////////////////////////////////////////////////////
815 FGPropertyCondition::FGPropertyCondition (const char * propname)
816 : _node(fgGetNode(propname, true))
820 FGPropertyCondition::~FGPropertyCondition ()
826 ////////////////////////////////////////////////////////////////////////
827 // Implementation of FGNotCondition.
828 ////////////////////////////////////////////////////////////////////////
830 FGNotCondition::FGNotCondition (FGCondition * condition)
831 : _condition(condition)
835 FGNotCondition::~FGNotCondition ()
841 FGNotCondition::test () const
843 return !(_condition->test());
848 ////////////////////////////////////////////////////////////////////////
849 // Implementation of FGAndCondition.
850 ////////////////////////////////////////////////////////////////////////
852 FGAndCondition::FGAndCondition ()
856 FGAndCondition::~FGAndCondition ()
858 for (unsigned int i = 0; i < _conditions.size(); i++)
859 delete _conditions[i];
863 FGAndCondition::test () const
865 int nConditions = _conditions.size();
866 for (int i = 0; i < nConditions; i++) {
867 if (!_conditions[i]->test())
874 FGAndCondition::addCondition (FGCondition * condition)
876 _conditions.push_back(condition);
881 ////////////////////////////////////////////////////////////////////////
882 // Implementation of FGOrCondition.
883 ////////////////////////////////////////////////////////////////////////
885 FGOrCondition::FGOrCondition ()
889 FGOrCondition::~FGOrCondition ()
891 for (unsigned int i = 0; i < _conditions.size(); i++)
892 delete _conditions[i];
896 FGOrCondition::test () const
898 int nConditions = _conditions.size();
899 for (int i = 0; i < nConditions; i++) {
900 if (_conditions[i]->test())
907 FGOrCondition::addCondition (FGCondition * condition)
909 _conditions.push_back(condition);
914 ////////////////////////////////////////////////////////////////////////
915 // Implementation of FGComparisonCondition.
916 ////////////////////////////////////////////////////////////////////////
919 doComparison (const SGPropertyNode * left, const SGPropertyNode *right)
921 switch (left->getType()) {
922 case SGPropertyNode::BOOL: {
923 bool v1 = left->getBoolValue();
924 bool v2 = right->getBoolValue();
926 return FGComparisonCondition::LESS_THAN;
928 return FGComparisonCondition::GREATER_THAN;
930 return FGComparisonCondition::EQUALS;
933 case SGPropertyNode::INT: {
934 int v1 = left->getIntValue();
935 int v2 = right->getIntValue();
937 return FGComparisonCondition::LESS_THAN;
939 return FGComparisonCondition::GREATER_THAN;
941 return FGComparisonCondition::EQUALS;
944 case SGPropertyNode::LONG: {
945 long v1 = left->getLongValue();
946 long v2 = right->getLongValue();
948 return FGComparisonCondition::LESS_THAN;
950 return FGComparisonCondition::GREATER_THAN;
952 return FGComparisonCondition::EQUALS;
955 case SGPropertyNode::FLOAT: {
956 float v1 = left->getFloatValue();
957 float v2 = right->getFloatValue();
959 return FGComparisonCondition::LESS_THAN;
961 return FGComparisonCondition::GREATER_THAN;
963 return FGComparisonCondition::EQUALS;
966 case SGPropertyNode::DOUBLE: {
967 double v1 = left->getDoubleValue();
968 double v2 = right->getDoubleValue();
970 return FGComparisonCondition::LESS_THAN;
972 return FGComparisonCondition::GREATER_THAN;
974 return FGComparisonCondition::EQUALS;
977 case SGPropertyNode::STRING:
978 case SGPropertyNode::NONE:
979 case SGPropertyNode::UNSPECIFIED: {
980 string v1 = left->getStringValue();
981 string v2 = right->getStringValue();
983 return FGComparisonCondition::LESS_THAN;
985 return FGComparisonCondition::GREATER_THAN;
987 return FGComparisonCondition::EQUALS;
991 throw sg_exception("Unrecognized node type");
996 FGComparisonCondition::FGComparisonCondition (Type type, bool reverse)
1005 FGComparisonCondition::~FGComparisonCondition ()
1007 delete _right_value;
1011 FGComparisonCondition::test () const
1013 // Always fail if incompletely specified
1014 if (_left_property == 0 ||
1015 (_right_property == 0 && _right_value == 0))
1018 // Get LESS_THAN, EQUALS, or GREATER_THAN
1020 doComparison(_left_property,
1021 (_right_property != 0 ? _right_property : _right_value));
1023 return (cmp == _type);
1025 return (cmp != _type);
1029 FGComparisonCondition::setLeftProperty (const char * propname)
1031 _left_property = fgGetNode(propname, true);
1035 FGComparisonCondition::setRightProperty (const char * propname)
1037 delete _right_value;
1039 _right_property = fgGetNode(propname, true);
1043 FGComparisonCondition::setRightValue (const SGPropertyNode *node)
1045 _right_property = 0;
1046 delete _right_value;
1047 _right_value = new SGPropertyNode(*node);
1052 ////////////////////////////////////////////////////////////////////////
1053 // Read a condition and use it if necessary.
1054 ////////////////////////////////////////////////////////////////////////
1056 // Forward declaration
1057 static FGCondition * readCondition (const SGPropertyNode * node);
1059 static FGCondition *
1060 readPropertyCondition (const SGPropertyNode * node)
1062 return new FGPropertyCondition(node->getStringValue());
1065 static FGCondition *
1066 readNotCondition (const SGPropertyNode * node)
1068 int nChildren = node->nChildren();
1069 for (int i = 0; i < nChildren; i++) {
1070 const SGPropertyNode * child = node->getChild(i);
1071 FGCondition * condition = readCondition(child);
1073 return new FGNotCondition(condition);
1075 SG_LOG(SG_COCKPIT, SG_ALERT, "Panel: empty 'not' condition");
1079 static FGCondition *
1080 readAndConditions (const SGPropertyNode * node)
1082 FGAndCondition * andCondition = new FGAndCondition;
1083 int nChildren = node->nChildren();
1084 for (int i = 0; i < nChildren; i++) {
1085 const SGPropertyNode * child = node->getChild(i);
1086 FGCondition * condition = readCondition(child);
1088 andCondition->addCondition(condition);
1090 return andCondition;
1093 static FGCondition *
1094 readOrConditions (const SGPropertyNode * node)
1096 FGOrCondition * orCondition = new FGOrCondition;
1097 int nChildren = node->nChildren();
1098 for (int i = 0; i < nChildren; i++) {
1099 const SGPropertyNode * child = node->getChild(i);
1100 FGCondition * condition = readCondition(child);
1102 orCondition->addCondition(condition);
1107 static FGCondition *
1108 readComparison (const SGPropertyNode * node,
1109 FGComparisonCondition::Type type,
1112 FGComparisonCondition * condition = new FGComparisonCondition(type, reverse);
1113 condition->setLeftProperty(node->getStringValue("property[0]"));
1114 if (node->hasValue("property[1]"))
1115 condition->setRightProperty(node->getStringValue("property[1]"));
1117 condition->setRightValue(node->getChild("value", 0));
1122 static FGCondition *
1123 readCondition (const SGPropertyNode * node)
1125 const string &name = node->getName();
1126 if (name == "property")
1127 return readPropertyCondition(node);
1128 else if (name == "not")
1129 return readNotCondition(node);
1130 else if (name == "and")
1131 return readAndConditions(node);
1132 else if (name == "or")
1133 return readOrConditions(node);
1134 else if (name == "less-than")
1135 return readComparison(node, FGComparisonCondition::LESS_THAN, false);
1136 else if (name == "less-than-equals")
1137 return readComparison(node, FGComparisonCondition::GREATER_THAN, true);
1138 else if (name == "greater-than")
1139 return readComparison(node, FGComparisonCondition::GREATER_THAN, false);
1140 else if (name == "greater-than-equals")
1141 return readComparison(node, FGComparisonCondition::LESS_THAN, true);
1142 else if (name == "equals")
1143 return readComparison(node, FGComparisonCondition::EQUALS, false);
1144 else if (name == "not-equals")
1145 return readComparison(node, FGComparisonCondition::EQUALS, true);
1152 ////////////////////////////////////////////////////////////////////////
1153 // Implementation of FGConditional.
1154 ////////////////////////////////////////////////////////////////////////
1156 FGConditional::FGConditional ()
1161 FGConditional::~FGConditional ()
1167 FGConditional::setCondition (FGCondition * condition)
1170 _condition = condition;
1174 FGConditional::test () const
1176 return ((_condition == 0) || _condition->test());
1181 // The top-level is always an implicit 'and' group
1183 fgReadCondition (const SGPropertyNode * node)
1185 return readAndConditions(node);
1189 // end of fg_props.cxx