]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2207] Split off the local Writer
authorMichal 'vorner' Vaner <michal.vaner@nic.cz>
Wed, 17 Oct 2012 10:15:05 +0000 (12:15 +0200)
committerMichal 'vorner' Vaner <michal.vaner@nic.cz>
Wed, 17 Oct 2012 10:15:05 +0000 (12:15 +0200)
Into a separate file. It is not needed to be too public.

src/lib/datasrc/memory/Makefile.am
src/lib/datasrc/memory/zone_table_segment_local.cc
src/lib/datasrc/memory/zone_writer.h
src/lib/datasrc/memory/zone_writer_local.cc [moved from src/lib/datasrc/memory/zone_writer.cc with 98% similarity]
src/lib/datasrc/memory/zone_writer_local.h [new file with mode: 0644]
src/lib/datasrc/tests/memory/zone_table_segment_unittest.cc
src/lib/datasrc/tests/memory/zone_writer_unittest.cc

index b626068bbedcbc0bfa375d78c8d0a8fee75ec25f..25fc0fa40ac084070692f97e9c145034ce255d8c 100644 (file)
@@ -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
 
index 218c8a2f264ca35216c74b9c3928bc2b524a0562..2630d1eabaefde399ddb95e6d3ced3a8ac2d67c3 100644 (file)
@@ -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;
 
index d763fba11a957775bcd9650229317e5674600e30..1fdfbfd64321dc2e1da189a42b28d01cff1792c9 100644 (file)
 // 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_;
-};
-
 }
 }
 }
similarity index 98%
rename from src/lib/datasrc/memory/zone_writer.cc
rename to src/lib/datasrc/memory/zone_writer_local.cc
index f7f90c6f5c57b308ede89c3c6b69c8dfecdd6d2b..01df3da6cb9dd6f58849f38a91ebd68a0ba7f5b1 100644 (file)
@@ -12,7 +12,7 @@
 // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 // PERFORMANCE OF THIS SOFTWARE.
 
-#include "zone_writer.h"
+#include "zone_writer_local.h"
 #include "zone_data.h"
 #include "zone_table_segment.h"
 
diff --git a/src/lib/datasrc/memory/zone_writer_local.h b/src/lib/datasrc/memory/zone_writer_local.h
new file mode 100644 (file)
index 0000000..6a92056
--- /dev/null
@@ -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
index d1d32e025b9210185b3ded60d9bbf39f1e8b880c..36f06ad2c4835efc329637df4a8ec7657249bf31 100644 (file)
@@ -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>
index e9c698f70f0d268241b3b2d3d4ec23cd6cbb6b55..2719cb452ffa31a23d404b37319dd90c641cf6f2 100644 (file)
@@ -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>