32#include "FGPropertyManager.h"
56 for(
auto& property: tied_properties)
59 tied_properties.clear();
66 auto it = tied_properties.begin();
68 while(it != tied_properties.end()) {
70 if (property->BindingInstance == instance) {
72 tied_properties.erase(property);
84 for(i=0;i<name.length();i++) {
85 if( lowercase && isupper(name[i]) )
86 name[i]=tolower(name[i]);
87 else if( isspace(name[i]) )
99 SGPropertyNode* node = getNode(path.c_str(), create);
101 cerr <<
"FGPropertyManager::GetNode() No node found for " << path << endl;
111 SGPropertyNode* node = getNode(relpath.c_str(), index, create);
113 cerr <<
"FGPropertyManager::GetNode() No node found for " << relpath
114 <<
"[" << index <<
"]" << endl;
116 return (FGPropertyNode*)node;
123 const SGPropertyNode* node = getNode(path.c_str(),
false);
131 string temp_string(getNameString());
132 size_t initial_location=0;
133 size_t found_location;
135 found_location = temp_string.rfind(
"/");
136 if (found_location != string::npos)
137 temp_string = temp_string.substr(found_location);
139 found_location = temp_string.find(
'_',initial_location);
140 while (found_location != string::npos) {
141 temp_string.replace(found_location,1,
" ");
142 initial_location = found_location+1;
143 found_location = temp_string.find(
'_',initial_location);
153 const SGPropertyNode* node =
this;
155 fqname = node->getDisplayName(
true) +
"/" + fqname;
156 node = node->getParent();
160 size_t len = std::max<size_t>(1, fqname.size()-1);
161 return fqname.substr(0, len);
169 size_t len = path.length();
170 if ( (len > 0) && (temp_string.substr(0,len) == path) ) {
171 temp_string = temp_string.erase(0,len);
182 return getBoolValue(name.c_str(), defaultValue);
189 return getIntValue(name.c_str(), defaultValue);
196 return getLongValue(name.c_str(), defaultValue);
203 return getFloatValue(name.c_str(), defaultValue);
210 return getDoubleValue(name.c_str(), defaultValue);
217 return string(getStringValue(name.c_str(), defaultValue.c_str()));
224 return setBoolValue(name.c_str(), val);
231 return setIntValue(name.c_str(), val);
238 return setLongValue(name.c_str(), val);
245 return setFloatValue(name.c_str(), val);
252 return setDoubleValue(name.c_str(), val);
259 return setStringValue(name.c_str(), val.c_str());
266 SGPropertyNode * node = getNode(name.c_str());
269 "Attempt to set archive flag for non-existent property "
272 node->setAttribute(SGPropertyNode::ARCHIVE, state);
279 SGPropertyNode * node = getNode(name.c_str());
282 "Attempt to set read flag for non-existant property "
285 node->setAttribute(SGPropertyNode::READ, state);
292 SGPropertyNode * node = getNode(name.c_str());
295 "Attempt to set write flag for non-existant property "
298 node->setAttribute(SGPropertyNode::WRITE, state);
305 SGPropertyNode*
property = root->getNode(name.c_str());
307 cerr <<
"Attempt to untie a non-existant property." << name << endl;
318 const string& name =
property->getNameString();
320 assert(property->isTied());
322 for (
auto it = tied_properties.begin(); it != tied_properties.end(); ++it) {
323 if (it->node.ptr() == property) {
325 tied_properties.erase(it);
326 if (FGJSBBase::debug_lvl & 0x20) cout <<
"Untied " << name << endl;
331 cerr <<
"Failed to untie property " << name << endl
332 <<
"JSBSim is not the owner of this property." << endl;
void Untie(const std::string &name)
Untie a property from an external data source.
std::string mkPropertyName(std::string name, bool lowercase)
Property-ify a name replaces spaces with '-' and, optionally, makes name all lower case.
void Unbind(void)
Unbind all properties bound by this manager to an external data source.
Class wrapper for property handling.
FGPropertyNode * GetNode(const std::string &path, bool create=false)
Get a property node.
bool SetFloat(const std::string &name, float val)
Set a float value for a property.
bool HasNode(const std::string &path)
Test whether a given node exists.
bool SetInt(const std::string &name, int val)
Set an int value for a property.
std::string GetPrintableName(void) const
Get the name of a node without underscores, etc.
void SetWritable(const std::string &name, bool state=true)
Set the state of the write attribute for a property.
bool SetLong(const std::string &name, long val)
Set a long value for a property.
float GetFloat(const std::string &name, float defaultValue=0.0) const
Get a float value for a property.
bool SetBool(const std::string &name, bool val)
Set a bool value for a property.
std::string GetRelativeName(const std::string &path="/fdm/jsbsim/") const
Get the qualified name of a node relative to given base path, otherwise the fully qualified name.
std::string GetFullyQualifiedName(void) const
Get the fully qualified name of a node This function is very slow, so is probably useful for debuggin...
bool GetBool(const std::string &name, bool defaultValue=false) const
Get a bool value for a property.
bool SetDouble(const std::string &name, double val)
Set a double value for a property.
bool SetString(const std::string &name, const std::string &val)
Set a string value for a property.
double GetDouble(const std::string &name, double defaultValue=0.0) const
Get a double value for a property.
int GetLong(const std::string &name, long defaultValue=0L) const
Get a long value for a property.
void SetReadable(const std::string &name, bool state=true)
Set the state of the read attribute for a property.
std::string GetString(const std::string &name, std::string defaultValue="") const
Get a string value for a property.
void SetArchivable(const std::string &name, bool state=true)
Set the state of the archive attribute for a property.
int GetInt(const std::string &name, int defaultValue=0) const
Get an int value for a property.