]> git.mxchange.org Git - simgear.git/blobdiff - simgear/props/PropertyBasedElement.cxx
Update doxgen config and some comments.
[simgear.git] / simgear / props / PropertyBasedElement.cxx
index 88a0ad2ce52c7bec7a980e1a06a3f44457f54b74..855829c7769d8ff01e8fadae64b5c1fba51d63d9 100644 (file)
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 // Library General Public License for more details.
 //
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+// You should have received a copy of the GNU Library General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA
 
 #include "PropertyBasedElement.hxx"
 
 namespace simgear
 {
 
-  //------------------------------------------------------------------------------
+  //----------------------------------------------------------------------------
   PropertyBasedElement::PropertyBasedElement(SGPropertyNode* node):
     _node(node)
   {
     _node->addChangeListener(this);
   }
 
-  //------------------------------------------------------------------------------
+  //----------------------------------------------------------------------------
   PropertyBasedElement::~PropertyBasedElement()
+  {
+    onDestroy();
+    removeListener();
+  }
+
+  //----------------------------------------------------------------------------
+  void PropertyBasedElement::removeListener()
   {
     _node->removeChangeListener(this);
   }
 
-  //------------------------------------------------------------------------------
+  //----------------------------------------------------------------------------
+  void PropertyBasedElement::destroy()
+  {
+    if( !_node )
+      return;
+
+    // TODO check if really not in use anymore
+    if( _node->getParent() )
+      _node->getParent()
+           ->removeChild(_node->getName(), _node->getIndex());
+  }
+
+  //----------------------------------------------------------------------------
   SGConstPropertyNode_ptr PropertyBasedElement::getProps() const
   {
     return _node;
   }
 
-  //------------------------------------------------------------------------------
+  //----------------------------------------------------------------------------
   SGPropertyNode_ptr PropertyBasedElement::getProps()
   {
     return _node;