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();
105 static string result = ""; // FIXME
106 for (int i = 0; log_class_mappings[i].c != SG_UNDEFD; i++) {
107 if ((classes&log_class_mappings[i].c) > 0) {
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.empty() || 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.empty() || 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.
252 static char buf[64]; // FIXME
253 struct tm * t = globals->get_time_params()->getGmt();
254 sprintf(buf, "%.4d-%.2d-%.2dT%.2d:%.2d:%.2d",
255 t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
256 t->tm_hour, t->tm_min, t->tm_sec);
262 * Set the current Zulu time.
265 setDateString (const char * date_string)
267 static const SGPropertyNode *cur_time_override
268 = fgGetNode("/sim/time/cur-time-override", true);
270 SGTime * st = globals->get_time_params();
271 struct tm * current_time = st->getGmt();
274 // Scan for basic ISO format
275 // YYYY-MM-DDTHH:MM:SS
276 int ret = sscanf(date_string, "%d-%d-%dT%d:%d:%d",
277 &(new_time.tm_year), &(new_time.tm_mon),
278 &(new_time.tm_mday), &(new_time.tm_hour),
279 &(new_time.tm_min), &(new_time.tm_sec));
281 // Be pretty picky about this, so
282 // that strange things don't happen
283 // if the save file has been edited
286 SG_LOG(SG_INPUT, SG_ALERT, "Date/time string " << date_string
287 << " not in YYYY-MM-DDTHH:MM:SS format; skipped");
291 // OK, it looks like we got six
292 // values, one way or another.
293 new_time.tm_year -= 1900;
294 new_time.tm_mon -= 1;
296 // Now, tell flight gear to use
297 // the new time. This was far
298 // too difficult, by the way.
300 mktime(&new_time) - mktime(current_time) + globals->get_warp();
301 double lon = current_aircraft.fdm_state->get_Longitude();
302 double lat = current_aircraft.fdm_state->get_Latitude();
303 globals->set_warp(warp);
304 st->update(lon, lat, cur_time_override->getLongValue(), warp);
305 fgUpdateSkyAndLightingParams();
309 * Return the GMT as a string.
314 static char buf[16]; // FIXME
315 struct tm *t = globals->get_time_params()->getGmt();
316 sprintf(buf, " %.2d:%.2d:%.2d",
317 t->tm_hour, t->tm_min, t->tm_sec);
318 // cout << t << " " << buf << endl;
324 * Get the texture rendering state.
329 return (material_lib.get_step() == 0);
334 * Set the texture rendering state.
337 setTextures (bool textures)
340 material_lib.set_step(0);
342 material_lib.set_step(1);
347 * Return the magnetic variation
352 return globals->get_mag()->get_magvar() * SGD_RADIANS_TO_DEGREES;
357 * Return the magnetic dip
362 return globals->get_mag()->get_magdip() * SGD_RADIANS_TO_DEGREES;
367 * Return the current heading in degrees.
372 return current_aircraft.fdm_state->get_Psi() * SGD_RADIANS_TO_DEGREES - getMagVar();
376 #if !defined(FG_NEW_ENVIRONMENT)
379 * Get the current visibility (meters).
384 return WeatherDatabase->getWeatherVisibility();
389 * Set the current visibility (meters).
392 setVisibility (double visibility)
394 WeatherDatabase->setWeatherVisibility(visibility);
398 * Get the current wind north velocity (feet/second).
403 return current_aircraft.fdm_state->get_V_north_airmass();
408 * Set the current wind north velocity (feet/second).
411 setWindNorth (double speed)
413 current_aircraft.fdm_state
414 ->set_Velocities_Local_Airmass(speed, getWindEast(), getWindDown());
419 * Get the current wind east velocity (feet/second).
424 return current_aircraft.fdm_state->get_V_east_airmass();
429 * Set the current wind east velocity (feet/second).
432 setWindEast (double speed)
434 cout << "Set wind-east to " << speed << endl;
435 current_aircraft.fdm_state->set_Velocities_Local_Airmass(getWindNorth(),
442 * Get the current wind down velocity (feet/second).
447 return current_aircraft.fdm_state->get_V_down_airmass();
452 * Set the current wind down velocity (feet/second).
455 setWindDown (double speed)
457 current_aircraft.fdm_state->set_Velocities_Local_Airmass(getWindNorth(),
462 #endif // FG_NEW_ENVIRONMENT
467 return globals->get_warp();
473 globals->set_warp(warp);
479 return globals->get_warp_delta();
483 setWarpDelta (long delta)
485 globals->set_warp_delta(delta);
495 setWindingCCW (bool state)
499 glFrontFace ( GL_CCW );
501 glFrontFace ( GL_CW );
507 #if defined(FX) && !defined(WIN32)
508 return globals->get_fullscreen();
515 setFullScreen (bool state)
517 #if defined(FX) && !defined(WIN32)
518 globals->set_fullscreen(state);
519 # if defined(XMESA_FX_FULLSCREEN) && defined(XMESA_FX_WINDOW)
520 XMesaSetFXmode( state ? XMESA_FX_FULLSCREEN : XMESA_FX_WINDOW );
528 return fdm_data_logging;
532 setFDMDataLogging (bool state)
534 // kludge; no getter or setter available
535 if (state != fdm_data_logging) {
536 fgToggleFDMdataLogging();
537 fdm_data_logging = state;
542 ////////////////////////////////////////////////////////////////////////
543 // Tie the properties.
544 ////////////////////////////////////////////////////////////////////////
550 fgTie("/sim/logging/priority", getLoggingPriority, setLoggingPriority);
551 fgTie("/sim/logging/classes", getLoggingClasses, setLoggingClasses);
552 // fgTie("/sim/freeze", getFreeze, setFreeze);
553 fgTie("/sim/aircraft-dir", getAircraftDir, setAircraftDir);
555 fgTie("/sim/time/elapsed-ms", getElapsedTime_ms);
556 fgTie("/sim/time/gmt", getDateString, setDateString);
557 fgSetArchivable("/sim/time/gmt");
558 fgTie("/sim/time/gmt-string", getGMTString);
559 fgTie("/sim/rendering/textures", getTextures, setTextures);
562 fgTie("/orientation/heading-magnetic-deg", getHeadingMag);
565 #if !defined(FG_NEW_ENVIRONMENT)
566 fgTie("/environment/visibility-m", getVisibility, setVisibility);
567 fgSetArchivable("/environment/visibility-m");
568 fgTie("/environment/wind-from-north-fps", getWindNorth, setWindNorth);
569 fgSetArchivable("/environment/wind-from-north-fps");
570 fgTie("/environment/wind-from-east-fps", getWindEast, setWindEast);
571 fgSetArchivable("/environment/wind-from-east-fps");
572 fgTie("/environment/wind-from-down-fps", getWindDown, setWindDown);
573 fgSetArchivable("/environment/wind-from-down-fps");
576 fgTie("/environment/magnetic-variation-deg", getMagVar);
577 fgTie("/environment/magnetic-dip-deg", getMagDip);
579 fgTie("/sim/time/warp", getWarp, setWarp, false);
580 fgTie("/sim/time/warp-delta", getWarpDelta, setWarpDelta);
582 // Misc. Temporary junk.
583 fgTie("/sim/temp/winding-ccw", getWindingCCW, setWindingCCW, false);
584 fgTie("/sim/temp/full-screen", getFullScreen, setFullScreen);
585 fgTie("/sim/temp/fdm-data-logging", getFDMDataLogging, setFDMDataLogging);
597 ////////////////////////////////////////////////////////////////////////
599 ////////////////////////////////////////////////////////////////////////
603 * Save the current state of the simulator to a stream.
606 fgSaveFlight (ostream &output, bool write_all)
609 fgSetBool("/sim/startup/onground", false);
610 fgSetArchivable("/sim/startup/onground");
611 fgSetBool("/sim/startup/trim", false);
612 fgSetArchivable("/sim/startup/trim");
613 fgSetString("/sim/startup/speed-set", "UVW");
614 fgSetArchivable("/sim/startup/speed-set");
617 writeProperties(output, globals->get_props(), write_all);
618 } catch (const sg_exception &e) {
619 guiErrorMessage("Error saving flight: ", e);
627 * Restore the current state of the simulator from a stream.
630 fgLoadFlight (istream &input)
632 SGPropertyNode props;
634 readProperties(input, &props);
635 } catch (const sg_exception &e) {
636 guiErrorMessage("Error reading saved flight: ", e);
640 fgSetBool("/sim/startup/onground", false);
641 fgSetBool("/sim/startup/trim", false);
642 fgSetString("/sim/startup/speed-set", "UVW");
644 copyProperties(&props, globals->get_props());
645 // When loading a flight, make it the
646 // new initial state.
647 globals->saveInitialState();
653 ////////////////////////////////////////////////////////////////////////
654 // Property convenience functions.
655 ////////////////////////////////////////////////////////////////////////
658 fgGetNode (const char * path, bool create)
660 return globals->get_props()->getNode(path, create);
664 fgGetNode (const char * path, int index, bool create)
666 return globals->get_props()->getNode(path, index, create);
670 fgHasNode (const char * path)
672 return (fgGetNode(path, false) != 0);
676 fgGetBool (const char * name, bool defaultValue)
678 return globals->get_props()->getBoolValue(name, defaultValue);
682 fgGetInt (const char * name, int defaultValue)
684 return globals->get_props()->getIntValue(name, defaultValue);
688 fgGetLong (const char * name, long defaultValue)
690 return globals->get_props()->getLongValue(name, defaultValue);
694 fgGetFloat (const char * name, float defaultValue)
696 return globals->get_props()->getFloatValue(name, defaultValue);
700 fgGetDouble (const char * name, double defaultValue)
702 return globals->get_props()->getDoubleValue(name, defaultValue);
706 fgGetString (const char * name, const char * defaultValue)
708 return globals->get_props()->getStringValue(name, defaultValue);
712 fgSetBool (const char * name, bool val)
714 return globals->get_props()->setBoolValue(name, val);
718 fgSetInt (const char * name, int val)
720 return globals->get_props()->setIntValue(name, val);
724 fgSetLong (const char * name, long val)
726 return globals->get_props()->setLongValue(name, val);
730 fgSetFloat (const char * name, float val)
732 return globals->get_props()->setFloatValue(name, val);
736 fgSetDouble (const char * name, double val)
738 return globals->get_props()->setDoubleValue(name, val);
742 fgSetString (const char * name, const char * val)
744 return globals->get_props()->setStringValue(name, val);
748 fgSetArchivable (const char * name, bool state)
750 SGPropertyNode * node = globals->get_props()->getNode(name);
752 SG_LOG(SG_GENERAL, SG_ALERT,
753 "Attempt to set archive flag for non-existant property "
756 node->setAttribute(SGPropertyNode::ARCHIVE, state);
760 fgSetReadable (const char * name, bool state)
762 SGPropertyNode * node = globals->get_props()->getNode(name);
764 SG_LOG(SG_GENERAL, SG_ALERT,
765 "Attempt to set read flag for non-existant property "
768 node->setAttribute(SGPropertyNode::READ, state);
772 fgSetWritable (const char * name, bool state)
774 SGPropertyNode * node = globals->get_props()->getNode(name);
776 SG_LOG(SG_GENERAL, SG_ALERT,
777 "Attempt to set write flag for non-existant property "
780 node->setAttribute(SGPropertyNode::WRITE, state);
784 fgUntie (const char * name)
786 if (!globals->get_props()->untie(name))
787 SG_LOG(SG_GENERAL, SG_WARN, "Failed to untie property " << name);
793 ////////////////////////////////////////////////////////////////////////
794 // Implementation of FGCondition.
795 ////////////////////////////////////////////////////////////////////////
797 FGCondition::FGCondition ()
801 FGCondition::~FGCondition ()
807 ////////////////////////////////////////////////////////////////////////
808 // Implementation of FGPropertyCondition.
809 ////////////////////////////////////////////////////////////////////////
811 FGPropertyCondition::FGPropertyCondition (const char * propname)
812 : _node(fgGetNode(propname, true))
816 FGPropertyCondition::~FGPropertyCondition ()
822 ////////////////////////////////////////////////////////////////////////
823 // Implementation of FGNotCondition.
824 ////////////////////////////////////////////////////////////////////////
826 FGNotCondition::FGNotCondition (FGCondition * condition)
827 : _condition(condition)
831 FGNotCondition::~FGNotCondition ()
837 FGNotCondition::test () const
839 return !(_condition->test());
844 ////////////////////////////////////////////////////////////////////////
845 // Implementation of FGAndCondition.
846 ////////////////////////////////////////////////////////////////////////
848 FGAndCondition::FGAndCondition ()
852 FGAndCondition::~FGAndCondition ()
854 for (unsigned int i = 0; i < _conditions.size(); i++)
855 delete _conditions[i];
859 FGAndCondition::test () const
861 int nConditions = _conditions.size();
862 for (int i = 0; i < nConditions; i++) {
863 if (!_conditions[i]->test())
870 FGAndCondition::addCondition (FGCondition * condition)
872 _conditions.push_back(condition);
877 ////////////////////////////////////////////////////////////////////////
878 // Implementation of FGOrCondition.
879 ////////////////////////////////////////////////////////////////////////
881 FGOrCondition::FGOrCondition ()
885 FGOrCondition::~FGOrCondition ()
887 for (unsigned int i = 0; i < _conditions.size(); i++)
888 delete _conditions[i];
892 FGOrCondition::test () const
894 int nConditions = _conditions.size();
895 for (int i = 0; i < nConditions; i++) {
896 if (_conditions[i]->test())
903 FGOrCondition::addCondition (FGCondition * condition)
905 _conditions.push_back(condition);
910 ////////////////////////////////////////////////////////////////////////
911 // Implementation of FGComparisonCondition.
912 ////////////////////////////////////////////////////////////////////////
915 doComparison (const SGPropertyNode * left, const SGPropertyNode *right)
917 switch (left->getType()) {
918 case SGPropertyNode::BOOL: {
919 bool v1 = left->getBoolValue();
920 bool v2 = right->getBoolValue();
922 return FGComparisonCondition::LESS_THAN;
924 return FGComparisonCondition::GREATER_THAN;
926 return FGComparisonCondition::EQUALS;
929 case SGPropertyNode::INT: {
930 int v1 = left->getIntValue();
931 int v2 = right->getIntValue();
933 return FGComparisonCondition::LESS_THAN;
935 return FGComparisonCondition::GREATER_THAN;
937 return FGComparisonCondition::EQUALS;
940 case SGPropertyNode::LONG: {
941 long v1 = left->getLongValue();
942 long v2 = right->getLongValue();
944 return FGComparisonCondition::LESS_THAN;
946 return FGComparisonCondition::GREATER_THAN;
948 return FGComparisonCondition::EQUALS;
951 case SGPropertyNode::FLOAT: {
952 float v1 = left->getFloatValue();
953 float v2 = right->getFloatValue();
955 return FGComparisonCondition::LESS_THAN;
957 return FGComparisonCondition::GREATER_THAN;
959 return FGComparisonCondition::EQUALS;
962 case SGPropertyNode::DOUBLE: {
963 double v1 = left->getDoubleValue();
964 double v2 = right->getDoubleValue();
966 return FGComparisonCondition::LESS_THAN;
968 return FGComparisonCondition::GREATER_THAN;
970 return FGComparisonCondition::EQUALS;
973 case SGPropertyNode::STRING:
974 case SGPropertyNode::NONE:
975 case SGPropertyNode::UNSPECIFIED: {
976 string v1 = left->getStringValue();
977 string v2 = right->getStringValue();
979 return FGComparisonCondition::LESS_THAN;
981 return FGComparisonCondition::GREATER_THAN;
983 return FGComparisonCondition::EQUALS;
987 throw sg_exception("Unrecognized node type");
992 FGComparisonCondition::FGComparisonCondition (Type type, bool reverse)
1001 FGComparisonCondition::~FGComparisonCondition ()
1003 delete _right_value;
1007 FGComparisonCondition::test () const
1009 // Always fail if incompletely specified
1010 if (_left_property == 0 ||
1011 (_right_property == 0 && _right_value == 0))
1014 // Get LESS_THAN, EQUALS, or GREATER_THAN
1016 doComparison(_left_property,
1017 (_right_property != 0 ? _right_property : _right_value));
1019 return (cmp == _type);
1021 return (cmp != _type);
1025 FGComparisonCondition::setLeftProperty (const char * propname)
1027 _left_property = fgGetNode(propname, true);
1031 FGComparisonCondition::setRightProperty (const char * propname)
1033 delete _right_value;
1035 _right_property = fgGetNode(propname, true);
1039 FGComparisonCondition::setRightValue (const SGPropertyNode *node)
1041 _right_property = 0;
1042 delete _right_value;
1043 _right_value = new SGPropertyNode(*node);
1048 ////////////////////////////////////////////////////////////////////////
1049 // Read a condition and use it if necessary.
1050 ////////////////////////////////////////////////////////////////////////
1052 // Forward declaration
1053 static FGCondition * readCondition (const SGPropertyNode * node);
1055 static FGCondition *
1056 readPropertyCondition (const SGPropertyNode * node)
1058 return new FGPropertyCondition(node->getStringValue());
1061 static FGCondition *
1062 readNotCondition (const SGPropertyNode * node)
1064 int nChildren = node->nChildren();
1065 for (int i = 0; i < nChildren; i++) {
1066 const SGPropertyNode * child = node->getChild(i);
1067 FGCondition * condition = readCondition(child);
1069 return new FGNotCondition(condition);
1071 SG_LOG(SG_COCKPIT, SG_ALERT, "Panel: empty 'not' condition");
1075 static FGCondition *
1076 readAndConditions (const SGPropertyNode * node)
1078 FGAndCondition * andCondition = new FGAndCondition;
1079 int nChildren = node->nChildren();
1080 for (int i = 0; i < nChildren; i++) {
1081 const SGPropertyNode * child = node->getChild(i);
1082 FGCondition * condition = readCondition(child);
1084 andCondition->addCondition(condition);
1086 return andCondition;
1089 static FGCondition *
1090 readOrConditions (const SGPropertyNode * node)
1092 FGOrCondition * orCondition = new FGOrCondition;
1093 int nChildren = node->nChildren();
1094 for (int i = 0; i < nChildren; i++) {
1095 const SGPropertyNode * child = node->getChild(i);
1096 FGCondition * condition = readCondition(child);
1098 orCondition->addCondition(condition);
1103 static FGCondition *
1104 readComparison (const SGPropertyNode * node,
1105 FGComparisonCondition::Type type,
1108 FGComparisonCondition * condition = new FGComparisonCondition(type, reverse);
1109 condition->setLeftProperty(node->getStringValue("property[0]"));
1110 if (node->hasValue("property[1]"))
1111 condition->setRightProperty(node->getStringValue("property[1]"));
1113 condition->setRightValue(node->getChild("value", 0));
1118 static FGCondition *
1119 readCondition (const SGPropertyNode * node)
1121 const string &name = node->getName();
1122 if (name == "property")
1123 return readPropertyCondition(node);
1124 else if (name == "not")
1125 return readNotCondition(node);
1126 else if (name == "and")
1127 return readAndConditions(node);
1128 else if (name == "or")
1129 return readOrConditions(node);
1130 else if (name == "less-than")
1131 return readComparison(node, FGComparisonCondition::LESS_THAN, false);
1132 else if (name == "less-than-equals")
1133 return readComparison(node, FGComparisonCondition::GREATER_THAN, true);
1134 else if (name == "greater-than")
1135 return readComparison(node, FGComparisonCondition::GREATER_THAN, false);
1136 else if (name == "greater-than-equals")
1137 return readComparison(node, FGComparisonCondition::LESS_THAN, true);
1138 else if (name == "equals")
1139 return readComparison(node, FGComparisonCondition::EQUALS, false);
1140 else if (name == "not-equals")
1141 return readComparison(node, FGComparisonCondition::EQUALS, true);
1148 ////////////////////////////////////////////////////////////////////////
1149 // Implementation of FGConditional.
1150 ////////////////////////////////////////////////////////////////////////
1152 FGConditional::FGConditional ()
1157 FGConditional::~FGConditional ()
1163 FGConditional::setCondition (FGCondition * condition)
1166 _condition = condition;
1170 FGConditional::test () const
1172 return ((_condition == 0) || _condition->test());
1177 // The top-level is always an implicit 'and' group
1179 fgReadCondition (const SGPropertyNode * node)
1181 return readAndConditions(node);
1185 // end of fg_props.cxx