rdata_field.h rdata_field.cc \
rdata_reader.h rdata_reader.cc \
rdataset.h rdataset.cc \
- domaintree.h
+ domaintree.h \
+ zone_data.h zone_data.cc
run_unittests_SOURCES += rdata_serialization_unittest.cc
run_unittests_SOURCES += rdataset_unittest.cc
run_unittests_SOURCES += domaintree_unittest.cc
+run_unittests_SOURCES += zone_data_unittest.cc
run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS)
--- /dev/null
+// 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 <exceptions/exceptions.h>
+
+#include <util/memory_segment_local.h>
+
+#include <datasrc/memory/rdata_encoder.h>
+#include <datasrc/memory/rdataset.h>
+#include <datasrc/memory/zone_data.h>
+
+#include <gtest/gtest.h>
+
+using namespace isc::datasrc::memory;
+
+namespace {
+
+class ZoneDataTest : public ::testing::Test {
+protected:
+ ZoneDataTest() {}
+ void TearDown() {
+ // detect any memory leak in the test memory segment
+ EXPECT_TRUE(mem_sgmt_.allMemoryDeallocated());
+ }
+
+ isc::util::MemorySegmentLocal mem_sgmt_;
+ RdataEncoder encoder_;
+};
+
+TEST_F(ZoneDataTest, create) {
+ ZoneData* zone_data = ZoneData::create(mem_sgmt_);
+ ZoneData::destroy(mem_sgmt_, zone_data);
+}
+}
--- /dev/null
+// 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 <util/memory_segment.h>
+
+#include "rdataset.h"
+#include "rdata_encoder.h"
+#include "zone_data.h"
+
+#include <new> // for the placement new
+
+namespace isc {
+namespace datasrc {
+namespace memory {
+
+ZoneData*
+ZoneData::create(util::MemorySegment& mem_sgmt) {
+ ZoneTree* tree = ZoneTree::create(mem_sgmt, true);
+ void* p = mem_sgmt.allocate(sizeof(ZoneData));
+ ZoneData* zone_data = new(p) ZoneData;
+ zone_data->zone_tree = tree;
+
+ return (zone_data);
+}
+
+void
+ZoneData::destroy(util::MemorySegment& mem_sgmt, ZoneData* zone_data) {
+ ZoneTree::destroy(mem_sgmt, zone_data->zone_tree.get());
+ mem_sgmt.deallocate(zone_data, sizeof(ZoneData));
+}
+
+
+
+} // namespace memory
+} // namespace datasrc
+} // datasrc isc
--- /dev/null
+// 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 DATASRC_MEMORY_ZONE_DATA_H
+#define DATASRC_MEMORY_ZONE_DATA_H 1
+
+#include <util/memory_segment.h>
+
+#include <datasrc/memory/domaintree.h>
+#include <datasrc/memory/rdataset.h>
+
+#include <boost/interprocess/offset_ptr.hpp>
+#include <boost/noncopyable.hpp>
+
+namespace isc {
+namespace datasrc {
+namespace memory {
+
+class ZoneData : boost::noncopyable {
+ struct RdataSetDeleter {
+ public:
+ RdataSetDeleter() {}
+ void operator()(util::MemorySegment& /*mem_sgmt*/,
+ RdataSet* /*rdataset_head*/) const
+ {}
+ };
+ typedef DomainTree<RdataSet, RdataSetDeleter> ZoneTree;
+
+public:
+ static ZoneData* create(util::MemorySegment& mem_sgmt);
+ static void destroy(util::MemorySegment& mem_sgmt, ZoneData* zone_data);
+
+ boost::interprocess::offset_ptr<ZoneTree> zone_tree;
+};
+
+} // namespace memory
+} // namespace datasrc
+} // namespace isc
+
+#endif // DATASRC_MEMORY_ZONE_DATA_H
+
+// Local Variables:
+// mode: c++
+// End: