39 #include "FGPropertyReader.h" 40 #include "FGPropertyManager.h" 41 #include "FGXMLElement.h" 42 #include "FGJSBBase.h" 48 IDENT(IdSrc,
"$Id: FGPropertyReader.cpp,v 1.5 2014/06/14 11:58:31 bcoconni Exp $");
49 IDENT(IdHdr,ID_PROPERTYREADER);
57 bool FGPropertyReader::ResetToIC(
void)
59 map<SGPropertyNode_ptr, double>::iterator it = interface_prop_initial_value.begin();
60 for (;it != interface_prop_initial_value.end(); ++it) {
61 SGPropertyNode* node = it->first;
62 if (!node->getAttribute(SGPropertyNode::PRESERVE))
63 node->setDoubleValue(it->second);
71 void FGPropertyReader::Load(Element* el, FGPropertyManager* PM,
bool override)
74 string interface_property_string =
"";
76 Element *property_element = el->FindElement(
"property");
77 if (property_element && FGJSBBase::debug_lvl > 0) {
83 cout <<
" properties" << endl << endl;
86 while (property_element) {
87 SGPropertyNode* node = 0;
89 if ( ! property_element->GetAttributeValue(
"value").empty())
90 value = property_element->GetAttributeValueAsNumber(
"value");
92 interface_property_string = property_element->GetDataLine();
93 if (PM->HasNode(interface_property_string)) {
95 node = PM->GetNode(interface_property_string);
97 if (FGJSBBase::debug_lvl > 0) {
98 if (interface_prop_initial_value.find(node) == interface_prop_initial_value.end()) {
99 cout << property_element->ReadFrom()
100 <<
" The following property will be overridden but it has not been" << endl
101 <<
" defined in the current model '" << el->GetName() <<
"'" << endl;
104 cout <<
" " <<
"Overriding value for property " << interface_property_string << endl
105 <<
" (old value: " << node->getDoubleValue() <<
" new value: " << value <<
")" 109 node->setDoubleValue(value);
112 cerr << property_element->ReadFrom()
113 <<
" Property " << interface_property_string
114 <<
" is already defined." << endl;
115 property_element = el->FindNextElement(
"property");
119 node = PM->GetNode(interface_property_string,
true);
121 node->setDoubleValue(value);
123 if (FGJSBBase::debug_lvl > 0)
124 cout <<
" " << interface_property_string <<
" (initial value: " 125 << value <<
")" << endl << endl;
128 cerr <<
"Could not create property " << interface_property_string
130 property_element = el->FindNextElement(
"property");
134 interface_prop_initial_value[node] = value;
135 if (property_element->GetAttributeValue(
"persistent") == string(
"true"))
136 node->setAttribute(SGPropertyNode::PRESERVE,
true);
138 property_element = el->FindNextElement(
"property");