Commit b64a6654 authored by Michal Vaner's avatar Michal Vaner
Browse files

Move MemoryZone to memory_datasrc.{h,cc}

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac444@3937 e5f2f494-b856-4b98-b285-d166d9295462
parent a3337866
......@@ -13,6 +13,8 @@
// PERFORMANCE OF THIS SOFTWARE.
#include <dns/name.h>
#include <dns/rrclass.h>
#include <datasrc/memory_datasrc.h>
using namespace std;
......@@ -21,6 +23,39 @@ using namespace isc::dns;
namespace isc {
namespace datasrc {
struct MemoryZone::MemoryZoneImpl {
MemoryZoneImpl(const RRClass& zone_class, const Name& origin) :
zone_class_(zone_class), origin_(origin)
{}
RRClass zone_class_;
Name origin_;
};
MemoryZone::MemoryZone(const RRClass& zone_class, const Name& origin) :
impl_(new MemoryZoneImpl(zone_class, origin))
{
}
MemoryZone::~MemoryZone() {
delete impl_;
}
const Name&
MemoryZone::getOrigin() const {
return (impl_->origin_);
}
const RRClass&
MemoryZone::getClass() const {
return (impl_->zone_class_);
}
Zone::FindResult
MemoryZone::find(const Name&, const RRType&) const {
// This is a tentative implementation that always returns NXDOMAIN.
return (FindResult(NXDOMAIN, RRsetPtr()));
}
/// Implementation details for \c MemoryDataSrc hidden from the public
/// interface.
///
......
......@@ -24,6 +24,50 @@ class Name;
namespace datasrc {
/// A derived zone class intended to be used with the memory data source.
///
/// Currently this is almost empty and is only used for testing the
/// \c ZoneTable class. It will be substantially expanded, and will probably
/// moved to a separate header file.
///
/// \todo Is this really needed in header file? If it is used only inside
/// MemoryDataSrc, we could move it to .cc file and not care about the impl_.
class MemoryZone : public Zone {
///
/// \name Constructors and Destructor.
///
/// \b Note:
/// The copy constructor and the assignment operator are intentionally
/// defined as private, making this class non copyable.
//@{
private:
MemoryZone(const MemoryZone& source);
MemoryZone& operator=(const MemoryZone& source);
public:
/// \brief Constructor from zone parameters.
///
/// This constructor internally involves resource allocation, and if
/// it fails, a corresponding standard exception will be thrown.
/// It never throws an exception otherwise.
///
/// \param rrclass The RR class of the zone.
/// \param origin The origin name of the zone.
MemoryZone(const isc::dns::RRClass& rrclass, const isc::dns::Name& origin);
/// The destructor.
virtual ~MemoryZone();
//@}
virtual const isc::dns::Name& getOrigin() const;
virtual const isc::dns::RRClass& getClass() const;
virtual FindResult find(const isc::dns::Name& name,
const isc::dns::RRType& type) const;
private:
struct MemoryZoneImpl;
MemoryZoneImpl* impl_;
};
/// \brief A data source that uses in memory dedicated backend.
///
/// The \c MemoryDataSrc class represents a data source and provides a
......
......@@ -18,7 +18,6 @@
#include <utility>
#include <dns/name.h>
#include <dns/rrclass.h>
#include <datasrc/zonetable.h>
......@@ -28,39 +27,6 @@ using namespace isc::dns;
namespace isc {
namespace datasrc {
struct MemoryZone::MemoryZoneImpl {
MemoryZoneImpl(const RRClass& zone_class, const Name& origin) :
zone_class_(zone_class), origin_(origin)
{}
RRClass zone_class_;
Name origin_;
};
MemoryZone::MemoryZone(const RRClass& zone_class, const Name& origin) :
impl_(new MemoryZoneImpl(zone_class, origin))
{
}
MemoryZone::~MemoryZone() {
delete impl_;
}
const Name&
MemoryZone::getOrigin() const {
return (impl_->origin_);
}
const RRClass&
MemoryZone::getClass() const {
return (impl_->zone_class_);
}
Zone::FindResult
MemoryZone::find(const Name&, const RRType&) const {
// This is a tentative implementation that always returns NXDOMAIN.
return (FindResult(NXDOMAIN, RRsetPtr()));
}
// This is a temporary, inefficient implementation using std::map and handmade
// iteration to realize longest match.
......
......@@ -29,47 +29,6 @@ class RRClass;
namespace datasrc {
/// A derived zone class intended to be used with the memory data source.
///
/// Currently this is almost empty and is only used for testing the
/// \c ZoneTable class. It will be substantially expanded, and will probably
/// moved to a separate header file.
class MemoryZone : public Zone {
///
/// \name Constructors and Destructor.
///
/// \b Note:
/// The copy constructor and the assignment operator are intentionally
/// defined as private, making this class non copyable.
//@{
private:
MemoryZone(const MemoryZone& source);
MemoryZone& operator=(const MemoryZone& source);
public:
/// \brief Constructor from zone parameters.
///
/// This constructor internally involves resource allocation, and if
/// it fails, a corresponding standard exception will be thrown.
/// It never throws an exception otherwise.
///
/// \param rrclass The RR class of the zone.
/// \param origin The origin name of the zone.
MemoryZone(const isc::dns::RRClass& rrclass, const isc::dns::Name& origin);
/// The destructor.
virtual ~MemoryZone();
//@}
virtual const isc::dns::Name& getOrigin() const;
virtual const isc::dns::RRClass& getClass() const;
virtual FindResult find(const isc::dns::Name& name,
const isc::dns::RRType& type) const;
private:
struct MemoryZoneImpl;
MemoryZoneImpl* impl_;
};
/// \brief A set of authoritative zones.
///
/// \c ZoneTable class is primarily intended to be used as a backend for the
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment