]> git.mxchange.org Git - simgear.git/blobdiff - simgear/props/props.hxx
- allow for (rather unusual) ////// cloud groups
[simgear.git] / simgear / props / props.hxx
index fb04b6bf2d091976ecdf0ec6d7aee69097a04082..41361c9862e392ff4ba7c0ce4a6b69e22e16a216 100644 (file)
@@ -1097,9 +1097,11 @@ public:
 
 
   /**
-   * Add a change listener to the property.
+   * Add a change listener to the property. If "initial" is set call the
+   * listener initially.
    */
-  void addChangeListener (SGPropertyChangeListener * listener);
+  void addChangeListener (SGPropertyChangeListener * listener,
+                          bool initial = false);
 
 
   /**
@@ -1108,6 +1110,12 @@ public:
   void removeChangeListener (SGPropertyChangeListener * listener);
 
 
+  /**
+   * Get the number of listeners.
+   */
+  int nListeners () const { return _listeners ? _listeners->size() : 0; }
+
+
   /**
    * Fire a value change event to all listeners.
    */
@@ -1181,16 +1189,23 @@ private:
   void trace_write () const;
 
 
+  /**
+   * Remove this node from all nodes that link to it in their path cache.
+   */
+  void remove_from_path_caches();
+
+
   class hash_table;
 
+  int _index;
   string _name;
   mutable string _display_name;
-  int _index;
   /// To avoid cyclic reference counting loops this shall not be a reference
   /// counted pointer
   SGPropertyNode * _parent;
   vector<SGPropertyNode_ptr> _children;
   vector<SGPropertyNode_ptr> _removedChildren;
+  vector<hash_table *> _linkedNodes;
   mutable string _path;
   mutable string _buffer;
   hash_table * _path_cache;
@@ -1221,9 +1236,16 @@ private:
   vector <SGPropertyChangeListener *> * _listeners;
 
 
+  /**
+    * Register/unregister node that links to this node in its path cache.
+    */
+  void add_linked_node (hash_table * node) { _linkedNodes.push_back(node); }
+  bool remove_linked_node (hash_table * node);
+
+
 \f
   /**
-   * A very simple hash table with no remove functionality.
+   * A very simple hash table.
    */
   class hash_table {
   public:
@@ -1241,7 +1263,7 @@ private:
       void set_value (SGPropertyNode * value);
     private:
       string _key;
-      SGSharedPtr<SGPropertyNode>  _value;
+      SGSharedPtr<SGPropertyNode> _value;
     };
 
 
@@ -1253,7 +1275,8 @@ private:
       bucket ();
       ~bucket ();
       entry * get_entry (const char * key, bool create = false);
-      void erase(const char * key);
+      bool erase (SGPropertyNode * node);
+      void clear (hash_table * owner);
     private:
       int _length;
       entry ** _entries;
@@ -1265,7 +1288,7 @@ private:
     ~hash_table ();
     SGPropertyNode * get (const char * key);
     void put (const char * key, SGPropertyNode * value);
-    void erase(const char * key);
+    bool erase (SGPropertyNode * node);
 
   private:
     unsigned int hashcode (const char * key);