FlightGear next
JSBSim::FGPropertyNode Class Reference

Class wrapper for property handling. More...

#include <FGPropertyManager.h>

Inherits SGPropertyNode.

Public Member Functions

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

Detailed Description

Class wrapper for property handling.

Author
David Megginson, Tony Peden

Definition at line 51 of file FGPropertyManager.h.

Constructor & Destructor Documentation

◆ ~FGPropertyNode()

virtual JSBSim::FGPropertyNode::~FGPropertyNode ( void )
inlinevirtual

Destructor.

Definition at line 55 of file FGPropertyManager.h.

Member Function Documentation

◆ GetBool()

bool JSBSim::FGPropertyNode::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 175 of file FGPropertyManager.cpp.

◆ GetDouble()

double JSBSim::FGPropertyNode::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 203 of file FGPropertyManager.cpp.

◆ GetFloat()

float JSBSim::FGPropertyNode::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 196 of file FGPropertyManager.cpp.

◆ GetFullyQualifiedName()

string JSBSim::FGPropertyNode::GetFullyQualifiedName ( void ) const

Get the fully qualified name of a node This function is very slow, so is probably useful for debugging only.

Definition at line 135 of file FGPropertyManager.cpp.

◆ GetInt()

int JSBSim::FGPropertyNode::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 182 of file FGPropertyManager.cpp.

◆ GetLong()

int JSBSim::FGPropertyNode::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 189 of file FGPropertyManager.cpp.

◆ GetName()

const std::string & JSBSim::FGPropertyNode::GetName ( void ) const
inline

Get the name of a node.

Definition at line 81 of file FGPropertyManager.h.

◆ GetNode() [1/2]

FGPropertyNode * JSBSim::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.

◆ GetNode() [2/2]

FGPropertyNode * JSBSim::FGPropertyNode::GetNode ( const std::string & relpath,
int index,
bool create = false )

◆ GetPrintableName()

string JSBSim::FGPropertyNode::GetPrintableName ( void ) const

Get the name of a node without underscores, etc.

Definition at line 114 of file FGPropertyManager.cpp.

◆ GetRelativeName()

string JSBSim::FGPropertyNode::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 161 of file FGPropertyManager.cpp.

◆ GetString()

string JSBSim::FGPropertyNode::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 210 of file FGPropertyManager.cpp.

◆ HasNode()

bool JSBSim::FGPropertyNode::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 106 of file FGPropertyManager.cpp.

◆ SetArchivable()

void JSBSim::FGPropertyNode::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 259 of file FGPropertyManager.cpp.

◆ SetBool()

bool JSBSim::FGPropertyNode::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 217 of file FGPropertyManager.cpp.

◆ SetDouble()

bool JSBSim::FGPropertyNode::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 245 of file FGPropertyManager.cpp.

◆ SetFloat()

bool JSBSim::FGPropertyNode::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 238 of file FGPropertyManager.cpp.

◆ SetInt()

bool JSBSim::FGPropertyNode::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 224 of file FGPropertyManager.cpp.

◆ SetLong()

bool JSBSim::FGPropertyNode::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 231 of file FGPropertyManager.cpp.

◆ SetReadable()

void JSBSim::FGPropertyNode::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 272 of file FGPropertyManager.cpp.

◆ SetString()

bool JSBSim::FGPropertyNode::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 252 of file FGPropertyManager.cpp.

◆ SetWritable()

void JSBSim::FGPropertyNode::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 285 of file FGPropertyManager.cpp.


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