JSBSim Flight Dynamics Model 1.2.3 (07 Jun 2025)
An Open Source Flight Dynamics and Control Software Library in C++
Loading...
Searching...
No Matches
SGPropertyNode Class Reference

Detailed Description

A node in a property tree.

Definition at line 753 of file props.hxx.

#include <props.hxx>

+ Inheritance diagram for SGPropertyNode:
+ Collaboration diagram for SGPropertyNode:

Public Types

enum  { MAX_STRING_LEN = 1024 }
 Public constants. More...
 
enum  Attribute {
  NO_ATTR = 0 , READ = 1 , WRITE = 2 , ARCHIVE = 4 ,
  REMOVED = 8 , TRACE_READ = 16 , TRACE_WRITE = 32 , USERARCHIVE = 64 ,
  PRESERVE = 128
}
 Access mode attributes. More...
 

Public Member Functions

 SGPropertyNode ()
 Default constructor.
 
 SGPropertyNode (const SGPropertyNode &node)
 Copy constructor.
 
virtual ~SGPropertyNode ()
 Destructor.
 
void addChangeListener (SGPropertyChangeListener *listener, bool initial=false)
 Add a change listener to the property.
 
SGPropertyNodeaddChild (const char *name, int min_index=0, bool append=true)
 Create a new child node with the given name and an unused index.
 
SGPropertyNodeaddChild (const std::string &name, int min_index=0, bool append=true)
 
simgear::PropertyList addChildren (const std::string &name, size_t count, int min_index=0, bool append=true)
 Create multiple child nodes with the given name an unused indices.
 
bool alias (const char *path)
 Alias this node's leaf value to another's by relative path.
 
bool alias (const std::string &path)
 Alias this node's leaf value to another's by relative path.
 
bool alias (SGPropertyNode *target)
 Alias this node's leaf value to another's.
 
void clearValue ()
 Clear any existing value and set the type to NONE.
 
void fireChildAdded (SGPropertyNode *child)
 Fire a child-added event to all listeners.
 
void fireChildRemoved (SGPropertyNode *child)
 Fire a child-removed event to all listeners.
 
void fireChildrenRemovedRecursive ()
 Fire a child-removed event for every child of this node (Unlimited depth)
 
void fireCreatedRecursive (bool fire_self=false)
 Trigger a child-added and value-changed event for every child (Unlimited depth).
 
void fireValueChanged ()
 Fire a value change event to all listeners.
 
SGPropertyNodegetAliasTarget ()
 Get a non-const pointer to the current alias target, if any.
 
const SGPropertyNodegetAliasTarget () const
 Get a const pointer to the current alias target, if any.
 
bool getAttribute (Attribute attr) const
 Check a single mode attribute for the property node.
 
int getAttributes () const
 Get all of the mode attributes for the property node.
 
bool getBoolValue () const
 Get a bool value for this node.
 
bool getBoolValue (const char *relative_path, bool defaultValue=false) const
 Get another node's value as a bool.
 
bool getBoolValue (const std::string &relative_path, bool defaultValue=false) const
 Get another node's value as a bool.
 
const SGPropertyNodegetChild (const char *name, int index=0) const
 Get a const child node by name and index.
 
SGPropertyNodegetChild (const char *name, int index=0, bool create=false)
 Get a child node by name and index.
 
const SGPropertyNodegetChild (const std::string &name, int index=0) const
 Get a const child node by name and index.
 
SGPropertyNodegetChild (const std::string &name, int index=0, bool create=false)
 
SGPropertyNodegetChild (int position)
 Get a child node by position (NOT index).
 
const SGPropertyNodegetChild (int position) const
 Get a const child node by position (NOT index).
 
simgear::PropertyList getChildren (const char *name) const
 Get a vector of all children with the specified name.
 
simgear::PropertyList getChildren (const std::string &name) const
 Get a vector of all children with the specified name.
 
template<typename T , typename T_get >
std::vector< T > getChildValues (const std::string &name) const
 Get a list of values from all children with the given name.
 
template<typename T >
std::vector< T > getChildValues (const std::string &name) const
 Get a list of values from all children with the given name.
 
std::string getDisplayName (bool simplify=false) const
 Get the node's pretty display name, with subscript when needed.
 
double getDoubleValue () const
 Get a double value for this node.
 
double getDoubleValue (const char *relative_path, double defaultValue=0.0) const
 Get another node's value as a double.
 
double getDoubleValue (const std::string &relative_path, double defaultValue=0.0) const
 Get another node's value as a double.
 
float getFloatValue () const
 Get a float value for this node.
 
float getFloatValue (const char *relative_path, float defaultValue=0.0f) const
 Get another node's value as a float.
 
float getFloatValue (const std::string &relative_path, float defaultValue=0.0f) const
 Get another node's value as a float.
 
int getIndex () const
 Get the node's integer index.
 
int getIntValue () const
 Get an int value for this node.
 
int getIntValue (const char *relative_path, int defaultValue=0) const
 Get another node's value as an int.
 
int getIntValue (const std::string &relative_path, int defaultValue=0) const
 Get another node's value as an int.
 
long getLongValue () const
 Get a long int value for this node.
 
long getLongValue (const char *relative_path, long defaultValue=0L) const
 Get another node's value as a long int.
 
long getLongValue (const std::string &relative_path, long defaultValue=0L) const
 Get another node's value as a long int.
 
const std::string & getNameString () const
 Get the node's simple name as a string.
 
const SGPropertyNodegetNode (const char *relative_path) const
 Get a const pointer to another node by relative path.
 
SGPropertyNodegetNode (const char *relative_path, bool create=false)
 Get a pointer to another node by relative path.
 
const SGPropertyNodegetNode (const char *relative_path, int index) const
 Get a const pointer to another node by relative path.
 
SGPropertyNodegetNode (const char *relative_path, int index, bool create=false)
 Get a pointer to another node by relative path.
 
const SGPropertyNodegetNode (const std::string &relative_path) const
 Get a const pointer to another node by relative path.
 
SGPropertyNodegetNode (const std::string &relative_path, bool create=false)
 Get a pointer to another node by relative path.
 
const SGPropertyNodegetNode (const std::string &relative_path, int index) const
 Get a const pointer to another node by relative path.
 
SGPropertyNodegetNode (const std::string &relative_path, int index, bool create=false)
 Get a pointer to another node by relative path.
 
SGPropertyNodegetParent ()
 Get a non-const pointer to the node's parent.
 
const SGPropertyNodegetParent () const
 Get a const pointer to the node's parent.
 
std::string getPath (bool simplify=false) const
 Get the path to this node from the root.
 
SGPropertyNodegetRootNode ()
 Get a pointer to the root node.
 
const SGPropertyNodegetRootNode () const
 Get a const pointer to the root node.
 
const char * getStringValue () const
 Get a string value for this node.
 
const char * getStringValue (const char *relative_path, const char *defaultValue="") const
 Get another node's value as a string.
 
const char * getStringValue (const std::string &relative_path, const char *defaultValue="") const
 Get another node's value as a string.
 
simgear::props::Type getType () const
 Get the type of leaf value, if any, for this node.
 
simgear::props::Type getType (const char *relative_path) const
 Get another node's type.
 
simgear::props::Type getType (const std::string &relative_path) const
 Get another node's type.
 
template<typename T >
getValue (typename boost::disable_if_c< simgear::props ::PropertyTraits< T >::Internal >::type *dummy) const
 
template<typename T >
getValue (typename boost::disable_if_c< simgear::props::PropertyTraits< T >::Internal > ::type *dummy=0) const
 
template<typename T >
getValue (typename boost::enable_if_c< simgear::props ::PropertyTraits< T >::Internal >::type *dummy) const
 
template<typename T >
getValue (typename boost::enable_if_c< simgear::props::PropertyTraits< T >::Internal > ::type *dummy=0) const
 Get a value from a node.
 
bool hasChild (const char *name, int index=0) const
 Test whether a named child exists.
 
bool hasChild (const std::string &name, int index=0) const
 Test whether a named child exists.
 
bool hasValue () const
 Test whether this node contains a primitive leaf value.
 
bool hasValue (const char *relative_path) const
 Test whether another node has a leaf value.
 
bool hasValue (const std::string &relative_path) const
 Test whether another node has a leaf value.
 
bool isAlias () const
 Test whether the node's leaf value is aliased to another's.
 
bool isTied () const
 Test whether this node is bound to an external data source.
 
bool isTied (const char *relative_path) const
 Test whether another node is bound to an external data source.
 
bool isTied (const std::string &relative_path) const
 Test whether another node is bound to an external data source.
 
int nChildren () const
 Get the number of child nodes.
 
int nListeners () const
 Get the number of listeners.
 
std::ostream & printOn (std::ostream &stream) const
 Print the value of the property to a stream.
 
void removeAllChildren ()
 Remove all children (does not change the value of the node)
 
void removeChangeListener (SGPropertyChangeListener *listener)
 Remove a change listener from the property.
 
SGPropertyNode_ptr removeChild (const char *name, int index=0)
 Remove a child node.
 
SGPropertyNode_ptr removeChild (const std::string &name, int index=0)
 Remove a child node.
 
SGPropertyNode_ptr removeChild (int pos)
 Remove child by position.
 
bool removeChild (SGPropertyNode *node)
 Remove child by pointer (if it is a child of this node).
 
simgear::PropertyList removeChildren (const char *name)
 Remove all children with the specified name.
 
simgear::PropertyList removeChildren (const std::string &name)
 Remove all children with the specified name.
 
void setAttribute (Attribute attr, bool state)
 Set a single mode attribute for the property node.
 
void setAttributes (int attr)
 Set all of the mode attributes for the property node.
 
bool setBoolValue (bool value)
 Set a bool value for this node.
 
bool setBoolValue (const char *relative_path, bool value)
 Set another node's value as a bool.
 
bool setBoolValue (const std::string &relative_path, bool value)
 Set another node's value as a bool.
 
bool setDoubleValue (const char *relative_path, double value)
 Set another node's value as a double.
 
bool setDoubleValue (const std::string &relative_path, double value)
 Set another node's value as a double.
 
bool setDoubleValue (double value)
 Set a double value for this node.
 
bool setFloatValue (const char *relative_path, float value)
 Set another node's value as a float.
 
bool setFloatValue (const std::string &relative_path, float value)
 Set another node's value as a float.
 
bool setFloatValue (float value)
 Set a float value for this node.
 
bool setIntValue (const char *relative_path, int value)
 Set another node's value as an int.
 
bool setIntValue (const std::string &relative_path, int value)
 Set another node's value as an int.
 
bool setIntValue (int value)
 Set an int value for this node.
 
bool setLongValue (const char *relative_path, long value)
 Set another node's value as a long int.
 
bool setLongValue (const std::string &relative_path, long value)
 Set another node's value as a long int.
 
bool setLongValue (long value)
 Set a long int value for this node.
 
bool setStringValue (const char *relative_path, const char *value)
 Set another node's value as a string.
 
bool setStringValue (const char *relative_path, const std::string &value)
 
bool setStringValue (const char *value)
 Set a string value for this node.
 
bool setStringValue (const std::string &relative_path, const char *value)
 Set another node's value as a string.
 
bool setStringValue (const std::string &relative_path, const std::string &value)
 
bool setStringValue (const std::string &value)
 Set a string value for this node.
 
bool setUnspecifiedValue (const char *relative_path, const char *value)
 Set another node's value with no specified type.
 
bool setUnspecifiedValue (const char *value)
 Set a value of unspecified type for this node.
 
template<int N>
bool setValue (const char(&val)[N])
 
template<typename T >
bool setValue (const T &val, typename boost::disable_if_c< simgear::props ::PropertyTraits< T >::Internal >::type *dummy)
 
template<typename T >
bool setValue (const T &val, typename boost::disable_if_c< simgear::props::PropertyTraits< T >::Internal > ::type *dummy=0)
 
template<typename T >
bool setValue (const T &val, typename boost::enable_if_c< simgear::props ::PropertyTraits< T >::Internal >::type *dummy)
 
template<typename T >
bool setValue (const T &val, typename boost::enable_if_c< simgear::props::PropertyTraits< T >::Internal > ::type *dummy=0)
 
template<typename T >
bool setValueReadOnly (const std::string &relative_path, const T &value)
 Set relative node to given value and afterwards make read only.
 
bool tie (const char *relative_path, const SGRawValue< bool > &rawValue, bool useDefault=true)
 Bind another node to an external bool source.
 
bool tie (const char *relative_path, const SGRawValue< const char * > &rawValue, bool useDefault=true)
 Bind another node to an external string source.
 
bool tie (const char *relative_path, const SGRawValue< double > &rawValue, bool useDefault=true)
 Bind another node to an external double source.
 
bool tie (const char *relative_path, const SGRawValue< float > &rawValue, bool useDefault=true)
 Bind another node to an external float source.
 
bool tie (const char *relative_path, const SGRawValue< int > &rawValue, bool useDefault=true)
 Bind another node to an external int source.
 
bool tie (const char *relative_path, const SGRawValue< long > &rawValue, bool useDefault=true)
 Bind another node to an external long int source.
 
template<>
bool tie (const SGRawValue< const char * > &rawValue, bool useDefault)
 
template<typename T >
bool tie (const SGRawValue< T > &rawValue, bool useDefault=true)
 Bind this node to an external source.
 
bool tie (const std::string &relative_path, const SGRawValue< bool > &rawValue, bool useDefault=true)
 Bind another node to an external bool source.
 
bool tie (const std::string &relative_path, const SGRawValue< const char * > &rawValue, bool useDefault=true)
 Bind another node to an external string source.
 
bool tie (const std::string &relative_path, const SGRawValue< double > &rawValue, bool useDefault=true)
 Bind another node to an external double source.
 
bool tie (const std::string &relative_path, const SGRawValue< float > &rawValue, bool useDefault=true)
 Bind another node to an external float source.
 
bool tie (const std::string &relative_path, const SGRawValue< int > &rawValue, bool useDefault=true)
 Bind another node to an external int source.
 
bool tie (const std::string &relative_path, const SGRawValue< long > &rawValue, bool useDefault=true)
 Bind another node to an external long int source.
 
bool unalias ()
 Remove any alias for this node.
 
bool untie ()
 Unbind this node from any external data source.
 
bool untie (const char *relative_path)
 Unbind another node from any external data source.
 
bool untie (const std::string &relative_path)
 Unbind another node from any external data source.
 

Static Public Member Functions

static bool compare (const SGPropertyNode &lhs, const SGPropertyNode &rhs)
 Compare two property trees.
 

Static Public Attributes

static const int LAST_USED_ATTRIBUTE
 Last used attribute Update as needed when enum Attribute is changed.
 

Protected Member Functions

 SGPropertyNode (const std::string &name, int index, SGPropertyNode *parent)
 Protected constructor for making new nodes on demand.
 
template<typename Itr >
 SGPropertyNode (Itr begin, Itr end, int index, SGPropertyNode *parent)
 
SGPropertyNode_ptr eraseChild (simgear::PropertyList::iterator child)
 
void fireChildAdded (SGPropertyNode *parent, SGPropertyNode *child)
 
void fireChildRemoved (SGPropertyNode *parent, SGPropertyNode *child)
 
void fireValueChanged (SGPropertyNode *node)
 

Static Protected Attributes

static simgear::PropertyInterpolationMgr * _interpolation_mgr
 

Friends

template<typename SplitItr >
SGPropertyNodefind_node_aux (SGPropertyNode *current, SplitItr &itr, bool create, int last_index)
 
size_t hash_value (const SGPropertyNode &node)
 

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Public constants.

Definition at line 760 of file props.hxx.

760 {
761 MAX_STRING_LEN = 1024
762 };

◆ Attribute

enum Attribute

Access mode attributes.

The ARCHIVE attribute is strictly advisory, and controls whether the property should normally be saved and restored.

Definition at line 770 of file props.hxx.

770 {
771 NO_ATTR = 0,
772 READ = 1,
773 WRITE = 2,
774 ARCHIVE = 4,
775 REMOVED = 8,
776 TRACE_READ = 16,
777 TRACE_WRITE = 32,
778 USERARCHIVE = 64,
779 PRESERVE = 128
780 // beware: if you add another attribute here,
781 // also update value of "LAST_USED_ATTRIBUTE".
782 };

Member Function Documentation

◆ addChangeListener()

void addChangeListener ( SGPropertyChangeListener listener,
bool  initial = false 
)

Add a change listener to the property.

If "initial" is set call the listener initially.

◆ addChild() [1/2]

SGPropertyNode * addChild ( const char *  name,
int  min_index = 0,
bool  append = true 
)

Create a new child node with the given name and an unused index.

Parameters
min_indexMinimal index for new node (skips lower indices)
appendWhether to simply use the index after the last used index or use a lower, unused index if it exists

◆ addChild() [2/2]

SGPropertyNode * addChild ( const std::string &  name,
int  min_index = 0,
bool  append = true 
)
inline

Definition at line 897 of file props.hxx.

900 { return addChild(name.c_str(), min_index, append); }
SGPropertyNode * addChild(const char *name, int min_index=0, bool append=true)
Create a new child node with the given name and an unused index.

◆ addChildren()

simgear::PropertyList addChildren ( const std::string &  name,
size_t  count,
int  min_index = 0,
bool  append = true 
)

Create multiple child nodes with the given name an unused indices.

Parameters
countThe number of nodes create
min_indexMinimal index for new nodes (skips lower indices)
appendWhether to simply use the index after the last used index or use a lower, unused index if it exists

◆ alias()

bool alias ( const std::string &  path)
inline

Alias this node's leaf value to another's by relative path.

Definition at line 1005 of file props.hxx.

1006 { return alias(path.c_str()); }

◆ compare()

static bool compare ( const SGPropertyNode lhs,
const SGPropertyNode rhs 
)
static

Compare two property trees.

The property trees are equal if: 1) They have no children, and have the same type and the values are equal, or 2) have the same number of children, and the corresponding children in each tree are equal. "corresponding" means have the same name and index.

Attributes, removed children, and aliases aren't considered.

◆ fireChildrenRemovedRecursive()

void fireChildrenRemovedRecursive ( )

Fire a child-removed event for every child of this node (Unlimited depth)

Upon removal of a child node only for this single node a child-removed event is triggered. If eg. resource cleanup relies on receiving a child-removed event for every child this method can be used.

◆ fireCreatedRecursive()

void fireCreatedRecursive ( bool  fire_self = false)

Trigger a child-added and value-changed event for every child (Unlimited depth).

Parameters
fire_selfWhether to trigger the events also for the node itself.

It can be used to simulating the creation of a property tree, eg. for (re)initializing a subsystem which is controlled through the property tree.

◆ getAttribute()

bool getAttribute ( Attribute  attr) const
inline

Check a single mode attribute for the property node.

Definition at line 1132 of file props.hxx.

1132{ return ((_attr & attr) != 0); }

◆ getAttributes()

int getAttributes ( ) const
inline

Get all of the mode attributes for the property node.

Definition at line 1146 of file props.hxx.

1146{ return _attr; }
+ Here is the caller graph for this function:

◆ getBoolValue()

bool getBoolValue ( const std::string &  relative_path,
bool  defaultValue = false 
) const
inline

Get another node's value as a bool.

Definition at line 1407 of file props.hxx.

1409 { return getBoolValue(relative_path.c_str(), defaultValue); }
bool getBoolValue() const
Get a bool value for this node.

◆ getChild()

const SGPropertyNode * getChild ( const std::string &  name,
int  index = 0 
) const
inline

Get a const child node by name and index.

Definition at line 930 of file props.hxx.

931 { return getChild(name.c_str(), index); }
SGPropertyNode * getChild(int position)
Get a child node by position (NOT index).

◆ getChildren()

simgear::PropertyList getChildren ( const std::string &  name) const
inline

Get a vector of all children with the specified name.

Definition at line 942 of file props.hxx.

943 { return getChildren(name.c_str()); }
simgear::PropertyList getChildren(const char *name) const
Get a vector of all children with the specified name.

◆ getChildValues() [1/2]

template<typename T , typename T_get >
std::vector< T > getChildValues ( const std::string &  name) const

Get a list of values from all children with the given name.

Definition at line 1981 of file props.hxx.

1982{
1983 const simgear::PropertyList& props = getChildren(name);
1984 std::vector<T> values( props.size() );
1985
1986 for( size_t i = 0; i < props.size(); ++i )
1987 values[i] = props[i]->getValue<T_get>();
1988
1989 return values;
1990}
+ Here is the call graph for this function:

◆ getChildValues() [2/2]

template<typename T >
std::vector< T > getChildValues ( const std::string &  name) const
inline

Get a list of values from all children with the given name.

Definition at line 1994 of file props.hxx.

1995{
1996 return getChildValues<T, T>(name);
1997}

◆ getDoubleValue()

double getDoubleValue ( const std::string &  relative_path,
double  defaultValue = 0.0 
) const
inline

Get another node's value as a double.

Definition at line 1461 of file props.hxx.

1463 { return getDoubleValue(relative_path.c_str(), defaultValue); }
double getDoubleValue() const
Get a double value for this node.

◆ getFloatValue()

float getFloatValue ( const std::string &  relative_path,
float  defaultValue = 0.0f 
) const
inline

Get another node's value as a float.

Definition at line 1447 of file props.hxx.

1449 { return getFloatValue(relative_path.c_str(), defaultValue); }
float getFloatValue() const
Get a float value for this node.

◆ getIndex()

int getIndex ( ) const
inline

Get the node's integer index.

Definition at line 833 of file props.hxx.

833{ return _index; }

◆ getIntValue()

int getIntValue ( const std::string &  relative_path,
int  defaultValue = 0 
) const
inline

Get another node's value as an int.

Definition at line 1420 of file props.hxx.

1422 { return getIntValue(relative_path.c_str(), defaultValue); }
int getIntValue() const
Get an int value for this node.

◆ getLongValue()

long getLongValue ( const std::string &  relative_path,
long  defaultValue = 0L 
) const
inline

Get another node's value as a long int.

Definition at line 1434 of file props.hxx.

1436 { return getLongValue(relative_path.c_str(), defaultValue); }
long getLongValue() const
Get a long int value for this node.

◆ getNameString()

const std::string & getNameString ( ) const
inline

Get the node's simple name as a string.

Definition at line 822 of file props.hxx.

822{ return _name; }

◆ getNode() [1/6]

const SGPropertyNode * getNode ( const char *  relative_path,
int  index 
) const

Get a const pointer to another node by relative path.

This method leaves the index off the last member of the path, so that the user can specify it separate.

◆ getNode() [2/6]

SGPropertyNode * getNode ( const char *  relative_path,
int  index,
bool  create = false 
)

Get a pointer to another node by relative path.

This method leaves the index off the last member of the path, so that the user can specify it separately (and save some string building). For example, getNode("/bar[1]/foo", 3) is exactly equivalent to getNode("bar[1]/foo[3]"). The index provided overrides any given in the path itself for the last component.

◆ getNode() [3/6]

const SGPropertyNode * getNode ( const std::string &  relative_path) const
inline

Get a const pointer to another node by relative path.

Definition at line 1102 of file props.hxx.

1103 { return getNode(relative_path.c_str()); }
SGPropertyNode * getNode(const char *relative_path, bool create=false)
Get a pointer to another node by relative path.

◆ getNode() [4/6]

SGPropertyNode * getNode ( const std::string &  relative_path,
bool  create = false 
)
inline

Get a pointer to another node by relative path.

Definition at line 1064 of file props.hxx.

1065 { return getNode(relative_path.c_str(), create); }

◆ getNode() [5/6]

const SGPropertyNode * getNode ( const std::string &  relative_path,
int  index 
) const
inline

Get a const pointer to another node by relative path.

This method leaves the index off the last member of the path, so that the user can specify it separate.

Definition at line 1121 of file props.hxx.

1123 { return getNode(relative_path.c_str(), index); }

◆ getNode() [6/6]

SGPropertyNode * getNode ( const std::string &  relative_path,
int  index,
bool  create = false 
)
inline

Get a pointer to another node by relative path.

This method leaves the index off the last member of the path, so that the user can specify it separately (and save some string building). For example, getNode("/bar[1]/foo", 3) is exactly equivalent to getNode("bar[1]/foo[3]"). The index provided overrides any given in the path itself for the last component.

Definition at line 1090 of file props.hxx.

1092 { return getNode(relative_path.c_str(), index, create); }

◆ getParent() [1/2]

SGPropertyNode * getParent ( )
inline

Get a non-const pointer to the node's parent.

Definition at line 839 of file props.hxx.

839{ return _parent; }

◆ getParent() [2/2]

const SGPropertyNode * getParent ( ) const
inline

Get a const pointer to the node's parent.

Definition at line 845 of file props.hxx.

845{ return _parent; }

◆ getStringValue()

const char * getStringValue ( const std::string &  relative_path,
const char *  defaultValue = "" 
) const
inline

Get another node's value as a string.

Definition at line 1475 of file props.hxx.

1477 { return getStringValue(relative_path.c_str(), defaultValue); }
const char * getStringValue() const
Get a string value for this node.

◆ getType()

simgear::props::Type getType ( const std::string &  relative_path) const
inline

Get another node's type.

Definition at line 1384 of file props.hxx.

1385 { return getType(relative_path.c_str()); }
simgear::props::Type getType() const
Get the type of leaf value, if any, for this node.

◆ getValue() [1/3]

template<typename T >
T getValue ( typename boost::disable_if_c< simgear::props ::PropertyTraits< T >::Internal >::type *  dummy) const

Definition at line 1946 of file props.hxx.

1948{
1949 using namespace simgear::props;
1950 if (_attr == (READ|WRITE) && _type == EXTENDED
1951 && _value.val->getType() == PropertyTraits<T>::type_tag) {
1952 return static_cast<SGRawValue<T>*>(_value.val)->getValue();
1953 }
1954 if (getAttribute(TRACE_READ))
1955 trace_read();
1956 if (!getAttribute(READ))
1958 switch (_type) {
1959 case EXTENDED:
1960 if (_value.val->getType() == PropertyTraits<T>::type_tag)
1961 return static_cast<SGRawValue<T>*>(_value.val)->getValue();
1962 break;
1963 case STRING:
1964 case UNSPECIFIED:
1965 return simgear::parseString<T>(make_string());
1966 break;
1967 default: // avoid compiler warning
1968 break;
1969 }
1971}
bool getAttribute(Attribute attr) const
Check a single mode attribute for the property node.
Definition props.hxx:1132
T getValue(typename boost::enable_if_c< simgear::props::PropertyTraits< T >::Internal > ::type *dummy=0) const
Get a value from a node.
Abstract base class for a raw value.
Definition props.hxx:320
static T DefaultValue()
The default underlying value for this type.
Definition props.hxx:332
Property value types.
Definition props.hxx:155
@ EXTENDED
The node's value is not stored in the property; the actual value and type is retrieved from an SGRawV...
Definition props.hxx:170

◆ getValue() [2/3]

template<typename T >
T getValue ( typename boost::enable_if_c< simgear::props ::PropertyTraits< T >::Internal >::type *  dummy) const
inline

Definition at line 1974 of file props.hxx.

1976{
1977 return ::getValue<T>(this);
1978}

◆ getValue() [3/3]

template<typename T >
T getValue ( typename boost::enable_if_c< simgear::props::PropertyTraits< T >::Internal > ::type *  dummy = 0) const

Get a value from a node.

If the actual type of the node doesn't match the desired type, a conversion isn't guaranteed.

◆ hasChild() [1/2]

bool hasChild ( const char *  name,
int  index = 0 
) const
inline

Test whether a named child exists.

Definition at line 874 of file props.hxx.

875 {
876 return (getChild(name, index) != 0);
877 }

◆ hasChild() [2/2]

bool hasChild ( const std::string &  name,
int  index = 0 
) const
inline

Test whether a named child exists.

Definition at line 882 of file props.hxx.

883 {
884 return (getChild(name, index) != 0);
885 }

◆ hasValue() [1/2]

bool hasValue ( ) const
inline

Test whether this node contains a primitive leaf value.

Definition at line 817 of file props.hxx.

817{ return (_type != simgear::props::NONE); }
@ NONE
The node hasn't been assigned a value yet.
Definition props.hxx:161
+ Here is the caller graph for this function:

◆ hasValue() [2/2]

bool hasValue ( const std::string &  relative_path) const
inline

Test whether another node has a leaf value.

Definition at line 1395 of file props.hxx.

1396 { return hasValue(relative_path.c_str()); }
bool hasValue() const
Test whether this node contains a primitive leaf value.
Definition props.hxx:817

◆ isAlias()

bool isAlias ( ) const
inline

Test whether the node's leaf value is aliased to another's.

Definition at line 1018 of file props.hxx.

1018{ return (_type == simgear::props::ALIAS); }
@ ALIAS
The node "points" to another node.
Definition props.hxx:162

◆ isTied() [1/2]

bool isTied ( ) const
inline

Test whether this node is bound to an external data source.

Definition at line 1356 of file props.hxx.

1356{ return _tied; }
+ Here is the caller graph for this function:

◆ isTied() [2/2]

bool isTied ( const std::string &  relative_path) const
inline

Test whether another node is bound to an external data source.

Definition at line 1571 of file props.hxx.

1572 { return isTied(relative_path.c_str()); }
bool isTied() const
Test whether this node is bound to an external data source.
Definition props.hxx:1356

◆ nChildren()

int nChildren ( ) const
inline

Get the number of child nodes.

Definition at line 856 of file props.hxx.

856{ return (int)_children.size(); }

◆ nListeners()

int nListeners ( ) const
inline

Get the number of listeners.

Definition at line 1687 of file props.hxx.

1687{ return _listeners ? (int)_listeners->size() : 0; }

◆ removeChild() [1/2]

SGPropertyNode_ptr removeChild ( const std::string &  name,
int  index = 0 
)
inline

Remove a child node.

Definition at line 967 of file props.hxx.

968 { return removeChild(name.c_str(), index); }
bool removeChild(SGPropertyNode *node)
Remove child by pointer (if it is a child of this node).

◆ removeChild() [2/2]

bool removeChild ( SGPropertyNode node)

Remove child by pointer (if it is a child of this node).

Returns
true, if the node was deleted.

◆ removeChildren()

simgear::PropertyList removeChildren ( const std::string &  name)
inline

Remove all children with the specified name.

Definition at line 978 of file props.hxx.

979 { return removeChildren(name.c_str()); }
simgear::PropertyList removeChildren(const char *name)
Remove all children with the specified name.

◆ setAttribute()

void setAttribute ( Attribute  attr,
bool  state 
)
inline

Set a single mode attribute for the property node.

Definition at line 1138 of file props.hxx.

1138 {
1139 (state ? _attr |= attr : _attr &= ~attr);
1140 }
+ Here is the caller graph for this function:

◆ setAttributes()

void setAttributes ( int  attr)
inline

Set all of the mode attributes for the property node.

Definition at line 1152 of file props.hxx.

1152{ _attr = attr; }
+ Here is the caller graph for this function:

◆ setBoolValue()

bool setBoolValue ( const std::string &  relative_path,
bool  value 
)
inline

Set another node's value as a bool.

Definition at line 1488 of file props.hxx.

1489 { return setBoolValue(relative_path.c_str(), value); }
bool setBoolValue(bool value)
Set a bool value for this node.

◆ setDoubleValue()

bool setDoubleValue ( const std::string &  relative_path,
double  value 
)
inline

Set another node's value as a double.

Definition at line 1536 of file props.hxx.

1537 { return setDoubleValue(relative_path.c_str(), value); }
bool setDoubleValue(double value)
Set a double value for this node.

◆ setFloatValue()

bool setFloatValue ( const std::string &  relative_path,
float  value 
)
inline

Set another node's value as a float.

Definition at line 1524 of file props.hxx.

1525 { return setFloatValue(relative_path.c_str(), value); }
bool setFloatValue(float value)
Set a float value for this node.

◆ setIntValue()

bool setIntValue ( const std::string &  relative_path,
int  value 
)
inline

Set another node's value as an int.

Definition at line 1500 of file props.hxx.

1501 { return setIntValue(relative_path.c_str(), value); }
bool setIntValue(int value)
Set an int value for this node.

◆ setLongValue()

bool setLongValue ( const std::string &  relative_path,
long  value 
)
inline

Set another node's value as a long int.

Definition at line 1512 of file props.hxx.

1513 { return setLongValue(relative_path.c_str(), value); }
bool setLongValue(long value)
Set a long int value for this node.

◆ setStringValue() [1/4]

bool setStringValue ( const char *  relative_path,
const std::string &  value 
)
inline

Definition at line 1545 of file props.hxx.

1546 { return setStringValue(relative_path, value.c_str()); }
bool setStringValue(const char *value)
Set a string value for this node.

◆ setStringValue() [2/4]

bool setStringValue ( const std::string &  relative_path,
const char *  value 
)
inline

Set another node's value as a string.

Definition at line 1550 of file props.hxx.

1551 { return setStringValue(relative_path.c_str(), value); }

◆ setStringValue() [3/4]

bool setStringValue ( const std::string &  relative_path,
const std::string &  value 
)
inline

Definition at line 1553 of file props.hxx.

1555 { return setStringValue(relative_path.c_str(), value.c_str()); }

◆ setStringValue() [4/4]

bool setStringValue ( const std::string &  value)
inline

Set a string value for this node.

Definition at line 1263 of file props.hxx.

1264 { return setStringValue(value.c_str()); }

◆ setValue() [1/3]

template<int N>
bool setValue ( const char(&)  val[N])
inline

Definition at line 1283 of file props.hxx.

1284 {
1285 return setValue(&val[0]);
1286 }

◆ setValue() [2/3]

template<typename T >
bool setValue ( const T &  val,
typename boost::disable_if_c< simgear::props ::PropertyTraits< T >::Internal >::type *  dummy 
)

Definition at line 2000 of file props.hxx.

2003{
2004 using namespace simgear::props;
2005 if (_attr == (READ|WRITE) && _type == EXTENDED
2006 && _value.val->getType() == PropertyTraits<T>::type_tag) {
2007 static_cast<SGRawValue<T>*>(_value.val)->setValue(val);
2008 return true;
2009 }
2010 if (getAttribute(WRITE)
2011 && ((_type == EXTENDED
2012 && _value.val->getType() == PropertyTraits<T>::type_tag)
2013 || _type == NONE || _type == UNSPECIFIED)) {
2014 if (_type == NONE || _type == UNSPECIFIED) {
2015 clearValue();
2016 _type = EXTENDED;
2017 _value.val = new SGRawValueContainer<T>(val);
2018 } else {
2019 static_cast<SGRawValue<T>*>(_value.val)->setValue(val);
2020 }
2021 if (getAttribute(TRACE_WRITE))
2022 trace_write();
2023 return true;
2024 }
2025 return false;
2026}
void clearValue()
Clear any existing value and set the type to NONE.
A raw value that contains its value.
Definition props.hxx:649

◆ setValue() [3/3]

template<typename T >
bool setValue ( const T &  val,
typename boost::enable_if_c< simgear::props ::PropertyTraits< T >::Internal >::type *  dummy 
)
inline

Definition at line 2029 of file props.hxx.

2032{
2033 return ::setValue(this, val);
2034}

◆ setValueReadOnly()

template<typename T >
bool setValueReadOnly ( const std::string &  relative_path,
const T &  value 
)
inline

Set relative node to given value and afterwards make read only.

Parameters
relative_pathPath to node
valueValue to set
Returns
whether value could be set

Definition at line 1297 of file props.hxx.

1298 {
1299 SGPropertyNode* node = getNode(relative_path, true);
1300 bool ret = node->setValue(value);
1301 node->setAttributes(READ);
1302 return ret;
1303 }
A node in a property tree.
Definition props.hxx:754
void setAttributes(int attr)
Set all of the mode attributes for the property node.
Definition props.hxx:1152
+ Here is the call graph for this function:

◆ tie() [1/7]

template<typename T >
bool tie ( const SGRawValue< T > &  rawValue,
bool  useDefault = true 
)

Bind this node to an external source.

Definition at line 1915 of file props.hxx.

1916{
1917 using namespace simgear::props;
1918 if (_type == ALIAS || _tied)
1919 return false;
1920
1921 useDefault = useDefault && hasValue();
1922 T old_val = SGRawValue<T>::DefaultValue();
1923 if (useDefault)
1924 old_val = getValue<T>(this);
1925 clearValue();
1928 else
1929 _type = EXTENDED;
1930 _tied = true;
1931 _value.val = rawValue.clone();
1932 if (useDefault) {
1933 int save_attributes = getAttributes();
1934 setAttribute( WRITE, true );
1935 setValue(old_val);
1936 setAttributes( save_attributes );
1937 }
1938 return true;
1939}
void setAttribute(Attribute attr, bool state)
Set a single mode attribute for the property node.
Definition props.hxx:1138
int getAttributes() const
Get all of the mode attributes for the property node.
Definition props.hxx:1146
+ Here is the call graph for this function:

◆ tie() [2/7]

bool tie ( const std::string &  relative_path,
const SGRawValue< bool > &  rawValue,
bool  useDefault = true 
)
inline

Bind another node to an external bool source.

Definition at line 1583 of file props.hxx.

1585 { return tie(relative_path.c_str(), rawValue, useDefault); }
bool tie(const SGRawValue< T > &rawValue, bool useDefault=true)
Bind this node to an external source.
Definition props.hxx:1915

◆ tie() [3/7]

bool tie ( const std::string &  relative_path,
const SGRawValue< const char * > &  rawValue,
bool  useDefault = true 
)
inline

Bind another node to an external string source.

Definition at line 1653 of file props.hxx.

1655 { return tie(relative_path.c_str(), rawValue, useDefault); }

◆ tie() [4/7]

bool tie ( const std::string &  relative_path,
const SGRawValue< double > &  rawValue,
bool  useDefault = true 
)
inline

Bind another node to an external double source.

Definition at line 1639 of file props.hxx.

1641 { return tie(relative_path.c_str(), rawValue, useDefault); }

◆ tie() [5/7]

bool tie ( const std::string &  relative_path,
const SGRawValue< float > &  rawValue,
bool  useDefault = true 
)
inline

Bind another node to an external float source.

Definition at line 1625 of file props.hxx.

1627 { return tie(relative_path.c_str(), rawValue, useDefault); }

◆ tie() [6/7]

bool tie ( const std::string &  relative_path,
const SGRawValue< int > &  rawValue,
bool  useDefault = true 
)
inline

Bind another node to an external int source.

Definition at line 1597 of file props.hxx.

1599 { return tie(relative_path.c_str(), rawValue, useDefault); }

◆ tie() [7/7]

bool tie ( const std::string &  relative_path,
const SGRawValue< long > &  rawValue,
bool  useDefault = true 
)
inline

Bind another node to an external long int source.

Definition at line 1611 of file props.hxx.

1613 { return tie(relative_path.c_str(), rawValue, useDefault); }

◆ untie()

bool untie ( const std::string &  relative_path)
inline

Unbind another node from any external data source.

Definition at line 1666 of file props.hxx.

1667 { return untie(relative_path.c_str()); }
bool untie()
Unbind this node from any external data source.

Member Data Documentation

◆ _interpolation_mgr

simgear::PropertyInterpolationMgr* _interpolation_mgr
staticprotected

Definition at line 1758 of file props.hxx.

◆ alias

Definition at line 1808 of file props.hxx.

◆ bool_val

bool bool_val

Definition at line 1813 of file props.hxx.

◆ double_val

double double_val

Definition at line 1817 of file props.hxx.

◆ float_val

float float_val

Definition at line 1816 of file props.hxx.

◆ int_val

int int_val

Definition at line 1814 of file props.hxx.

◆ LAST_USED_ATTRIBUTE

const int LAST_USED_ATTRIBUTE
static

Last used attribute Update as needed when enum Attribute is changed.

Definition at line 789 of file props.hxx.

◆ long_val

long long_val

Definition at line 1815 of file props.hxx.

◆ string_val

char* string_val

Definition at line 1818 of file props.hxx.

◆ val

SGRaw* val

Definition at line 1809 of file props.hxx.


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