BIND 10 trac2207, updated. 5b77cd205f08b1bc76ec5ff4248f4c9cb4e0ac27 [2207] Split off the local Writer

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Oct 17 10:16:58 UTC 2012


The branch, trac2207 has been updated
       via  5b77cd205f08b1bc76ec5ff4248f4c9cb4e0ac27 (commit)
      from  1ae2321d7183470ad3540d2a92436893724ea773 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 5b77cd205f08b1bc76ec5ff4248f4c9cb4e0ac27
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Wed Oct 17 12:15:05 2012 +0200

    [2207] Split off the local Writer
    
    Into a separate file. It is not needed to be too public.

-----------------------------------------------------------------------

Summary of changes:
 src/lib/datasrc/memory/Makefile.am                 |    3 +-
 src/lib/datasrc/memory/zone_table_segment_local.cc |    2 +-
 src/lib/datasrc/memory/zone_writer.h               |   67 +-------------------
 .../{zone_writer.cc => zone_writer_local.cc}       |    2 +-
 .../memory/{zone_writer.h => zone_writer_local.h}  |   63 ++----------------
 .../tests/memory/zone_table_segment_unittest.cc    |    2 +-
 .../datasrc/tests/memory/zone_writer_unittest.cc   |    2 +-
 7 files changed, 12 insertions(+), 129 deletions(-)
 rename src/lib/datasrc/memory/{zone_writer.cc => zone_writer_local.cc} (98%)
 copy src/lib/datasrc/memory/{zone_writer.h => zone_writer_local.h} (55%)

-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/memory/Makefile.am b/src/lib/datasrc/memory/Makefile.am
index b626068..25fc0fa 100644
--- a/src/lib/datasrc/memory/Makefile.am
+++ b/src/lib/datasrc/memory/Makefile.am
@@ -22,7 +22,8 @@ libdatasrc_memory_la_SOURCES += zone_table.h zone_table.cc
 libdatasrc_memory_la_SOURCES += zone_finder.h zone_finder.cc
 libdatasrc_memory_la_SOURCES += zone_table_segment.h zone_table_segment.cc
 libdatasrc_memory_la_SOURCES += zone_table_segment_local.h zone_table_segment_local.cc
-libdatasrc_memory_la_SOURCES += zone_writer.h zone_writer.cc
+libdatasrc_memory_la_SOURCES += zone_writer.h
+libdatasrc_memory_la_SOURCES += zone_writer_local.h zone_writer_local.cc
 libdatasrc_memory_la_SOURCES += load_action.h
 nodist_libdatasrc_memory_la_SOURCES = memory_messages.h memory_messages.cc
 
diff --git a/src/lib/datasrc/memory/zone_table_segment_local.cc b/src/lib/datasrc/memory/zone_table_segment_local.cc
index 218c8a2..2630d1e 100644
--- a/src/lib/datasrc/memory/zone_table_segment_local.cc
+++ b/src/lib/datasrc/memory/zone_table_segment_local.cc
@@ -13,7 +13,7 @@
 // PERFORMANCE OF THIS SOFTWARE.
 
 #include <datasrc/memory/zone_table_segment_local.h>
-#include "zone_writer.h"
+#include "zone_writer_local.h"
 
 using namespace isc::util;
 
diff --git a/src/lib/datasrc/memory/zone_writer.cc b/src/lib/datasrc/memory/zone_writer.cc
deleted file mode 100644
index f7f90c6..0000000
--- a/src/lib/datasrc/memory/zone_writer.cc
+++ /dev/null
@@ -1,94 +0,0 @@
-// Copyright (C) 2012  Internet Systems Consortium, Inc. ("ISC")
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
-// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
-// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-// PERFORMANCE OF THIS SOFTWARE.
-
-#include "zone_writer.h"
-#include "zone_data.h"
-#include "zone_table_segment.h"
-
-#include <memory>
-
-using std::auto_ptr;
-
-namespace isc {
-namespace datasrc {
-namespace memory {
-
-ZoneWriterLocal::ZoneWriterLocal(ZoneTableSegment* segment,
-                                 const LoadAction& load_action,
-                                 const dns::Name& origin,
-                                 const dns::RRClass& rrclass) :
-    segment_(segment),
-    load_action_(load_action),
-    origin_(origin),
-    rrclass_(rrclass),
-    zone_data_(NULL),
-    loaded_(false),
-    data_ready_(false)
-{}
-
-ZoneWriterLocal::~ZoneWriterLocal() {
-    // Clean up everything there might be left if someone forgot, just
-    // in case. Or should we assert instead?
-    cleanup();
-}
-
-void
-ZoneWriterLocal::load() {
-    if (loaded_) {
-        isc_throw(isc::Unexpected, "Trying to load twice");
-    }
-    loaded_ = true;
-
-    zone_data_ = load_action_(segment_->getMemorySegment());
-
-    if (zone_data_ == NULL) {
-        // Bug inside load_action_.
-        isc_throw(isc::Unexpected, "No data returned from load action");
-    }
-
-    data_ready_ = true;
-}
-
-void
-ZoneWriterLocal::install() {
-    if (!data_ready_) {
-        isc_throw(isc::Unexpected, "No data to install");
-    }
-
-    data_ready_ = false;
-
-    ZoneTable* table(segment_->getHeader().getTable());
-    if (table == NULL) {
-        isc_throw(isc::Unexpected, "No zone table present");
-    }
-    ZoneTable::AddResult result(table->addZone(segment_->getMemorySegment(),
-                                               rrclass_, origin_, zone_data_));
-
-    zone_data_ = result.zone_data;
-}
-
-void
-ZoneWriterLocal::cleanup() {
-    // We eat the data (if any) now.
-    data_ready_ = false;
-
-    if (zone_data_ != NULL) {
-        ZoneData::destroy(segment_->getMemorySegment(), zone_data_, rrclass_);
-        zone_data_ = NULL;
-    }
-}
-
-}
-}
-}
diff --git a/src/lib/datasrc/memory/zone_writer.h b/src/lib/datasrc/memory/zone_writer.h
index d763fba..1fdfbfd 100644
--- a/src/lib/datasrc/memory/zone_writer.h
+++ b/src/lib/datasrc/memory/zone_writer.h
@@ -12,19 +12,14 @@
 // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 // PERFORMANCE OF THIS SOFTWARE.
 
-#ifndef ZONE_RELOADER_H
-#define ZONE_RELOADER_H
+#ifndef MEM_ZONE_WRITER_H
+#define MEM_ZONE_WRITER_H
 
 #include "load_action.h"
 
-#include <dns/rrclass.h>
-#include <dns/name.h>
-
 namespace isc {
 namespace datasrc {
 namespace memory {
-class ZoneData;
-class ZoneTableSegment;
 
 /// \brief Does an update to a zone.
 ///
@@ -82,64 +77,6 @@ public:
     virtual void cleanup() = 0;
 };
 
-/// \brief Writer implementation which loads data locally.
-///
-/// This implementation prepares a clean zone data and lets one callback
-/// to fill it and another to install it somewhere. The class does mostly
-/// nothing (and delegates the work to the callbacks), just stores little bit
-/// of state between the calls.
-class ZoneWriterLocal : public ZoneWriter {
-public:
-    /// \brief Constructor
-    ///
-    /// \param segment The zone table segment to store the zone into.
-    /// \param load_action The callback used to load data.
-    /// \param install_action The callback used to install the loaded zone.
-    /// \param rrclass The class of the zone.
-    ZoneWriterLocal(ZoneTableSegment* segment, const LoadAction& load_action,
-                      const dns::Name& name, const dns::RRClass& rrclass);
-
-    /// \brief Destructor
-    ~ZoneWriterLocal();
-
-    /// \brief Loads the data.
-    ///
-    /// This prepares an empty ZoneData and calls load_action (passed to
-    /// constructor) to fill it with data.
-    ///
-    /// \throw std::bad_alloc If there's a problem allocating the ZoneData.
-    /// \throw isc::Unexpected if it is called the second time in lifetime
-    ///     of the object.
-    /// \throw Whatever the load_action throws, it is propagated up.
-    virtual void load();
-
-    /// \brief Installs the zone.
-    ///
-    /// This simply calls the install_action.
-    ///
-    /// \throw isc::Unexpected if it is called the second time in lifetime
-    ///     of the object or if load() was not called previously or if
-    ///     cleanup() was already called.
-    /// \throw Whatever the install_action throws, it is propagated up.
-    virtual void install();
-
-    /// \brief Clean up memory.
-    ///
-    /// Cleans up the memory used by load()ed zone if not yet installed, or
-    /// the old zone replaced by install().
-    virtual void cleanup();
-private:
-    ZoneTableSegment* segment_;
-    LoadAction load_action_;
-    dns::Name origin_;
-    dns::RRClass rrclass_;
-    ZoneData* zone_data_;
-    // The load was performed
-    bool loaded_;
-    // The data are ready to be installed
-    bool data_ready_;
-};
-
 }
 }
 }
diff --git a/src/lib/datasrc/memory/zone_writer_local.cc b/src/lib/datasrc/memory/zone_writer_local.cc
new file mode 100644
index 0000000..01df3da
--- /dev/null
+++ b/src/lib/datasrc/memory/zone_writer_local.cc
@@ -0,0 +1,94 @@
+// Copyright (C) 2012  Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#include "zone_writer_local.h"
+#include "zone_data.h"
+#include "zone_table_segment.h"
+
+#include <memory>
+
+using std::auto_ptr;
+
+namespace isc {
+namespace datasrc {
+namespace memory {
+
+ZoneWriterLocal::ZoneWriterLocal(ZoneTableSegment* segment,
+                                 const LoadAction& load_action,
+                                 const dns::Name& origin,
+                                 const dns::RRClass& rrclass) :
+    segment_(segment),
+    load_action_(load_action),
+    origin_(origin),
+    rrclass_(rrclass),
+    zone_data_(NULL),
+    loaded_(false),
+    data_ready_(false)
+{}
+
+ZoneWriterLocal::~ZoneWriterLocal() {
+    // Clean up everything there might be left if someone forgot, just
+    // in case. Or should we assert instead?
+    cleanup();
+}
+
+void
+ZoneWriterLocal::load() {
+    if (loaded_) {
+        isc_throw(isc::Unexpected, "Trying to load twice");
+    }
+    loaded_ = true;
+
+    zone_data_ = load_action_(segment_->getMemorySegment());
+
+    if (zone_data_ == NULL) {
+        // Bug inside load_action_.
+        isc_throw(isc::Unexpected, "No data returned from load action");
+    }
+
+    data_ready_ = true;
+}
+
+void
+ZoneWriterLocal::install() {
+    if (!data_ready_) {
+        isc_throw(isc::Unexpected, "No data to install");
+    }
+
+    data_ready_ = false;
+
+    ZoneTable* table(segment_->getHeader().getTable());
+    if (table == NULL) {
+        isc_throw(isc::Unexpected, "No zone table present");
+    }
+    ZoneTable::AddResult result(table->addZone(segment_->getMemorySegment(),
+                                               rrclass_, origin_, zone_data_));
+
+    zone_data_ = result.zone_data;
+}
+
+void
+ZoneWriterLocal::cleanup() {
+    // We eat the data (if any) now.
+    data_ready_ = false;
+
+    if (zone_data_ != NULL) {
+        ZoneData::destroy(segment_->getMemorySegment(), zone_data_, rrclass_);
+        zone_data_ = NULL;
+    }
+}
+
+}
+}
+}
diff --git a/src/lib/datasrc/memory/zone_writer_local.h b/src/lib/datasrc/memory/zone_writer_local.h
new file mode 100644
index 0000000..6a92056
--- /dev/null
+++ b/src/lib/datasrc/memory/zone_writer_local.h
@@ -0,0 +1,92 @@
+// Copyright (C) 2012  Internet Systems Consortium, Inc. ("ISC")
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#ifndef MEM_ZONE_WRITER_LOCAL_H
+#define MEM_ZONE_WRITER_LOCAL_H
+
+#include "zone_writer.h"
+
+#include <dns/rrclass.h>
+#include <dns/name.h>
+
+namespace isc {
+namespace datasrc {
+namespace memory {
+
+class ZoneData;
+class ZoneTableSegment;
+
+/// \brief Writer implementation which loads data locally.
+///
+/// This implementation prepares a clean zone data and lets one callback
+/// to fill it and another to install it somewhere. The class does mostly
+/// nothing (and delegates the work to the callbacks), just stores little bit
+/// of state between the calls.
+class ZoneWriterLocal : public ZoneWriter {
+public:
+    /// \brief Constructor
+    ///
+    /// \param segment The zone table segment to store the zone into.
+    /// \param load_action The callback used to load data.
+    /// \param install_action The callback used to install the loaded zone.
+    /// \param rrclass The class of the zone.
+    ZoneWriterLocal(ZoneTableSegment* segment, const LoadAction& load_action,
+                      const dns::Name& name, const dns::RRClass& rrclass);
+
+    /// \brief Destructor
+    ~ZoneWriterLocal();
+
+    /// \brief Loads the data.
+    ///
+    /// This prepares an empty ZoneData and calls load_action (passed to
+    /// constructor) to fill it with data.
+    ///
+    /// \throw std::bad_alloc If there's a problem allocating the ZoneData.
+    /// \throw isc::Unexpected if it is called the second time in lifetime
+    ///     of the object.
+    /// \throw Whatever the load_action throws, it is propagated up.
+    virtual void load();
+
+    /// \brief Installs the zone.
+    ///
+    /// This simply calls the install_action.
+    ///
+    /// \throw isc::Unexpected if it is called the second time in lifetime
+    ///     of the object or if load() was not called previously or if
+    ///     cleanup() was already called.
+    /// \throw Whatever the install_action throws, it is propagated up.
+    virtual void install();
+
+    /// \brief Clean up memory.
+    ///
+    /// Cleans up the memory used by load()ed zone if not yet installed, or
+    /// the old zone replaced by install().
+    virtual void cleanup();
+private:
+    ZoneTableSegment* segment_;
+    LoadAction load_action_;
+    dns::Name origin_;
+    dns::RRClass rrclass_;
+    ZoneData* zone_data_;
+    // The load was performed
+    bool loaded_;
+    // The data are ready to be installed
+    bool data_ready_;
+};
+
+}
+}
+}
+
+#endif
diff --git a/src/lib/datasrc/tests/memory/zone_table_segment_unittest.cc b/src/lib/datasrc/tests/memory/zone_table_segment_unittest.cc
index d1d32e0..36f06ad 100644
--- a/src/lib/datasrc/tests/memory/zone_table_segment_unittest.cc
+++ b/src/lib/datasrc/tests/memory/zone_table_segment_unittest.cc
@@ -13,7 +13,7 @@
 // PERFORMANCE OF THIS SOFTWARE.
 
 #include <datasrc/memory/zone_table_segment.h>
-#include <datasrc/memory/zone_writer.h>
+#include <datasrc/memory/zone_writer_local.h>
 #include <gtest/gtest.h>
 
 #include <boost/scoped_ptr.hpp>
diff --git a/src/lib/datasrc/tests/memory/zone_writer_unittest.cc b/src/lib/datasrc/tests/memory/zone_writer_unittest.cc
index e9c698f..2719cb4 100644
--- a/src/lib/datasrc/tests/memory/zone_writer_unittest.cc
+++ b/src/lib/datasrc/tests/memory/zone_writer_unittest.cc
@@ -12,7 +12,7 @@
 // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 // PERFORMANCE OF THIS SOFTWARE.
 
-#include <datasrc/memory/zone_writer.h>
+#include <datasrc/memory/zone_writer_local.h>
 #include <datasrc/memory/zone_table_segment.h>
 #include <datasrc/memory/zone_data.h>
 



More information about the bind10-changes mailing list