7#define __FG_PROPS_HXX 1
12#include <simgear/structure/subsystem_mgr.hxx>
13#include <simgear/props/tiedpropertylist.hxx>
31 void update(
double dt)
override;
37 bool getFreeze()
const;
38 void setFreeze(
bool freeze);
40 simgear::TiedPropertyList _tiedProperties;
42 static const char* getLatitudeString ();
43 static const char* getLongitudeString ();
45 static SGConstPropertyNode_ptr _longDeg, _latDeg, _lonLatformat;
47 SGPropertyNode_ptr _offset;
48 SGPropertyNode_ptr _uyear, _umonth, _uday, _uhour, _umin, _usec, _uwday, _udsec;
49 SGPropertyNode_ptr _ryear, _rmonth, _rday, _rhour, _rmin, _rsec, _rwday, _rdsec;
51 SGPropertyNode_ptr _headingMagnetic, _trackMagnetic;
52 SGPropertyNode_ptr _magVar;
53 SGPropertyNode_ptr _trueHeading, _trueTrack;
56 struct tm _lastRealTime;
58 bool _simFreeze =
false;
59 SGPropertyNode_ptr _timeGmtNode, _timeGmtStringNode;
60 SGPropertyNode_ptr _simFreezeNode;
75extern bool fgSaveFlight (std::ostream &output,
bool write_all =
false);
101extern bool fgLoadProps (
const std::string& path, SGPropertyNode * props,
102 bool in_fg_root =
true,
int default_mode = 0);
119extern SGPropertyNode *
fgGetNode (
const char * path,
bool create =
false);
128inline SGPropertyNode *
fgGetNode (
const std::string & path,
bool create =
false)
148extern SGPropertyNode *
fgGetNode (
const char * path,
149 int index,
bool create =
false);
165inline SGPropertyNode *
fgGetNode (
const std::string & path,
166 int index,
bool create =
false)
168 return fgGetNode(path.c_str(), index, create );
178extern bool fgHasNode (
const char * path);
212 const std::string & path)
227 const char * path,
int index);
238 const std::string & path,
int index)
258extern bool fgGetBool (
const char *
name,
bool defaultValue =
false);
294extern int fgGetInt (
const char *
name,
int defaultValue = 0);
330extern long fgGetLong (
const char *
name,
long defaultValue = 0L);
366extern float fgGetFloat (
const char *
name,
float defaultValue = 0.0);
402extern double fgGetDouble (
const char *
name,
double defaultValue = 0.0);
439 const char * defaultValue =
"");
456 const std::string & defaultValue = std::string(
""))
751fgTie (
const char *
name, V (*getter)(),
void (*setter)(V) = 0,
752 bool useDefault =
true)
754 if (!
globals->get_props()->tie(
name, SGRawValueFunctions<V>(getter, setter),
756 SG_LOG(SG_GENERAL, SG_DEV_WARN,
757 "Failed to tie property " <<
name <<
" to functions");
782 void (*setter)(
int, V) = 0,
bool useDefault =
true)
785 SGRawValueFunctionsIndexed<V>(index,
789 SG_LOG(SG_GENERAL, SG_DEV_WARN,
790 "Failed to tie property " <<
name <<
" to indexed functions");
813template <
class T,
class V>
815fgTie (
const char *
name, T * obj, V (T::*getter)()
const,
816 void (T::*setter)(V) = 0,
bool useDefault =
true)
819 SGRawValueMethods<T,V>(*obj, getter, setter),
821 SG_LOG(SG_GENERAL, SG_DEV_WARN,
822 "Failed to tie property " <<
name <<
" to object methods");
845template <
class T,
class V>
848 V (T::*getter)(
int)
const,
void (T::*setter)(
int, V) = 0,
849 bool useDefault =
true)
852 SGRawValueMethodsIndexed<T,V>(*obj,
857 SG_LOG(SG_GENERAL, SG_DEV_WARN,
858 "Failed to tie property " <<
name <<
" to indexed object methods");
void update(double dt) override
static const char * staticSubsystemClassId()
void fgAddChangeListener(SGPropertyChangeListener *listener, const char *path)
Add a listener to a node.
bool fgHasNode(const char *path)
Test whether a given node exists.
double fgGetDouble(const char *name, double defaultValue=0.0)
Get a double value for a property.
std::string fgGetString(const char *name, const char *defaultValue="")
Get a string value for a property.
void fgSetReadable(const char *name, bool state=true)
Set the state of the read attribute for a property.
void fgUntie(const char *name)
Untie a property from an external data source.
void fgTie(const char *name, V(*getter)(), void(*setter)(V)=0, bool useDefault=true)
Tie a property to a pair of simple functions.
int fgGetInt(const char *name, int defaultValue=0)
Get an int value for a property.
bool fgSaveFlight(std::ostream &output, bool write_all=false)
Save a flight to disk.
bool fgSetDouble(const char *name, double val)
Set a double value for a property.
bool fgSetBool(const char *name, bool val)
Set a bool value for a property.
float fgGetFloat(const char *name, float defaultValue=0.0)
Get a float value for a property.
SGPropertyNode * fgGetNode(const char *path, bool create=false)
Get a property node.
void setLoggingPriority(const char *p)
Set the logging priority.
void fgUntieIfDefined(const std::string &name)
@brfief variant of the above which doesn't warn if the property does not exist
bool fgLoadProps(const std::string &path, SGPropertyNode *props, bool in_fg_root=true, int default_mode=0)
Load properties from a file.
bool fgGetBool(const char *name, bool defaultValue=false)
Get a bool value for a property.
bool fgLoadFlight(std::istream &input)
Load a flight from disk.
bool fgSetLong(const char *name, long val)
Set a long value for a property.
bool fgSetInt(const char *name, int val)
Set an int value for a property.
bool fgSetString(const char *name, const char *val)
Set a string value for a property.
long fgGetLong(const char *name, long defaultValue=0L)
Get a long value for a property.
bool fgSetFloat(const char *name, float val)
Set a float value for a property.
void setLoggingClasses(const char *c)
Set the logging classes.
void fgSetArchivable(const char *name, bool state=true)
Set the state of the archive attribute for a property.
void fgSetWritable(const char *name, bool state=true)
Set the state of the write attribute for a property.