FGPropertyManager Class Reference

#include <FGPropertyManager.h>

Inherits SGPropertyNode, and FGJSBBase.

List of all members.


Detailed Description

Author:
David Megginson, Tony Peden

Definition at line 70 of file FGPropertyManager.h.


Public Member Functions

 FGPropertyManager (void)
 Constructor.
bool GetBool (const string &name, bool defaultValue=false)
 Get a bool value for a property.
double GetDouble (const string &name, double defaultValue=0.0)
 Get a double value for a property.
float GetFloat (const string &name, float defaultValue=0.0)
 Get a float value for a property.
string GetFullyQualifiedName (void)
 Get the fully qualified name of a node This function is very slow, so is probably useful for debugging only.
int GetInt (const string &name, int defaultValue=0)
 Get an int value for a property.
int GetLong (const string &name, long defaultValue=0L)
 Get a long value for a property.
string GetName (void)
 Get the name of a node.
FGPropertyManagerGetNode (const string &relpath, int index, bool create=false)
FGPropertyManagerGetNode (const string &path, bool create=false)
 Get a property node.
string GetPrintableName (void)
 Get the name of a node without underscores, etc.
string GetString (const string &name, string defaultValue="")
 Get a string value for a property.
bool HasNode (const string &path)
 Test whether a given node exists.
string mkPropertyName (string name, bool lowercase)
 Property-ify a name replaces spaces with '-' and, optionally, makes name all lower case.
void SetArchivable (const string &name, bool state=true)
 Set the state of the archive attribute for a property.
bool SetBool (const string &name, bool val)
 Set a bool value for a property.
bool SetDouble (const string &name, double val)
 Set a double value for a property.
bool SetFloat (const string &name, float val)
 Set a float value for a property.
bool SetInt (const string &name, int val)
 Set an int value for a property.
bool SetLong (const string &name, long val)
 Set a long value for a property.
void SetReadable (const string &name, bool state=true)
 Set the state of the read attribute for a property.
bool SetString (const string &name, const string &val)
 Set a string value for a property.
void SetWritable (const string &name, bool state=true)
 Set the state of the write attribute for a property.
template<class T, class V>
void Tie (const string &name, T *obj, int index, V(T::*getter)(int) const, void(T::*setter)(int, V)=0, bool useDefault=true)
 Tie a property to a pair of indexed object methods.
template<class T, class V>
void Tie (const string &name, T *obj, V(T::*getter)() const, void(T::*setter)(V)=0, bool useDefault=true)
 Tie a property to a pair of object methods.
template<class V>
void Tie (const string &name, int index, V(*getter)(int), void(*setter)(int, V)=0, bool useDefault=true)
 Tie a property to a pair of indexed functions.
template<class V>
void Tie (const string &name, V(*getter)(), void(*setter)(V)=0, bool useDefault=true)
 Tie a property to a pair of simple functions.
void Tie (const string &name, double *pointer, bool useDefault=true)
 Tie a property to an external double variable.
void Tie (const string &name, float *pointer, bool useDefault=true)
 Tie a property to an external float variable.
void Tie (const string &name, long *pointer, bool useDefault=true)
 Tie a property to an external long variable.
void Tie (const string &name, int *pointer, bool useDefault=true)
 Tie a property to an external int variable.
void Tie (const string &name, bool *pointer, bool useDefault=true)
 Tie a property to an external bool variable.
void Untie (const string &name)
 Untie a property from an external data source.
virtual ~FGPropertyManager (void)
 Destructor.

Member Function Documentation

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

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:
name The property name.
defaultValue The 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 158 of file FGPropertyManager.cpp.

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

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:
name The property name.
defaultValue The 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 186 of file FGPropertyManager.cpp.

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

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:
name The property name.
defaultValue The 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 179 of file FGPropertyManager.cpp.

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

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:
name The property name.
defaultValue The 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 165 of file FGPropertyManager.cpp.

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

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:
name The property name.
defaultValue The 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 172 of file FGPropertyManager.cpp.

FGPropertyManager * GetNode ( const string &  path,
bool  create = false 
)

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

Definition at line 73 of file FGPropertyManager.cpp.

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

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:
name The property name.
defaultValue The 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 193 of file FGPropertyManager.cpp.

bool HasNode ( const string &  path  ) 

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

Definition at line 93 of file FGPropertyManager.cpp.

string mkPropertyName ( string  name,
bool  lowercase 
)

Parameters:
name string to change
lowercase true to change all upper case chars to lower NOTE: this function changes its argument and thus relies on pass by value

Definition at line 55 of file FGPropertyManager.cpp.

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

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:
name The property name.
state The state of the archive attribute (defaults to true).

Definition at line 242 of file FGPropertyManager.cpp.

bool SetBool ( const string &  name,
bool  val 
)

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 bool value will be converted to the property's type.

Parameters:
name The property name.
val The new value for the property.
Returns:
true if the assignment succeeded, false otherwise.

Definition at line 200 of file FGPropertyManager.cpp.

bool SetDouble ( const string &  name,
double  val 
)

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:
name The property name.
val The new value for the property.
Returns:
true if the assignment succeeded, false otherwise.

Definition at line 228 of file FGPropertyManager.cpp.

bool SetFloat ( const string &  name,
float  val 
)

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 bool value will be converted to the property's type.

Parameters:
name The property name.
val The new value for the property.
Returns:
true if the assignment succeeded, false otherwise.

Definition at line 221 of file FGPropertyManager.cpp.

bool SetInt ( const string &  name,
int  val 
)

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 bool value will be converted to the property's type.

Parameters:
name The property name.
val The new value for the property.
Returns:
true if the assignment succeeded, false otherwise.

Definition at line 207 of file FGPropertyManager.cpp.

bool SetLong ( const string &  name,
long  val 
)

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 bool value will be converted to the property's type.

Parameters:
name The property name.
val The new value for the property.
Returns:
true if the assignment succeeded, false otherwise.

Definition at line 214 of file FGPropertyManager.cpp.

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

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:
name The property name.
state The state of the read attribute (defaults to true).

Definition at line 255 of file FGPropertyManager.cpp.

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

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:
name The property name.
val The new value for the property.
Returns:
true if the assignment succeeded, false otherwise.

Definition at line 235 of file FGPropertyManager.cpp.

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

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:
name The property name.
state The state of the write attribute (defaults to true).

Definition at line 268 of file FGPropertyManager.cpp.

void Tie ( const string &  name,
T *  obj,
int  index,
V(T::*)(int) const   getter,
void(T::*)(int, V)  setter = 0,
bool  useDefault = true 
) [inline]

Every time the property value is queried, the getter (if any) will be invoked with the index provided; every time the property value is modified, the setter (if any) will be invoked with the index provided. The getter can be 0 to make the property unreadable, and the setter can be 0 to make the property unmodifiable.

Parameters:
name The property name to tie (full path).
obj The object whose methods should be invoked.
index The integer argument to pass to the getter and setter methods.
getter The getter method, or 0 if the value is unreadable.
setter The setter method, or 0 if the value is unmodifiable.
useDefault true if the setter should be invoked with any existing property value should be; false if the old value should be discarded; defaults to true.

Definition at line 596 of file FGPropertyManager.h.

void Tie ( const string &  name,
T *  obj,
V(T::*)() const   getter,
void(T::*)(V)  setter = 0,
bool  useDefault = true 
) [inline]

Every time the property value is queried, the getter (if any) will be invoked; every time the property value is modified, the setter (if any) will be invoked. The getter can be 0 to make the property unreadable, and the setter can be 0 to make the property unmodifiable.

Parameters:
name The property name to tie (full path).
obj The object whose methods should be invoked.
getter The object's getter method, or 0 if the value is unreadable.
setter The object's setter method, or 0 if the value is unmodifiable.
useDefault true if the setter should be invoked with any existing property value should there be one; false if the old value should be discarded; defaults to true.

Definition at line 567 of file FGPropertyManager.h.

void Tie ( const string &  name,
int  index,
V(*)(int)  getter,
void(*)(int, V)  setter = 0,
bool  useDefault = true 
) [inline]

Every time the property value is queried, the getter (if any) will be invoked with the index provided; every time the property value is modified, the setter (if any) will be invoked with the index provided. The getter can be 0 to make the property unreadable, and the setter can be 0 to make the property unmodifiable.

Parameters:
name The property name to tie (full path).
index The integer argument to pass to the getter and setter functions.
getter The getter function, or 0 if the value is unreadable.
setter The setter function, or 0 if the value is unmodifiable.
useDefault true if the setter should be invoked with any existing property value should there be one; false if the old value should be discarded; defaults to true.

Definition at line 537 of file FGPropertyManager.h.

void Tie ( const string &  name,
V(*)()  getter,
void(*)(V)  setter = 0,
bool  useDefault = true 
) [inline]

Every time the property value is queried, the getter (if any) will be invoked; every time the property value is modified, the setter (if any) will be invoked. The getter can be 0 to make the property unreadable, and the setter can be 0 to make the property unmodifiable.

Parameters:
name The property name to tie (full path).
getter The getter function, or 0 if the value is unreadable.
setter The setter function, or 0 if the value is unmodifiable.
useDefault true if the setter should be invoked with any existing property value should be; false if the old value should be discarded; defaults to true.

Definition at line 510 of file FGPropertyManager.h.

void Tie ( const string &  name,
double *  pointer,
bool  useDefault = true 
)

The property's value will automatically mirror the variable's value, and vice-versa, until the property is untied.

Parameters:
name The property name to tie (full path).
pointer A pointer to the variable.
useDefault true if any existing property value should be copied to the variable; false if the variable should not be modified; defaults to true.

Definition at line 332 of file FGPropertyManager.cpp.

void Tie ( const string &  name,
float *  pointer,
bool  useDefault = true 
)

The property's value will automatically mirror the variable's value, and vice-versa, until the property is untied.

Parameters:
name The property name to tie (full path).
pointer A pointer to the variable.
useDefault true if any existing property value should be copied to the variable; false if the variable should not be modified; defaults to true.

Definition at line 321 of file FGPropertyManager.cpp.

void Tie ( const string &  name,
long *  pointer,
bool  useDefault = true 
)

The property's value will automatically mirror the variable's value, and vice-versa, until the property is untied.

Parameters:
name The property name to tie (full path).
pointer A pointer to the variable.
useDefault true if any existing property value should be copied to the variable; false if the variable should not be modified; defaults to true.

Definition at line 310 of file FGPropertyManager.cpp.

void Tie ( const string &  name,
int *  pointer,
bool  useDefault = true 
)

The property's value will automatically mirror the variable's value, and vice-versa, until the property is untied.

Parameters:
name The property name to tie (full path).
pointer A pointer to the variable.
useDefault true if any existing property value should be copied to the variable; false if the variable should not be modified; defaults to true.

Definition at line 299 of file FGPropertyManager.cpp.

void Tie ( const string &  name,
bool *  pointer,
bool  useDefault = true 
)

The property's value will automatically mirror the variable's value, and vice-versa, until the property is untied.

Parameters:
name The property name to tie (full path).
pointer A pointer to the variable.
useDefault true if any existing property value should be copied to the variable; false if the variable should not be modified; defaults to true.

Definition at line 289 of file FGPropertyManager.cpp.

void Untie ( const string &  name  ) 

Classes should use this function to release control of any properties they are managing.

Definition at line 281 of file FGPropertyManager.cpp.


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

Generated on Tue May 26 00:55:12 2009 for JSBSim Flight Dynamics Model by  doxygen 1.5.5