Commit 45dcf93c authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[trac1060] Inherit MemoryDataSrc

* Inherit the MemoryDataSrc from DataSourceClient
* Small comment cleanup
* Makefile fix
* Remove extra parts of MemoryDataSrc
  - FindResult is inherited from MemoryDataSrc and it was the same
    anyway, just different name.
  - Remove the private assignment operator and copy constructor, the
    DataSourceClient is already uncopyable.
parent bf5fbf4c
......@@ -21,6 +21,7 @@ libdatasrc_la_SOURCES += memory_datasrc.h memory_datasrc.cc
libdatasrc_la_SOURCES += zone.h
libdatasrc_la_SOURCES += result.h
libdatasrc_la_SOURCES += logger.h logger.cc
libdatasrc_la_SOURCES += client.h
nodist_libdatasrc_la_SOURCES = datasrc_messages.h datasrc_messages.cc
libdatasrc_la_LIBADD = $(top_builddir)/src/lib/exceptions/libexceptions.la
......
......@@ -15,6 +15,8 @@
#ifndef __DATA_SOURCE_CLIENT_H
#define __DATA_SOURCE_CLIENT_H 1
#include <datasrc/zone.h>
namespace isc {
namespace datasrc {
......@@ -28,6 +30,9 @@ namespace datasrc {
/// we'll give them more concise names such as InMemoryClient.
///
/// This class is not copyable.
///
/// \todo This class is not complete. It needs more factory methods, for
/// accessing the whole zone, updating it, loading it, etc.
class DataSourceClient : boost::noncopyable {
public:
/// \brief A helper structure to represent the search result of
......@@ -78,12 +83,12 @@ public:
/// form of a \c FindResult object as follows:
/// - \c code: The result code of the operation.
/// - \c result::SUCCESS: A zone that gives an exact match
// is found
/// is found
/// - \c result::PARTIALMATCH: A zone whose origin is a
// super domain of \c name is found (but there is no exact match)
/// super domain of \c name is found (but there is no exact match)
/// - \c result::NOTFOUND: For all other cases.
/// - \c zone: Pointer to the found \c ZoneFinder object if one
// is found; otherwise \c NULL.
/// is found; otherwise \c NULL.
///
/// This method never throws an exception.
///
......
......@@ -20,6 +20,7 @@
#include <boost/noncopyable.hpp>
#include <datasrc/zonetable.h>
#include <datasrc/client.h>
namespace isc {
namespace dns {
......@@ -210,44 +211,13 @@ private:
/// The findZone() method takes a domain name and returns the best matching \c
/// MemoryZone in the form of (Boost) shared pointer, so that it can provide
/// the general interface for all data sources.
class MemoryDataSrc {
class MemoryDataSrc : public DataSourceClient {
public:
/// \brief A helper structure to represent the search result of
/// <code>MemoryDataSrc::find()</code>.
///
/// This is a straightforward pair of the result code and a share pointer
/// to the found zone to represent the result of \c find().
/// We use this in order to avoid overloading the return value for both
/// the result code ("success" or "not found") and the found object,
/// i.e., avoid using \c NULL to mean "not found", etc.
///
/// This is a simple value class with no internal state, so for
/// convenience we allow the applications to refer to the members
/// directly.
///
/// See the description of \c find() for the semantics of the member
/// variables.
struct FindResult {
FindResult(result::Result param_code,
const ZoneFinderPtr param_zone_finder) :
code(param_code), zone_finder(param_zone_finder)
{}
const result::Result code;
const ZoneFinderPtr zone_finder;
};
///
/// \name Constructors and Destructor.
///
/// \b Note:
/// The copy constructor and the assignment operator are intentionally
/// defined as private, making this class non copyable.
//@{
private:
MemoryDataSrc(const MemoryDataSrc& source);
MemoryDataSrc& operator=(const MemoryDataSrc& source);
public:
/// Default constructor.
///
/// This constructor internally involves resource allocation, and if
......@@ -288,20 +258,22 @@ public:
/// form of a \c FindResult object as follows:
/// - \c code: The result code of the operation.
/// - \c result::SUCCESS: A zone that gives an exact match
// is found
/// is found
/// - \c result::PARTIALMATCH: A zone whose origin is a
// super domain of \c name is found (but there is no exact match)
/// super domain of \c name is found (but there is no exact match)
/// - \c result::NOTFOUND: For all other cases.
/// - \c zone: A "Boost" shared pointer to the found \c Zone object if one
// is found; otherwise \c NULL.
/// is found; otherwise \c NULL.
///
/// This method never throws an exception.
///
/// \param name A domain name for which the search is performed.
/// \return A \c FindResult object enclosing the search result (see above).
FindResult findZone(const isc::dns::Name& name) const;
virtual FindResult findZone(const isc::dns::Name& name) const;
private:
// TODO: Do we still need the PImpl if nobody should manipulate this class
// directly any more (it should be handled trough DataSourceClient)?
class MemoryDataSrcImpl;
MemoryDataSrcImpl* impl_;
};
......
Markdown is supported
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