Browse Source

[2108] Add ZoneTable::setZoneData()

Mukund Sivaraman 12 years ago
parent
commit
061fbc119b
2 changed files with 25 additions and 0 deletions
  1. 15 0
      src/lib/datasrc/memory/zone_table.cc
  2. 10 0
      src/lib/datasrc/memory/zone_table.h

+ 15 - 0
src/lib/datasrc/memory/zone_table.cc

@@ -132,6 +132,21 @@ ZoneTable::findZone(const Name& name) const {
     return (FindResult(my_result, node->getData()));
 }
 
+ZoneData*
+ZoneTable::setZoneData(const Name& name, ZoneData* data)
+{
+    ZoneTableNode* node(NULL);
+
+    ZoneTableTree::Result result(zones_->find(name, &node));
+
+    if ((result != ZoneTableTree::EXACTMATCH) &&
+        (result != ZoneTableTree::PARTIALMATCH)) {
+        return (NULL);
+    }
+
+    return (node->setData(data));
+}
+
 } // end of namespace memory
 } // end of namespace datasrc
 } // end of namespace isc

+ 10 - 0
src/lib/datasrc/memory/zone_table.h

@@ -185,6 +185,16 @@ public:
     /// \return A \c FindResult object enclosing the search result (see above).
     FindResult findZone(const isc::dns::Name& name) const;
 
+    /// Override the ZoneData for a node (zone) in the zone tree.
+    ///
+    /// \throw none
+    ///
+    /// \param name A domain name for which the zone data is set.
+    /// \param data The new zone data to set.
+    /// \return A \c ZoneData object containing the old data if the zone
+    /// was found, or \c NULL otherwise.
+    ZoneData* setZoneData(const isc::dns::Name& name, ZoneData* data);
+
 private:
     boost::interprocess::offset_ptr<ZoneTableTree> zones_;
 };