Howto:Work with the Property Tree API: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
mNo edit summary
m (adding propertytree tag)
Line 1: Line 1:
{{Stub}}
{{Stub}}
{{WIP}}
{{PropertyTree}}


Most FlightGear systems communicate internally using the so called [[Property Tree]] (see [[Property Tree Intro]] for an introduction).  
Most FlightGear systems communicate internally using the so called [[Property Tree]] (see [[Property Tree Intro]] for an introduction).  

Revision as of 10:11, 10 September 2009

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);