Browse Source

[2268] Move ZoneDataLoader class out of its header

Mukund Sivaraman 12 years ago
parent
commit
f176512171

+ 49 - 0
src/lib/datasrc/memory/zone_data_loader.cc

@@ -13,14 +13,19 @@
 // PERFORMANCE OF THIS SOFTWARE.
 // PERFORMANCE OF THIS SOFTWARE.
 
 
 #include <datasrc/memory/zone_data_loader.h>
 #include <datasrc/memory/zone_data_loader.h>
+#include <datasrc/memory/zone_data_updater.h>
 #include <datasrc/memory/logger.h>
 #include <datasrc/memory/logger.h>
 #include <datasrc/memory/segment_object_holder.h>
 #include <datasrc/memory/segment_object_holder.h>
 
 
 #include <dns/rdataclass.h>
 #include <dns/rdataclass.h>
+#include <dns/rrset.h>
 #include <dns/masterload.h>
 #include <dns/masterload.h>
 
 
 #include <boost/foreach.hpp>
 #include <boost/foreach.hpp>
 #include <boost/bind.hpp>
 #include <boost/bind.hpp>
+#include <boost/noncopyable.hpp>
+
+#include <map>
 
 
 using namespace isc::dns;
 using namespace isc::dns;
 using namespace isc::dns::rdata;
 using namespace isc::dns::rdata;
@@ -31,6 +36,50 @@ namespace memory {
 
 
 using detail::SegmentObjectHolder;
 using detail::SegmentObjectHolder;
 
 
+// A helper internal class for \c loadZoneData().  make it non-copyable
+// to avoid accidental copy.
+//
+// The current internal implementation expects that both a normal
+// (non RRSIG) RRset and (when signed) its RRSIG are added at once.
+// Also in the current implementation, the input sequence of RRsets
+// are grouped with their owner name (so once a new owner name is encountered,
+// no subsequent RRset has the previous owner name), but the ordering
+// in the same group is not fixed.  So we hold all RRsets of the same
+// owner name in node_rrsets_ and node_rrsigsets_, and add the matching
+// pairs of RRsets to the zone when we see a new owner name.
+//
+// The caller is responsible for adding the RRsets of the last group
+// in the input sequence by explicitly calling flushNodeRRsets() at the
+// end.  It's cleaner and more robust if we let the destructor of this class
+// do it, but since we cannot guarantee the adding operation is exception free,
+// we don't choose that option to maintain the common expectation for
+// destructors.
+class ZoneDataLoader : boost::noncopyable {
+public:
+    ZoneDataLoader(util::MemorySegment& mem_sgmt,
+                   const isc::dns::RRClass rrclass,
+                   const isc::dns::Name& zone_name, ZoneData& zone_data) :
+        updater_(mem_sgmt, rrclass, zone_name, zone_data)
+    {}
+
+    void addFromLoad(const isc::dns::ConstRRsetPtr& rrset);
+    void flushNodeRRsets();
+
+private:
+    typedef std::map<isc::dns::RRType, isc::dns::ConstRRsetPtr> NodeRRsets;
+    typedef NodeRRsets::value_type NodeRRsetsVal;
+
+    // A helper to identify the covered type of an RRSIG.
+    static isc::dns::RRType getCoveredType
+        (const isc::dns::ConstRRsetPtr& sig_rrset);
+    const isc::dns::Name& getCurrentName() const;
+
+private:
+    NodeRRsets node_rrsets_;
+    NodeRRsets node_rrsigsets_;
+    ZoneDataUpdater updater_;
+};
+
 void
 void
 ZoneDataLoader::addFromLoad(const ConstRRsetPtr& rrset) {
 ZoneDataLoader::addFromLoad(const ConstRRsetPtr& rrset) {
     // If we see a new name, flush the temporary holders, adding the
     // If we see a new name, flush the temporary holders, adding the

+ 2 - 52
src/lib/datasrc/memory/zone_data_loader.h

@@ -15,70 +15,20 @@
 #ifndef DATASRC_ZONE_DATA_LOADER_H
 #ifndef DATASRC_ZONE_DATA_LOADER_H
 #define DATASRC_ZONE_DATA_LOADER_H 1
 #define DATASRC_ZONE_DATA_LOADER_H 1
 
 
-#include <datasrc/memory/zone_data_updater.h>
-
 #include <datasrc/memory/zone_data.h>
 #include <datasrc/memory/zone_data.h>
 #include <datasrc/iterator.h>
 #include <datasrc/iterator.h>
 #include <dns/name.h>
 #include <dns/name.h>
 #include <dns/rrclass.h>
 #include <dns/rrclass.h>
-#include <dns/rrset.h>
 #include <util/memory_segment.h>
 #include <util/memory_segment.h>
 
 
-#include <boost/noncopyable.hpp>
-#include <map>
-
 namespace isc {
 namespace isc {
 namespace datasrc {
 namespace datasrc {
 namespace memory {
 namespace memory {
 
 
-// A helper internal class for load().  make it non-copyable to avoid
-// accidental copy.
-//
-// The current internal implementation expects that both a normal
-// (non RRSIG) RRset and (when signed) its RRSIG are added at once.
-// Also in the current implementation, the input sequence of RRsets
-// are grouped with their owner name (so once a new owner name is encountered,
-// no subsequent RRset has the previous owner name), but the ordering
-// in the same group is not fixed.  So we hold all RRsets of the same
-// owner name in node_rrsets_ and node_rrsigsets_, and add the matching
-// pairs of RRsets to the zone when we see a new owner name.
-//
-// The caller is responsible for adding the RRsets of the last group
-// in the input sequence by explicitly calling flushNodeRRsets() at the
-// end.  It's cleaner and more robust if we let the destructor of this class
-// do it, but since we cannot guarantee the adding operation is exception free,
-// we don't choose that option to maintain the common expectation for
-// destructors.
-class ZoneDataLoader : boost::noncopyable {
-public:
-    ZoneDataLoader(util::MemorySegment& mem_sgmt,
-                   const isc::dns::RRClass rrclass,
-                   const isc::dns::Name& zone_name, ZoneData& zone_data) :
-        updater_(mem_sgmt, rrclass, zone_name, zone_data)
-    {}
-
-    void addFromLoad(const isc::dns::ConstRRsetPtr& rrset);
-    void flushNodeRRsets();
-
-private:
-    typedef std::map<isc::dns::RRType, isc::dns::ConstRRsetPtr> NodeRRsets;
-    typedef NodeRRsets::value_type NodeRRsetsVal;
-
-    // A helper to identify the covered type of an RRSIG.
-    static isc::dns::RRType getCoveredType
-        (const isc::dns::ConstRRsetPtr& sig_rrset);
-    const isc::dns::Name& getCurrentName() const;
-
-private:
-    NodeRRsets node_rrsets_;
-    NodeRRsets node_rrsigsets_;
-    ZoneDataUpdater updater_;
-};
-
 /// \brief Zone is empty exception.
 /// \brief Zone is empty exception.
 ///
 ///
-/// This is thrown if we have an empty zone created as a result of
-/// load().
+/// This is thrown if we have an empty zone created during
+/// \c loadZoneData().
 struct EmptyZone : public InvalidParameter {
 struct EmptyZone : public InvalidParameter {
     EmptyZone(const char* file, size_t line, const char* what) :
     EmptyZone(const char* file, size_t line, const char* what) :
         InvalidParameter(file, line, what)
         InvalidParameter(file, line, what)