2 #define __FG_PROPS_HXX 1
4 #include <simgear/debug/logstream.hxx>
5 #include <simgear/misc/props.hxx>
9 ////////////////////////////////////////////////////////////////////////
10 // Loading and saving properties.
11 ////////////////////////////////////////////////////////////////////////
13 extern bool fgSaveFlight (ostream &output);
14 extern bool fgLoadFlight (istream &input);
18 ////////////////////////////////////////////////////////////////////////
19 // Convenience functions for tying properties, with logging.
20 ////////////////////////////////////////////////////////////////////////
23 fgUntie (const string &name)
25 if (!globals->get_props()->untie(name))
26 FG_LOG(FG_GENERAL, FG_WARN, "Failed to untie property " << name);
30 // Templates cause ambiguity here
32 fgTie (const string &name, bool *pointer)
34 if (!globals->get_props()->tie(name, SGRawValuePointer<bool>(pointer)))
35 FG_LOG(FG_GENERAL, FG_WARN,
36 "Failed to tie property " << name << " to a pointer");
40 fgTie (const string &name, int *pointer)
42 if (!globals->get_props()->tie(name, SGRawValuePointer<int>(pointer)))
43 FG_LOG(FG_GENERAL, FG_WARN,
44 "Failed to tie property " << name << " to a pointer");
48 fgTie (const string &name, float *pointer)
50 if (!globals->get_props()->tie(name, SGRawValuePointer<float>(pointer)))
51 FG_LOG(FG_GENERAL, FG_WARN,
52 "Failed to tie property " << name << " to a pointer");
56 fgTie (const string &name, double *pointer)
58 if (!globals->get_props()->tie(name, SGRawValuePointer<double>(pointer)))
59 FG_LOG(FG_GENERAL, FG_WARN,
60 "Failed to tie property " << name << " to a pointer");
64 fgTie (const string &name, string *pointer)
66 if (!globals->get_props()->tie(name, SGRawValuePointer<string>(pointer)))
67 FG_LOG(FG_GENERAL, FG_WARN,
68 "Failed to tie property " << name << " to a pointer");
73 fgTie (const string &name, V (*getter)(), void (*setter)(V) = 0)
75 if (!globals->get_props()->tie(name, SGRawValueFunctions<V>(getter, setter)))
76 FG_LOG(FG_GENERAL, FG_WARN,
77 "Failed to tie property " << name << " to functions");
82 fgTie (const string &name, int index, V (*getter)(int),
83 void (*setter)(int, V) = 0)
85 if (!globals->get_props()->tie(name,
86 SGRawValueFunctionsIndexed<V>(index,
89 FG_LOG(FG_GENERAL, FG_WARN,
90 "Failed to tie property " << name << " to indexed functions");
93 template <class T, class V>
95 fgTie (const string &name, T * obj, V (T::*getter)() const,
96 void (T::*setter)(V) = 0)
98 if (!globals->get_props()->tie(name,
99 SGRawValueMethods<T,V>(*obj, getter, setter)))
100 FG_LOG(FG_GENERAL, FG_WARN,
101 "Failed to tie property " << name << " to object methods");
104 template <class T, class V>
106 fgTie (const string &name, T * obj, int index,
107 V (T::*getter)(int) const, void (T::*setter)(int, V) = 0)
109 if (!globals->get_props()->tie(name,
110 SGRawValueMethodsIndexed<T,V>(*obj,
114 FG_LOG(FG_GENERAL, FG_WARN,
115 "Failed to tie property " << name << " to indexed object methods");
119 #endif // __FG_PROPS_HXX