Howto:Work with the Property Tree API: Difference between revisions
mNo edit summary |
mNo edit summary |
||
Line 8: | Line 8: | ||
Most of the high level API can be found in the [[$FG_SRC]]/Main folder, specifically the files fg_props.cxx and the corresponding fg_props.hxx header are relevant (this is the one, that you'll want to include when working with the property tree). | Most of the high level API can be found in the [[$FG_SRC]]/Main folder, specifically the files fg_props.cxx and the corresponding fg_props.hxx header are relevant (this is the one, that you'll want to include when working with the property tree). | ||
The property tree implementation itself is to be found in the SimGear sources ([http://simgear | The property tree implementation itself is to be found in the SimGear sources ([http://www.menet.umn.edu/~curt/simgear/doxygen/props__io_8cxx_source.html] see specifically [http://www.menet.umn.edu/~curt/simgear/doxygen/classSGPropertyNode.html SGPropertyNode]). | ||
Note: Accessing property manager values via static propertynode pointers is more efficient because you only have to do the expensive string name hash lookup once the first time the routine runs. | Note: Accessing property manager values via static propertynode pointers is more efficient because you only have to do the expensive string name hash lookup once the first time the routine runs. |
Revision as of 18:43, 26 May 2010
This article is a stub. You can help the wiki by expanding it. |
Most FlightGear systems communicate internally using the so called Property Tree (see Property Tree Intro for an introduction).
This article is meant to introduce you to the C++ API that is used by FlightGear to work with the Property Tree.
Most of the high level API can be found in the $FG_SRC/Main folder, specifically the files fg_props.cxx and the corresponding fg_props.hxx header are relevant (this is the one, that you'll want to include when working with the property tree).
The property tree implementation itself is to be found in the SimGear sources ([1] see specifically SGPropertyNode).
Note: Accessing property manager values via static propertynode pointers is more efficient because you only have to do the expensive string name hash lookup once the first time the routine runs.
Checking for Property Existence
bool fgHasNode (const char * path);
Getters
SGPropertyNode * fgGetNode (const char * path, bool create); SGPropertyNode * fgGetNode (const char * path, int index, bool create);
Boolean Values
bool fgSetBool (const char * name, bool val); bool fgGetBool (const char * name, bool defaultValue);
Integers
bool fgSetInt (const char * name, int val); int fgGetInt (const char * name, int defaultValue);
Floats
bool fgSetFloat (const char * name, float val); float fgGetFloat (const char * name, float defaultValue);
Doubles
bool fgSetDouble (const char * name, double val); double fgGetDouble (const char * name, double defaultValue);
Longs
long fgGetLong (const char * name, long defaultValue); fgSetLong (const char * name, long val);
Strings
bool fgSetString (const char * name, const char * val); const char * fgGetString (const char * name, const char * defaultValue);
Using Listeners
void fgAddChangeListener (SGPropertyChangeListener * listener, const char * path); void fgAddChangeListener (SGPropertyChangeListener * listener, const char * path, int index);
Attributes
Persistance
void fgSetArchivable (const char * name, bool state);
Access
void fgSetReadable (const char * name, bool state); void fgSetWritable (const char * name, bool state);
Tied Properties
void fgUntie (const char * name);