JSBSim Flight Dynamics Model 1.2.2 (22 Mar 2025)
An Open Source Flight Dynamics and Control Software Library in C++
Loading...
Searching...
No Matches
FGPropertyReader Class Reference

Detailed Description

Definition at line 62 of file FGPropertyReader.h.

Classes

class  const_iterator
 

Public Member Functions

const_iterator begin (void) const
 
bool empty (void) const
 
const_iterator end (void) const
 
void Load (Element *el, FGPropertyManager *PropertyManager, bool override_props)
 
bool ResetToIC (void)
 

Member Function Documentation

◆ begin()

const_iterator begin ( void  ) const
inline

Definition at line 83 of file FGPropertyReader.h.

83{ return const_iterator(interface_prop_initial_value.begin()); }

◆ empty()

bool empty ( void  ) const
inline

Definition at line 85 of file FGPropertyReader.h.

85{ return interface_prop_initial_value.empty(); }

◆ end()

const_iterator end ( void  ) const
inline

Definition at line 84 of file FGPropertyReader.h.

84{ return const_iterator(interface_prop_initial_value.end()); }

◆ Load()

void Load ( Element el,
FGPropertyManager PropertyManager,
bool  override_props 
)

Definition at line 67 of file FGPropertyReader.cpp.

68{
69 Element *property_element = el->FindElement("property");
70 if (property_element && FGJSBBase::debug_lvl > 0) {
71 cout << endl << " ";
72 if (override_props)
73 cout << "Overriding";
74 else
75 cout << "Declared";
76 cout << " properties" << endl << endl;
77 }
78
79 while (property_element) {
80 SGPropertyNode* node = nullptr;
81 double value=0.0;
82 bool has_value_attribute = !property_element->GetAttributeValue("value").empty();
83
84 if (has_value_attribute)
85 value = property_element->GetAttributeValueAsNumber("value");
86
87 string interface_property_string = property_element->GetDataLine();
88 if (PM->HasNode(interface_property_string)) {
89 node = PM->GetNode(interface_property_string);
90 if (override_props) {
91
92 if (FGJSBBase::debug_lvl > 0) {
93 if (interface_prop_initial_value.find(node) == interface_prop_initial_value.end()) {
94 cout << property_element->ReadFrom()
95 << " The following property will be overridden but it has not been" << endl
96 << " defined in the current model '" << el->GetName() << "'" << endl;
97 }
98
99 cout << " " << "Overriding value for property " << interface_property_string << endl
100 << " (old value: " << node->getDoubleValue() << " new value: " << value << ")"
101 << endl << endl;
102 }
103
104 node->setDoubleValue(value);
105 }
106 else {
107 if (has_value_attribute) {
108 cerr << property_element->ReadFrom()
109 << " Property " << interface_property_string
110 << " is already defined." << endl
111 << " Its value (" << node->getDoubleValue() << ") will not"
112 << " be overridden." << endl;
113 }
114 property_element = el->FindNextElement("property");
115 continue;
116 }
117 } else {
118 node = PM->GetNode(interface_property_string, true);
119 if (node) {
120 node->setDoubleValue(value);
121
122 if (FGJSBBase::debug_lvl > 0)
123 cout << " " << interface_property_string << " (initial value: "
124 << value << ")" << endl << endl;
125 }
126 else {
127 cerr << "Could not create property " << interface_property_string
128 << endl;
129 property_element = el->FindNextElement("property");
130 continue;
131 }
132 }
133 interface_prop_initial_value[node] = value;
134 if (property_element->GetAttributeValue("persistent") == string("true"))
135 node->setAttribute(SGPropertyNode::PRESERVE, true);
136
137 property_element = el->FindNextElement("property");
138 }
139
140 // End of interface property loading logic
141}

◆ ResetToIC()

bool ResetToIC ( void  )

Definition at line 54 of file FGPropertyReader.cpp.

55{
56 for (auto v: interface_prop_initial_value) {
57 SGPropertyNode* node = v.first;
58 if (!node->getAttribute(SGPropertyNode::PRESERVE))
59 node->setDoubleValue(v.second);
60 }
61
62 return true;
63}

The documentation for this class was generated from the following files: