SGPropertyNode Class Reference

A node in a property tree. More...

#include <props.hxx>

Inheritance diagram for SGPropertyNode:
SGReferenced

List of all members.

Public Types

enum  
 

Public constants.


enum  Attribute
 

Access mode attributes.

More...

Public Member Functions

 SGPropertyNode ()
 Default constructor.
 SGPropertyNode (const SGPropertyNode &node)
 Copy constructor.
virtual ~SGPropertyNode ()
 Destructor.
bool hasValue () const
 Test whether this node contains a primitive leaf value.
const char * getName () const
 Get the node's simple (XML) name.
const std::string & getNameString () const
 Get the node's simple name as a string.
std::string getDisplayName (bool simplify=false) const
 Get the node's pretty display name, with subscript when needed.
int getIndex () const
 Get the node's integer index.
SGPropertyNodegetParent ()
 Get a non-const pointer to the node's parent.
const SGPropertyNodegetParent () const
 Get a const pointer to the node's parent.
int nChildren () const
 Get the number of child nodes.
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).
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.
SGPropertyNodeaddChild (const char *name)
 Create a child node after the last node with the same name.
SGPropertyNodegetChild (const char *name, int index=0, bool create=false)
 Get a child node by name and index.
const SGPropertyNodegetChild (const char *name, int index=0) const
 Get a const 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.
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.
SGPropertyNode_ptr removeChild (int pos, bool keep=true)
 Remove child by position.
SGPropertyNode_ptr removeChild (const char *name, int index=0, bool keep=true)
 Remove a child node.
SGPropertyNode_ptr removeChild (const std::string &name, int index=0, bool keep=true)
 Remove a child node.
simgear::PropertyList removeChildren (const char *name, bool keep=true)
 Remove all children with the specified name.
simgear::PropertyList removeChildren (const std::string &name, bool keep=true)
 Remove all children with the specified name.
bool alias (SGPropertyNode *target)
 Alias this node's leaf value to another's.
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 unalias ()
 Remove any alias for this node.
bool isAlias () const
 Test whether the node's leaf value is aliased to another's.
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.
const char * 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.
SGPropertyNodegetNode (const char *relative_path, bool create=false)
 Get a 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.
SGPropertyNodegetNode (const char *relative_path, int index, bool create=false)
 Get a 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.
const SGPropertyNodegetNode (const char *relative_path) const
 Get a const 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.
const SGPropertyNodegetNode (const char *relative_path, int index) const
 Get a const 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.
bool getAttribute (Attribute attr) const
 Check a single mode attribute for the property node.
void setAttribute (Attribute attr, bool state)
 Set a single mode attribute for the property node.
int getAttributes () const
 Get all of the mode attributes for the property node.
void setAttributes (int attr)
 Set all of the mode attributes for the property node.
simgear::props::Type getType () const
 Get the type of leaf value, if any, for this node.
bool getBoolValue () const
 Get a bool value for this node.
int getIntValue () const
 Get an int value for this node.
long getLongValue () const
 Get a long int value for this node.
float getFloatValue () const
 Get a float value for this node.
double getDoubleValue () const
 Get a double value for this node.
const char * getStringValue () const
 Get a string value for this node.
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 setBoolValue (bool value)
 Set a bool value for this node.
bool setIntValue (int value)
 Set an int value for this node.
bool setLongValue (long value)
 Set a long int value for this node.
bool setFloatValue (float value)
 Set a float value for this node.
bool setDoubleValue (double value)
 Set a double value for this node.
bool setStringValue (const char *value)
 Set a string value for this node.
bool setStringValue (const std::string &value)
 Set a string value for this node.
bool setUnspecifiedValue (const char *value)
 Set a value of unspecified type for this node.
std::ostream & printOn (std::ostream &stream) const
 Print the value of the property to a stream.
bool isTied () const
 Test whether this node is bound to an external data source.
template<typename T >
bool tie (const SGRawValue< T > &rawValue, bool useDefault=true)
 Bind this node to an external source.
bool untie ()
 Unbind this node from any external data source.
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.
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 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.
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 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.
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.
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.
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.
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 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 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 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 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 setStringValue (const char *relative_path, const char *value)
 Set another node's value as a string.
bool setStringValue (const std::string &relative_path, const char *value)
 Set another node's value as a string.
bool setUnspecifiedValue (const char *relative_path, const char *value)
 Set another node's value with no specified type.
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.
bool tie (const char *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< bool > &rawValue, bool useDefault=true)
 Bind another node to an external bool 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 std::string &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.
bool tie (const std::string &relative_path, const SGRawValue< long > &rawValue, bool useDefault=true)
 Bind another node to an external long int 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 std::string &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< double > &rawValue, bool useDefault=true)
 Bind another node to an external double 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 char *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< const char * > &rawValue, bool useDefault=true)
 Bind another node to an external string 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.
void addChangeListener (SGPropertyChangeListener *listener, bool initial=false)
 Add a change listener to the property.
void removeChangeListener (SGPropertyChangeListener *listener)
 Remove a change listener from the property.
int nListeners () const
 Get the number of listeners.
void fireValueChanged ()
 Fire a value change event to all listeners.
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 clearValue ()
 Clear any existing value and set the type to NONE.

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 = USERARCHIVE
 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)
 Convenience constructor.

Detailed Description

A node in a property tree.

Definition at line 739 of file props.hxx.


Member Enumeration Documentation

Access mode attributes.

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

Definition at line 756 of file props.hxx.


Constructor & Destructor Documentation

SGPropertyNode::SGPropertyNode (  ) 

Default constructor.

Default constructor: always creates a root node.

Definition at line 641 of file props.cxx.


Member Function Documentation

void SGPropertyNode::addChangeListener ( SGPropertyChangeListener listener,
bool  initial = false 
)

Add a change listener to the property.

If "initial" is set call the listener initially.

Definition at line 2043 of file props.cxx.

SGPropertyNode * SGPropertyNode::addChild ( const char *  name  ) 

Create a child node after the last node with the same name.

create a non-const child by name after the last node with the same name.

Definition at line 829 of file props.cxx.

bool SGPropertyNode::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.

Definition at line 2423 of file props.cxx.

SGPropertyNode * SGPropertyNode::getAliasTarget (  ) 

Get a non-const pointer to the current alias target, if any.

Get the target of an alias.

Definition at line 813 of file props.cxx.

bool SGPropertyNode::getBoolValue ( const char *  relative_path,
bool  defaultValue = false 
) const

Get another node's value as a bool.

Get a bool value for another node.

Definition at line 1810 of file props.cxx.

const SGPropertyNode * SGPropertyNode::getChild ( const char *  name,
int  index = 0 
) const

Get a const child node by name and index.

Get a const child by name and index.

Definition at line 898 of file props.cxx.

SGPropertyNode * SGPropertyNode::getChild ( const char *  name,
int  index = 0,
bool  create = false 
)

Get a child node by name and index.

Get a non-const child by name and index, creating if necessary.

Definition at line 872 of file props.cxx.

const SGPropertyNode * SGPropertyNode::getChild ( int  position  )  const

Get a const child node by position (*NOT* index).

Get a const child by index.

Definition at line 858 of file props.cxx.

SGPropertyNode * SGPropertyNode::getChild ( int  position  ) 

Get a child node by position (*NOT* index).

Get a non-const child by index.

Definition at line 845 of file props.cxx.

PropertyList SGPropertyNode::getChildren ( const char *  name  )  const

Get a vector of all children with the specified name.

Get all children with the same name (but different indices).

Definition at line 912 of file props.cxx.

double SGPropertyNode::getDoubleValue ( const char *  relative_path,
double  defaultValue = 0.0 
) const

Get another node's value as a double.

Get a double value for another node.

Definition at line 1858 of file props.cxx.

float SGPropertyNode::getFloatValue ( const char *  relative_path,
float  defaultValue = 0.0f 
) const

Get another node's value as a float.

Get a float value for another node.

Definition at line 1846 of file props.cxx.

int SGPropertyNode::getIntValue ( const char *  relative_path,
int  defaultValue = 0 
) const

Get another node's value as an int.

Get an int value for another node.

Definition at line 1822 of file props.cxx.

long SGPropertyNode::getLongValue ( const char *  relative_path,
long  defaultValue = 0L 
) const

Get another node's value as a long int.

Get a long value for another node.

Definition at line 1834 of file props.cxx.

const SGPropertyNode* 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 1077 of file props.hxx.

const SGPropertyNode * 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.

Definition at line 1773 of file props.cxx.

SGPropertyNode* 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 1046 of file props.hxx.

SGPropertyNode * 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.

Definition at line 1758 of file props.cxx.

const char * SGPropertyNode::getStringValue ( const char *  relative_path,
const char *  defaultValue = "" 
) const

Get another node's value as a string.

Get a string value for another node.

Definition at line 1870 of file props.cxx.

props::Type SGPropertyNode::getType ( const char *  relative_path  )  const

Get another node's type.

Get the value type for another node.

Definition at line 1799 of file props.cxx.

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

Get a value from a node.

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

Definition at line 1898 of file props.hxx.

bool SGPropertyNode::hasValue ( const char *  relative_path  )  const

Test whether another node has a leaf value.

Test whether another node has a value attached.

Definition at line 1788 of file props.cxx.

bool SGPropertyNode::isTied ( const char *  relative_path  )  const

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

Test whether another node is tied.

Definition at line 1953 of file props.cxx.

bool SGPropertyNode::setBoolValue ( const char *  relative_path,
bool  value 
)

Set another node's value as a bool.

Set a bool value for another node.

Definition at line 1882 of file props.cxx.

bool SGPropertyNode::setDoubleValue ( const char *  relative_path,
double  value 
)

Set another node's value as a double.

Set a double value for another node.

Definition at line 1922 of file props.cxx.

bool SGPropertyNode::setFloatValue ( const char *  relative_path,
float  value 
)

Set another node's value as a float.

Set a float value for another node.

Definition at line 1912 of file props.cxx.

bool SGPropertyNode::setIntValue ( const char *  relative_path,
int  value 
)

Set another node's value as an int.

Set an int value for another node.

Definition at line 1892 of file props.cxx.

bool SGPropertyNode::setLongValue ( const char *  relative_path,
long  value 
)

Set another node's value as a long int.

Set a long value for another node.

Definition at line 1902 of file props.cxx.

bool SGPropertyNode::setStringValue ( const char *  relative_path,
const char *  value 
)

Set another node's value as a string.

Set a string value for another node.

Definition at line 1932 of file props.cxx.

bool SGPropertyNode::setUnspecifiedValue ( const char *  relative_path,
const char *  value 
)

Set another node's value with no specified type.

Set an unknown value for another node.

Definition at line 1942 of file props.cxx.

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

Bind another node to an external string source.

Tie a node reached by a relative path, creating it if necessary.

Definition at line 2024 of file props.cxx.

bool SGPropertyNode::tie ( const char *  relative_path,
const SGRawValue< double > &  rawValue,
bool  useDefault = true 
)

Bind another node to an external double source.

Tie a node reached by a relative path, creating it if necessary.

Definition at line 2012 of file props.cxx.

bool SGPropertyNode::tie ( const char *  relative_path,
const SGRawValue< float > &  rawValue,
bool  useDefault = true 
)

Bind another node to an external float source.

Tie a node reached by a relative path, creating it if necessary.

Definition at line 2000 of file props.cxx.

bool SGPropertyNode::tie ( const char *  relative_path,
const SGRawValue< long > &  rawValue,
bool  useDefault = true 
)

Bind another node to an external long int source.

Tie a node reached by a relative path, creating it if necessary.

Definition at line 1988 of file props.cxx.

bool SGPropertyNode::tie ( const char *  relative_path,
const SGRawValue< int > &  rawValue,
bool  useDefault = true 
)

Bind another node to an external int source.

Tie a node reached by a relative path, creating it if necessary.

Definition at line 1976 of file props.cxx.

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

Bind another node to an external bool source.

Tie a node reached by a relative path, creating it if necessary.

Definition at line 1964 of file props.cxx.

bool SGPropertyNode::unalias (  ) 

Remove any alias for this node.

Remove an alias.

Definition at line 800 of file props.cxx.

bool SGPropertyNode::untie ( const char *  relative_path  ) 

Unbind another node from any external data source.

Attempt to untie another node reached by a relative path.

Definition at line 2036 of file props.cxx.


Member Data Documentation

Alias to another node.

Alias to another node by path.

Definition at line 1687 of file props.hxx.


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

Generated on 23 Feb 2010 for SimGear by  doxygen 1.6.1