]> git.mxchange.org Git - simgear.git/blobdiff - simgear/props/PropertyBasedElement.hxx
cppbind: automatic conversion of SGReferenced derived pointers.
[simgear.git] / simgear / props / PropertyBasedElement.hxx
index 05dbcd1bae15d006d744bbf0929a29585e3d2028..b2ccd30b74fd0c3f1802bb8b1ac647dfe62a6f58 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <simgear/props/props.hxx>
 
+#include <boost/call_traits.hpp>
 #include <boost/shared_ptr.hpp>
 #include <boost/weak_ptr.hpp>
 
@@ -42,12 +43,45 @@ namespace simgear
       PropertyBasedElement(SGPropertyNode* node);
       virtual ~PropertyBasedElement();
 
+      /**
+       * Remove the property listener of the element.
+       *
+       * You will need to call the appropriate methods (#childAdded,
+       * #childRemoved, #valueChanged) yourself to ensure the element still
+       * receives the needed events.
+       */
+      void removeListener();
+
+      /**
+       * Destroys this element (removes node from property tree)
+       */
+      void destroy();
+
       virtual void update(double delta_time_sec) = 0;
 
       SGConstPropertyNode_ptr getProps() const;
       SGPropertyNode_ptr getProps();
 
+      template<class T>
+      void set( const std::string& name,
+                typename boost::call_traits<T>::param_type val )
+      {
+        setValue(_node->getNode(name, true), val);
+      }
+
+      template<class T>
+      T get( const std::string& name,
+             typename boost::call_traits<T>::param_type def = T() )
+      {
+        SGPropertyNode const* child = _node->getNode(name);
+        if( !child )
+          return def;
+
+        return getValue<T>(child);
+      }
+
       virtual void setSelf(const PropertyBasedElementPtr& self);
+      virtual void onDestroy() {};
 
     protected: