X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fprops%2Fprops.hxx;h=9ce7df4bf52524d315366884ae72b97b292da427;hb=68eb7031e2dce999d112d0164fa28d4b8d66922e;hp=a74b89c28165309decb7df7fc50a0837f04e832a;hpb=6935baba5b9a66bbf1dd2557fc9cc45f0f6768fd;p=simgear.git diff --git a/simgear/props/props.hxx b/simgear/props/props.hxx index a74b89c2..9ce7df4b 100644 --- a/simgear/props/props.hxx +++ b/simgear/props/props.hxx @@ -282,13 +282,11 @@ public: * The template type of a static getter function. */ typedef T (*getter_t)(); - typedef T (*getter_td)(void*); /** * The template type of a static setter function. */ typedef void (*setter_t)(T); - typedef void (*setter_td)(T,void*); /** * Explicit constructor. @@ -301,26 +299,7 @@ public: * to write-disable the value. */ SGRawValueFunctions (getter_t getter = 0, setter_t setter = 0) - : _getter(getter), _setter(setter), - _getter_d(0), _setter_d(0), _data(0) {} - - /** - * Explicit constructor. - * - * Create a new raw value bound to the getter and setter supplied. - * - * @param getter A static function for getting a value, or 0 - * to read-disable the value. - * @param setter A static function for setting a value, or 0 - * to write-disable the value. - * @param data A pointer to user data which gets passed to the - * getter and setter functions. This could be used to pass the this - * pointer to the callback function. - */ - SGRawValueFunctions (getter_td getter = 0, setter_td setter = 0, - void *data = NULL) - : _setter(0), _getter(0), - _getter_d(getter), _setter_d(setter), _data(data) {} + : _getter(getter), _setter(setter) {} /** * Destructor. @@ -335,8 +314,7 @@ public: * return the default value for the type. */ virtual T getValue () const { - if (_getter_d) return (*_getter_d)(_data); - else if (_getter) return (*_getter)(); + if (_getter) return (*_getter)(); else return SGRawValue::DefaultValue; } @@ -348,8 +326,7 @@ public: * method will return false. */ virtual bool setValue (T value) { - if (_setter_d) { (*_setter_d)(value,_data); return true; } - else if (_setter) { (*_setter)(value); return true; } + if (_setter) { (*_setter)(value); return true; } else return false; } @@ -357,18 +334,12 @@ public: * Create a copy of this raw value, bound to the same functions. */ virtual SGRawValue * clone () const { - if (_getter_d) - return new SGRawValueFunctions(_getter_d,_setter_d,_data); - else - return new SGRawValueFunctions(_getter,_setter); + return new SGRawValueFunctions(_getter,_setter); } private: getter_t _getter; setter_t _setter; - getter_td _getter_d; - setter_td _setter_d; - void *_data; }; @@ -387,40 +358,25 @@ class SGRawValueFunctionsIndexed : public SGRawValue { public: typedef T (*getter_t)(int); - typedef T (*getter_td)(int,void*); typedef void (*setter_t)(int,T); - typedef void (*setter_td)(int,T,void*); - SGRawValueFunctionsIndexed (int index, getter_t getter = 0, setter_t setter = -0) - : _index(index), _getter(getter), _setter(setter), - _getter_d(0), _setter_d(0),_data(0) {} - SGRawValueFunctionsIndexed (int index, getter_td getter = 0, setter_td setter = 0, void *data = NULL) - : _index(index), _setter(0), _getter(0), - _getter_d(getter), _setter_d(setter), _data(data) {} + SGRawValueFunctionsIndexed (int index, getter_t getter = 0, setter_t setter = 0) + : _index(index), _getter(getter), _setter(setter) {} virtual ~SGRawValueFunctionsIndexed () {} virtual T getValue () const { - if (_getter_d) return (*_getter_d)(_index,_data); - else if (_getter) return (*_getter)(_index); + if (_getter) return (*_getter)(_index); else return SGRawValue::DefaultValue; } virtual bool setValue (T value) { - if (_setter_d) { (*_setter_d)(_index, value, _data); return true; } - else if (_setter) { (*_setter)(_index, value); return true; } + if (_setter) { (*_setter)(_index, value); return true; } else return false; } virtual SGRawValue * clone () const { - if (_getter_d) - return new SGRawValueFunctionsIndexed(_index,_getter_d,_setter_d,_data); - else - return new SGRawValueFunctionsIndexed(_index,_getter,_setter); + return new SGRawValueFunctionsIndexed(_index, _getter, _setter); } private: int _index; getter_t _getter; setter_t _setter; - getter_td _getter_d; - setter_td _setter_d; - void *_data; }; @@ -605,7 +561,7 @@ public: * Property value types. */ enum Type { - NONE, + NONE = 0, ALIAS, BOOL, INT, @@ -1216,6 +1172,12 @@ public: void fireChildRemoved (SGPropertyNode * child); + /** + * Clear any existing value and set the type to NONE. + */ + void clearValue (); + + protected: void fireValueChanged (SGPropertyNode * node); @@ -1247,12 +1209,6 @@ private: bool set_string (const char * value); - /** - * Clear any existing value and set the type to NONE. - */ - void clear_value (); - - /** * Get the value as a string. */ @@ -1356,6 +1312,7 @@ private: bucket (); virtual ~bucket (); virtual entry * get_entry (const char * key, bool create = false); + virtual void erase(const char * key); private: int _length; entry ** _entries; @@ -1367,6 +1324,7 @@ private: virtual ~hash_table (); virtual SGPropertyNode * get (const char * key); virtual void put (const char * key, SGPropertyNode * value); + virtual void erase(const char * key); private: unsigned int hashcode (const char * key);