JSBSim Flight Dynamics Model  1.0 (02 March 2017)
An Open Source Flight Dynamics and Control Software Library in C++
FGPropertyNode Class Reference

Class wrapper for property handling. More...

#include <FGPropertyManager.h>

+ Inheritance diagram for FGPropertyNode:
+ Collaboration diagram for FGPropertyNode:

Public Member Functions

virtual ~FGPropertyNode (void)
 Destructor.
 
bool GetBool (const std::string &name, bool defaultValue=false) const
 Get a bool value for a property. More...
 
double GetDouble (const std::string &name, double defaultValue=0.0) const
 Get a double value for a property. More...
 
float GetFloat (const std::string &name, float defaultValue=0.0) const
 Get a float value for a property. More...
 
std::string GetFullyQualifiedName (void) const
 Get the fully qualified name of a node This function is very slow, so is probably useful for debugging only.
 
int GetInt (const std::string &name, int defaultValue=0) const
 Get an int value for a property. More...
 
int GetLong (const std::string &name, long defaultValue=0L) const
 Get a long value for a property. More...
 
std::string GetName (void) const
 Get the name of a node.
 
FGPropertyNodeGetNode (const std::string &path, bool create=false)
 Get a property node. More...
 
FGPropertyNodeGetNode (const std::string &relpath, int index, bool create=false)
 
std::string GetPrintableName (void) const
 Get the name of a node without underscores, etc.
 
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. More...
 
std::string GetString (const std::string &name, std::string defaultValue="") const
 Get a string value for a property. More...
 
bool HasNode (const std::string &path)
 Test whether a given node exists. More...
 
void SetArchivable (const std::string &name, bool state=true)
 Set the state of the archive attribute for a property. More...
 
bool SetBool (const std::string &name, bool val)
 Set a bool value for a property. More...
 
bool SetDouble (const std::string &name, double val)
 Set a double value for a property. More...
 
bool SetFloat (const std::string &name, float val)
 Set a float value for a property. More...
 
bool SetInt (const std::string &name, int val)
 Set an int value for a property. More...
 
bool SetLong (const std::string &name, long val)
 Set a long value for a property. More...
 
void SetReadable (const std::string &name, bool state=true)
 Set the state of the read attribute for a property. More...
 
bool SetString (const std::string &name, const std::string &val)
 Set a string value for a property. More...
 
void SetWritable (const std::string &name, bool state=true)
 Set the state of the write attribute for a property. More...
 

Detailed Description

Class wrapper for property handling.

Author
David Megginson, Tony Peden

Definition at line 76 of file FGPropertyManager.h.

Member Function Documentation

◆ GetBool()

bool GetBool ( const std::string &  name,
bool  defaultValue = false 
) const

Get a bool value for a property.

This method is convenient but inefficient. It should be used infrequently (i.e. for initializing, loading, saving, etc.), not in the main loop. If you need to get a value frequently, it is better to look up the node itself using GetNode and then use the node's getBoolValue() method, to avoid the lookup overhead.

Parameters
nameThe property name.
defaultValueThe default value to return if the property does not exist.
Returns
The property's value as a bool, or the default value provided.

Definition at line 183 of file FGPropertyManager.cpp.

184 {
185  return getBoolValue(name.c_str(), defaultValue);
186 }
+ Here is the caller graph for this function:

◆ GetDouble()

double GetDouble ( const std::string &  name,
double  defaultValue = 0.0 
) const

Get a double value for a property.

This method is convenient but inefficient. It should be used infrequently (i.e. for initializing, loading, saving, etc.), not in the main loop. If you need to get a value frequently, it is better to look up the node itself using GetNode and then use the node's getDoubleValue() method, to avoid the lookup overhead.

Parameters
nameThe property name.
defaultValueThe default value to return if the property does not exist.
Returns
The property's value as a double, or the default value provided.

Definition at line 211 of file FGPropertyManager.cpp.

212 {
213  return getDoubleValue(name.c_str(), defaultValue);
214 }
+ Here is the caller graph for this function:

◆ GetFloat()

float GetFloat ( const std::string &  name,
float  defaultValue = 0.0 
) const

Get a float value for a property.

This method is convenient but inefficient. It should be used infrequently (i.e. for initializing, loading, saving, etc.), not in the main loop. If you need to get a value frequently, it is better to look up the node itself using GetNode and then use the node's getFloatValue() method, to avoid the lookup overhead.

Parameters
nameThe property name.
defaultValueThe default value to return if the property does not exist.
Returns
The property's value as a float, or the default value provided.

Definition at line 204 of file FGPropertyManager.cpp.

205 {
206  return getFloatValue(name.c_str(), defaultValue);
207 }
+ Here is the caller graph for this function:

◆ GetInt()

int GetInt ( const std::string &  name,
int  defaultValue = 0 
) const

Get an int value for a property.

This method is convenient but inefficient. It should be used infrequently (i.e. for initializing, loading, saving, etc.), not in the main loop. If you need to get a value frequently, it is better to look up the node itself using GetNode and then use the node's getIntValue() method, to avoid the lookup overhead.

Parameters
nameThe property name.
defaultValueThe default value to return if the property does not exist.
Returns
The property's value as an int, or the default value provided.

Definition at line 190 of file FGPropertyManager.cpp.

191 {
192  return getIntValue(name.c_str(), defaultValue);
193 }
+ Here is the caller graph for this function:

◆ GetLong()

int GetLong ( const std::string &  name,
long  defaultValue = 0L 
) const

Get a long value for a property.

This method is convenient but inefficient. It should be used infrequently (i.e. for initializing, loading, saving, etc.), not in the main loop. If you need to get a value frequently, it is better to look up the node itself using GetNode and then use the node's getLongValue() method, to avoid the lookup overhead.

Parameters
nameThe property name.
defaultValueThe default value to return if the property does not exist.
Returns
The property's value as a long, or the default value provided.

Definition at line 197 of file FGPropertyManager.cpp.

198 {
199  return getLongValue(name.c_str(), defaultValue);
200 }
+ Here is the caller graph for this function:

◆ GetNode()

FGPropertyNode * GetNode ( const std::string &  path,
bool  create = false 
)

Get a property node.

Parameters
pathThe path of the node, relative to root.
createtrue to create the node if it doesn't exist.
Returns
The node, or 0 if none exists and none was created.

Definition at line 83 of file FGPropertyManager.cpp.

84 {
85  SGPropertyNode* node = getNode(path.c_str(), create);
86  if (node == 0) {
87  cerr << "FGPropertyManager::GetNode() No node found for " << path << endl;
88  }
89  return (FGPropertyNode*)node;
90 }
+ Here is the caller graph for this function:

◆ GetRelativeName()

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.

This function is very slow, so is probably useful for debugging only.

Parameters
pathThe path to strip off, if found.

Definition at line 169 of file FGPropertyManager.cpp.

170 {
171  string temp_string = GetFullyQualifiedName();
172  size_t len = path.length();
173  if ( (len > 0) && (temp_string.substr(0,len) == path) ) {
174  temp_string = temp_string.erase(0,len);
175  }
176  return temp_string;
177 }
std::string GetFullyQualifiedName(void) const
Get the fully qualified name of a node This function is very slow, so is probably useful for debuggin...
+ Here is the caller graph for this function:

◆ GetString()

string GetString ( const std::string &  name,
std::string  defaultValue = "" 
) const

Get a string value for a property.

This method is convenient but inefficient. It should be used infrequently (i.e. for initializing, loading, saving, etc.), not in the main loop. If you need to get a value frequently, it is better to look up the node itself using GetNode and then use the node's getStringValue() method, to avoid the lookup overhead.

Parameters
nameThe property name.
defaultValueThe default value to return if the property does not exist.
Returns
The property's value as a string, or the default value provided.

Definition at line 218 of file FGPropertyManager.cpp.

219 {
220  return string(getStringValue(name.c_str(), defaultValue.c_str()));
221 }
+ Here is the caller graph for this function:

◆ HasNode()

bool HasNode ( const std::string &  path)

Test whether a given node exists.

Parameters
pathThe path of the node, relative to root.
Returns
true if the node exists, false otherwise.

Definition at line 107 of file FGPropertyManager.cpp.

108 {
109  const SGPropertyNode* node = getNode(path.c_str(), false);
110  return (node != 0);
111 }
+ Here is the caller graph for this function:

◆ SetArchivable()

void SetArchivable ( const std::string &  name,
bool  state = true 
)

Set the state of the archive attribute for a property.

If the archive attribute is true, the property will be written when a flight is saved; if it is false, the property will be skipped.

A warning message will be printed if the property does not exist.

Parameters
nameThe property name.
stateThe state of the archive attribute (defaults to true).

Definition at line 267 of file FGPropertyManager.cpp.

268 {
269  SGPropertyNode * node = getNode(name.c_str());
270  if (node == 0)
271  cerr <<
272  "Attempt to set archive flag for non-existent property "
273  << name << endl;
274  else
275  node->setAttribute(SGPropertyNode::ARCHIVE, state);
276 }
+ Here is the caller graph for this function:

◆ SetBool()

bool SetBool ( const std::string &  name,
bool  val 
)

Set a bool value for a property.

Assign a bool value to a property. If the property does not yet exist, it will be created and its type will be set to BOOL; if it has a type of UNKNOWN, the type will also be set to BOOL; otherwise, the value type will be converted to the property's type.

Parameters
nameThe property name.
valThe new value for the property.
Returns
true if the assignment succeeded, false otherwise.

Definition at line 225 of file FGPropertyManager.cpp.

226 {
227  return setBoolValue(name.c_str(), val);
228 }
+ Here is the caller graph for this function:

◆ SetDouble()

bool SetDouble ( const std::string &  name,
double  val 
)

Set a double value for a property.

Assign a double value to a property. If the property does not yet exist, it will be created and its type will be set to DOUBLE; if it has a type of UNKNOWN, the type will also be set to DOUBLE; otherwise, the double value will be converted to the property's type.

Parameters
nameThe property name.
valThe new value for the property.
Returns
true if the assignment succeeded, false otherwise.

Definition at line 253 of file FGPropertyManager.cpp.

254 {
255  return setDoubleValue(name.c_str(), val);
256 }
+ Here is the caller graph for this function:

◆ SetFloat()

bool SetFloat ( const std::string &  name,
float  val 
)

Set a float value for a property.

Assign a float value to a property. If the property does not yet exist, it will be created and its type will be set to FLOAT; if it has a type of UNKNOWN, the type will also be set to FLOAT; otherwise, the value type will be converted to the property's type.

Parameters
nameThe property name.
valThe new value for the property.
Returns
true if the assignment succeeded, false otherwise.

Definition at line 246 of file FGPropertyManager.cpp.

247 {
248  return setFloatValue(name.c_str(), val);
249 }
+ Here is the caller graph for this function:

◆ SetInt()

bool SetInt ( const std::string &  name,
int  val 
)

Set an int value for a property.

Assign an int value to a property. If the property does not yet exist, it will be created and its type will be set to INT; if it has a type of UNKNOWN, the type will also be set to INT; otherwise, the value type will be converted to the property's type.

Parameters
nameThe property name.
valThe new value for the property.
Returns
true if the assignment succeeded, false otherwise.

Definition at line 232 of file FGPropertyManager.cpp.

233 {
234  return setIntValue(name.c_str(), val);
235 }
+ Here is the caller graph for this function:

◆ SetLong()

bool SetLong ( const std::string &  name,
long  val 
)

Set a long value for a property.

Assign a long value to a property. If the property does not yet exist, it will be created and its type will be set to LONG; if it has a type of UNKNOWN, the type will also be set to LONG; otherwise, the value type will be converted to the property's type.

Parameters
nameThe property name.
valThe new value for the property.
Returns
true if the assignment succeeded, false otherwise.

Definition at line 239 of file FGPropertyManager.cpp.

240 {
241  return setLongValue(name.c_str(), val);
242 }
+ Here is the caller graph for this function:

◆ SetReadable()

void SetReadable ( const std::string &  name,
bool  state = true 
)

Set the state of the read attribute for a property.

If the read attribute is true, the property value will be readable; if it is false, the property value will always be the default value for its type.

A warning message will be printed if the property does not exist.

Parameters
nameThe property name.
stateThe state of the read attribute (defaults to true).

Definition at line 280 of file FGPropertyManager.cpp.

281 {
282  SGPropertyNode * node = getNode(name.c_str());
283  if (node == 0)
284  cerr <<
285  "Attempt to set read flag for non-existant property "
286  << name << endl;
287  else
288  node->setAttribute(SGPropertyNode::READ, state);
289 }
+ Here is the caller graph for this function:

◆ SetString()

bool SetString ( const std::string &  name,
const std::string &  val 
)

Set a string value for a property.

Assign a string value to a property. If the property does not yet exist, it will be created and its type will be set to STRING; if it has a type of UNKNOWN, the type will also be set to STRING; otherwise, the string value will be converted to the property's type.

Parameters
nameThe property name.
valThe new value for the property.
Returns
true if the assignment succeeded, false otherwise.

Definition at line 260 of file FGPropertyManager.cpp.

261 {
262  return setStringValue(name.c_str(), val.c_str());
263 }
+ Here is the caller graph for this function:

◆ SetWritable()

void SetWritable ( const std::string &  name,
bool  state = true 
)

Set the state of the write attribute for a property.

If the write attribute is true, the property value may be modified (depending on how it is tied); if the write attribute is false, the property value may not be modified.

A warning message will be printed if the property does not exist.

Parameters
nameThe property name.
stateThe state of the write attribute (defaults to true).

Definition at line 293 of file FGPropertyManager.cpp.

294 {
295  SGPropertyNode * node = getNode(name.c_str());
296  if (node == 0)
297  cerr <<
298  "Attempt to set write flag for non-existant property "
299  << name << endl;
300  else
301  node->setAttribute(SGPropertyNode::WRITE, state);
302 }
+ Here is the caller graph for this function:

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