From: Michal 'vorner' Vaner Date: Mon, 15 Oct 2012 09:28:35 +0000 (+0200) Subject: [2207] interface of the getZoneReloader X-Git-Tag: trac2402_base~12^2~25 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c55218e6bebfeec753b01e4cd724adcda40b3a5f;p=thirdparty%2Fkea.git [2207] interface of the getZoneReloader --- diff --git a/src/lib/datasrc/memory/Makefile.am b/src/lib/datasrc/memory/Makefile.am index 192bbce965..7319602e8b 100644 --- a/src/lib/datasrc/memory/Makefile.am +++ b/src/lib/datasrc/memory/Makefile.am @@ -23,6 +23,7 @@ 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_reloader.h zone_reloader.cc +libdatasrc_memory_la_SOURCES += load_action.h nodist_libdatasrc_memory_la_SOURCES = memory_messages.h memory_messages.cc EXTRA_DIST = rdata_serialization_priv.cc diff --git a/src/lib/datasrc/memory/load_action.h b/src/lib/datasrc/memory/load_action.h new file mode 100644 index 0000000000..e5fe004a46 --- /dev/null +++ b/src/lib/datasrc/memory/load_action.h @@ -0,0 +1,42 @@ +// 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 LOAD_ACTION_H +#define LOAD_ACTION_H + +#include + +namespace isc { +// Forward declarations +namespace util{ +class MemorySegment; +} +namespace datasrc { +namespace memory { +class ZoneData; + +/// \brief Callback to load data into the memory +/// +/// This callback should create new ZoneData (allocated from the passed +/// memory segment) and fill it with relevant loaded data. The caller +/// of the callback takes ownership of the ZoneData. +/// +/// It must not return NULL. +typedef boost::function LoadAction; + +} +} +} + +#endif diff --git a/src/lib/datasrc/memory/zone_reloader.h b/src/lib/datasrc/memory/zone_reloader.h index 70572f7180..b1672377cb 100644 --- a/src/lib/datasrc/memory/zone_reloader.h +++ b/src/lib/datasrc/memory/zone_reloader.h @@ -12,16 +12,15 @@ // 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 + +#include "load_action.h" + #include #include -#include - namespace isc { -// Forward declarations -namespace util{ -class MemorySegment; -} namespace datasrc { namespace memory { class ZoneData; @@ -81,15 +80,6 @@ public: virtual void cleanup() = 0; }; -/// \brief Callback to load data into the memory -/// -/// This callback should create new ZoneData (allocated from the passed -/// memory segment) and fill it with relevant loaded data. The caller -/// of the callback takes ownership of the ZoneData. -/// -/// It must not return NULL. -typedef boost::function LoadAction; - /// \brief Reloader implementation which loads data locally. /// /// This implementation prepares a clean zone data and lets one callback @@ -147,3 +137,5 @@ private: } } } + +#endif diff --git a/src/lib/datasrc/memory/zone_table_segment.h b/src/lib/datasrc/memory/zone_table_segment.h index 3c927e7944..d05af58112 100644 --- a/src/lib/datasrc/memory/zone_table_segment.h +++ b/src/lib/datasrc/memory/zone_table_segment.h @@ -16,6 +16,7 @@ #define __ZONE_TABLE_SEGMENT_H__ #include +#include "load_action.h" #include #include @@ -24,8 +25,14 @@ #include namespace isc { +// Some forward declarations +namespace dns { +class Name; +class RRClass; +} namespace datasrc { namespace memory { +class ZoneReloader; /// \brief Memory-management independent entry point that contains a /// pointer to a zone table in memory. @@ -121,6 +128,18 @@ public: /// /// \param segment The segment to destroy. static void destroy(ZoneTableSegment* segment); + + /// \brief Create a reloader corresponding to this segment + /// + /// This creates a new reloader that can be used to reload zones + /// inside this zone table segment. + /// + /// \param loadAction Callback to provide the actual data. + /// \param origin The origin of the zone to reload. + /// \param rrclass The class of the zone to reload. + virtual ZoneReloader* getZoneReloader(const LoadAction& loadAction, + const dns::Name& origin, + const dns::RRClass& rrclass) = 0; }; } // namespace memory diff --git a/src/lib/datasrc/memory/zone_table_segment_local.h b/src/lib/datasrc/memory/zone_table_segment_local.h index de776a9036..b6b76f9fdf 100644 --- a/src/lib/datasrc/memory/zone_table_segment_local.h +++ b/src/lib/datasrc/memory/zone_table_segment_local.h @@ -54,6 +54,10 @@ public: /// implementation (a MemorySegmentLocal instance). virtual isc::util::MemorySegment& getMemorySegment(); + /// \brief Concrete implementation of ZoneTableSegment::getZoneReloader + virtual ZoneReloader* getZoneReloader(const LoadAction& loadAction, + const dns::Name& origin, + const dns::RRClass& rrclass); private: ZoneTableHeader header_; isc::util::MemorySegmentLocal mem_sgmt_;