diff --git a/src/lib/datasrc/Makefile.am b/src/lib/datasrc/Makefile.am index f4e768aafc..911d2f525c 100644 --- a/src/lib/datasrc/Makefile.am +++ b/src/lib/datasrc/Makefile.am @@ -31,7 +31,7 @@ libb10_datasrc_la_SOURCES += zonetable.h zonetable.cc libb10_datasrc_la_SOURCES += zone.h zone_finder.cc zone_finder_context.cc libb10_datasrc_la_SOURCES += result.h libb10_datasrc_la_SOURCES += logger.h logger.cc -libb10_datasrc_la_SOURCES += client.h iterator.h +libb10_datasrc_la_SOURCES += client.h client.cc iterator.h libb10_datasrc_la_SOURCES += database.h database.cc libb10_datasrc_la_SOURCES += factory.h factory.cc libb10_datasrc_la_SOURCES += client_list.h client_list.cc diff --git a/src/lib/datasrc/client.cc b/src/lib/datasrc/client.cc new file mode 100644 index 0000000000..e9db6bb072 --- /dev/null +++ b/src/lib/datasrc/client.cc @@ -0,0 +1,49 @@ +// 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 + +#include + +/// This file defines a few default implementations for methods. +/// +/// While some of the detail of the API are worked out, we define +/// default implementations to ease development for some of the +/// more tentative methods (those that are not (yet) pure virtual) +/// They should all throw NotImplemented + +namespace isc { +namespace datasrc { + +ZoneIteratorPtr +DataSourceClient::getIterator(const isc::dns::Name&, bool) const { + isc_throw(isc::NotImplemented, + "Data source doesn't support iteration"); +} + +unsigned int +DataSourceClient::getZoneCount() const { + isc_throw(isc::NotImplemented, + "Data source doesn't support getZoneCount"); +} + +bool +DataSourceClient::createZone(const dns::Name&) { + isc_throw(isc::NotImplemented, + "Data source doesn't support addZone"); +} + + +} // end namespace datasrc +} // end namespace isc diff --git a/src/lib/datasrc/client.h b/src/lib/datasrc/client.h index 33d1faa997..f65d87dd95 100644 --- a/src/lib/datasrc/client.h +++ b/src/lib/datasrc/client.h @@ -20,8 +20,6 @@ #include #include -#include - #include /// \file @@ -225,15 +223,7 @@ public: /// adjusted to the lowest one found. /// \return Pointer to the iterator. virtual ZoneIteratorPtr getIterator(const isc::dns::Name& name, - bool separate_rrs = false) const { - // This is here to both document the parameter in doxygen (therefore it - // needs a name) and avoid unused parameter warning. - static_cast(name); - static_cast(separate_rrs); - - isc_throw(isc::NotImplemented, - "Data source doesn't support iteration"); - } + bool separate_rrs = false) const; /// Return an updater to make updates to a specific zone. /// @@ -368,16 +358,15 @@ public: /// This is an optional convenience method, currently only implemented /// by the InMemory datasource. By default, it throws NotImplemented /// + /// \note This is a tentative API, and this method is likely to change + /// or be removed in the near future. For that reason, it currently + /// provides a default implementation that throws NotImplemented. + /// /// \exception NotImplemented Thrown if this method is not supported /// by the datasource /// - /// \note This is a tentative API, and this method may likely to be - /// removed in the near future. /// \return The number of zones known to this datasource - virtual unsigned int getZoneCount() const { - isc_throw(isc::NotImplemented, - "Data source doesn't support getZoneCount"); - } + virtual unsigned int getZoneCount() const; /// \brief Create a zone in the database /// @@ -385,7 +374,8 @@ public: /// can subsequently be filled with data (through getUpdater()). /// /// \note This is a tentative API, and this method is likely to change - /// or be removed in the near future. + /// or be removed in the near future. For that reason, it currently + /// provides a default implementation that throws NotImplemented. /// /// Apart from the two exceptions mentioned below, in theory this /// call can throw anything, depending on the implementation of @@ -397,10 +387,7 @@ public: /// while creating the zone. /// \param name The (fully qualified) name of the zone to create /// \return True if the zone was added, false if it already existed - virtual bool createZone(const dns::Name&) { - isc_throw(isc::NotImplemented, - "Data source doesn't support addZone"); - } + virtual bool createZone(const dns::Name& name); }; } }