Commit f0341f0a authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰

[#6,!54] Removed DCfgContextBase class.

parent 7a035096
......@@ -24,13 +24,13 @@ CtrlAgentCfgContext::CtrlAgentCfgContext()
}
CtrlAgentCfgContext::CtrlAgentCfgContext(const CtrlAgentCfgContext& orig)
: DCfgContextBase(), ctrl_sockets_(orig.ctrl_sockets_),
: ConfigBase(), ctrl_sockets_(orig.ctrl_sockets_),
http_host_(orig.http_host_), http_port_(orig.http_port_),
hooks_config_(orig.hooks_config_) {
}
CtrlAgentCfgMgr::CtrlAgentCfgMgr()
: DCfgMgrBase(DCfgContextBasePtr(new CtrlAgentCfgContext())) {
: DCfgMgrBase(ConfigPtr(new CtrlAgentCfgContext())) {
}
CtrlAgentCfgMgr::~CtrlAgentCfgMgr() {
......@@ -59,9 +59,9 @@ CtrlAgentCfgMgr::getConfigSummary(const uint32_t /*selection*/) {
return (s.str());
}
DCfgContextBasePtr
ConfigPtr
CtrlAgentCfgMgr::createNewContext() {
return (DCfgContextBasePtr(new CtrlAgentCfgContext()));
return (ConfigPtr(new CtrlAgentCfgContext()));
}
isc::data::ConstElementPtr
......
......@@ -27,8 +27,8 @@ typedef boost::shared_ptr<CtrlAgentCfgContext> CtrlAgentCfgContextPtr;
/// It provides a single enclosure for the storage of configuration parameters
/// and any other Control Agent specific information that needs to be accessible
/// during configuration parsing as well as to the application as a whole.
/// It is derived from the context base class, DCfgContextBase.
class CtrlAgentCfgContext : public process::DCfgContextBase {
/// It is derived from the context base class, ConfigBase.
class CtrlAgentCfgContext : public process::ConfigBase {
public:
/// @brief Default constructor
......@@ -40,8 +40,8 @@ public:
/// That data is stored as ConstElementPtr (a shared pointer) to the actual data.
///
/// @return A pointer to the new clone.
virtual process::DCfgContextBasePtr clone() {
return (process::DCfgContextBasePtr(new CtrlAgentCfgContext(*this)));
virtual process::ConfigPtr clone() {
return (process::ConfigPtr(new CtrlAgentCfgContext(*this)));
}
/// @brief Returns information about control socket
......@@ -200,8 +200,8 @@ protected:
/// existing context provided the configuration process completes without
/// error.
///
/// @return Returns a DCfgContextBasePtr to the new context instance.
virtual process::DCfgContextBasePtr createNewContext();
/// @return Returns a ConfigPtr to the new context instance.
virtual process::ConfigPtr createNewContext();
};
/// @brief Defines a shared pointer to CtrlAgentCfgMgr.
......
......@@ -10,6 +10,7 @@
#include <agent/ca_process.h>
#include <agent/ca_command_mgr.h>
#include <agent/parser_context.h>
#include <boost/bind.hpp>
using namespace isc::process;
......
......@@ -115,7 +115,7 @@ CtrlAgentProcess::configure(isc::data::ConstElementPtr config_set,
ConstElementPtr answer = getCfgMgr()->simpleParseConfig(config_set,
check_only,
[this]() {
DCfgContextBasePtr base_ctx = getCfgMgr()->getContext();
ConfigPtr base_ctx = getCfgMgr()->getContext();
CtrlAgentCfgContextPtr
ctx = boost::dynamic_pointer_cast<CtrlAgentCfgContext>(base_ctx);
......
......@@ -16,7 +16,6 @@
using namespace isc::agent;
using namespace isc::data;
using namespace isc::dhcp;
using namespace isc::hooks;
using namespace isc::process;
......@@ -130,7 +129,7 @@ TEST(CtrlAgentCfgMgr, contextSocketInfoCopy) {
libs.add(exp_name, exp_param);
// Make a copy.
DCfgContextBasePtr copy_base(ctx.clone());
ConfigPtr copy_base(ctx.clone());
CtrlAgentCfgContextPtr copy = boost::dynamic_pointer_cast<CtrlAgentCfgContext>(copy_base);
ASSERT_TRUE(copy);
......
......@@ -36,7 +36,7 @@ D2CfgContext::D2CfgContext()
keys_(new TSIGKeyInfoMap()) {
}
D2CfgContext::D2CfgContext(const D2CfgContext& rhs) : DCfgContextBase(rhs) {
D2CfgContext::D2CfgContext(const D2CfgContext& rhs) : ConfigBase(rhs) {
d2_params_ = rhs.d2_params_;
if (rhs.forward_mgr_) {
forward_mgr_.reset(new DdnsDomainListMgr(rhs.forward_mgr_->getName()));
......@@ -106,15 +106,15 @@ const char* D2CfgMgr::IPV4_REV_ZONE_SUFFIX = "in-addr.arpa.";
const char* D2CfgMgr::IPV6_REV_ZONE_SUFFIX = "ip6.arpa.";
D2CfgMgr::D2CfgMgr() : DCfgMgrBase(DCfgContextBasePtr(new D2CfgContext())) {
D2CfgMgr::D2CfgMgr() : DCfgMgrBase(ConfigPtr(new D2CfgContext())) {
}
D2CfgMgr::~D2CfgMgr() {
}
DCfgContextBasePtr
ConfigPtr
D2CfgMgr::createNewContext() {
return (DCfgContextBasePtr(new D2CfgContext()));
return (ConfigPtr(new D2CfgContext()));
}
bool
......
......@@ -29,8 +29,8 @@ typedef boost::shared_ptr<D2CfgContext> D2CfgContextPtr;
/// It provides a single enclosure for the storage of configuration parameters
/// and any other DHCP-DDNS specific information that needs to be accessible
/// during configuration parsing as well as to the application as a whole.
/// It is derived from the context base class, DCfgContextBase.
class D2CfgContext : public process::DCfgContextBase {
/// It is derived from the context base class, ConfigBase.
class D2CfgContext : public process::ConfigBase {
public:
/// @brief Constructor
D2CfgContext();
......@@ -41,8 +41,8 @@ public:
/// @brief Creates a clone of this context object.
///
/// @return returns a pointer to the new clone.
virtual process::DCfgContextBasePtr clone() {
return (process::DCfgContextBasePtr(new D2CfgContext(*this)));
virtual process::ConfigPtr clone() {
return (process::ConfigPtr(new D2CfgContext(*this)));
}
/// @brief Fetches a reference to the D2Params
......@@ -289,8 +289,8 @@ protected:
/// existing context provided the configuration process completes without
/// error.
///
/// @return Returns a DCfgContextBasePtr to the new context instance.
virtual process::DCfgContextBasePtr createNewContext();
/// @return Returns a ConfigPtr to the new context instance.
virtual process::ConfigPtr createNewContext();
};
/// @brief Defines a shared pointer to D2CfgMgr.
......
......@@ -701,7 +701,7 @@ typedef boost::shared_ptr<DdnsDomainListMgr> DdnsDomainListMgrPtr;
///
/// This class implements a concrete version of the base class by supplying a
/// "clone" method.
class DScalarContext : public process::DCfgContextBase {
class DScalarContext : public process::ConfigBase {
public:
/// @brief Constructor
......@@ -715,8 +715,8 @@ public:
/// @brief Creates a clone of a DStubContext.
///
/// @return returns a pointer to the new clone.
virtual process::DCfgContextBasePtr clone() {
return (process::DCfgContextBasePtr(new DScalarContext(*this)));
virtual process::ConfigPtr clone() {
return (process::ConfigPtr(new DScalarContext(*this)));
}
/// @brief Unparse a configuration object
......@@ -728,7 +728,7 @@ public:
protected:
/// @brief Copy constructor
DScalarContext(const DScalarContext& rhs) : DCfgContextBase(rhs) {
DScalarContext(const DScalarContext& rhs) : ConfigBase(rhs) {
}
private:
......
......@@ -31,17 +31,9 @@ using namespace isc::asiolink;
namespace isc {
namespace process {
// *********************** DCfgContextBase *************************
DCfgContextBase::DCfgContextBase() {
}
DCfgContextBase::~DCfgContextBase() {
}
// *********************** DCfgMgrBase *************************
DCfgMgrBase::DCfgMgrBase(DCfgContextBasePtr context) {
DCfgMgrBase::DCfgMgrBase(ConfigPtr context) {
setContext(context);
}
......@@ -50,12 +42,12 @@ DCfgMgrBase::~DCfgMgrBase() {
void
DCfgMgrBase::resetContext() {
DCfgContextBasePtr context = createNewContext();
ConfigPtr context = createNewContext();
setContext(context);
}
void
DCfgMgrBase::setContext(DCfgContextBasePtr& context) {
DCfgMgrBase::setContext(ConfigPtr& context) {
if (!context) {
isc_throw(DCfgMgrBaseError, "DCfgMgrBase: context cannot be NULL");
}
......@@ -80,7 +72,7 @@ DCfgMgrBase::simpleParseConfig(isc::data::ConstElementPtr config_set,
// inconsistency if the parsing operation fails after the context has been
// modified. We need to preserve the original context here
// so as we can rollback changes when an error occurs.
DCfgContextBasePtr original_context = context_;
ConfigPtr original_context = context_;
resetContext();
// Answer will hold the result returned to the caller.
......
......@@ -12,19 +12,11 @@
#include <cc/user_context.h>
#include <process/config_base.h>
#include <exceptions/exceptions.h>
#include <dhcpsrv/parsers/dhcp_parsers.h>
#include <functional>
#include <stdint.h>
#include <string>
// Undefine the macro OPTIONAL which is defined in some operating
// systems but conflicts with class constant is the context base class.
#ifdef OPTIONAL
#undef OPTIONAL
#endif
namespace isc {
namespace process {
......@@ -38,9 +30,11 @@ public:
isc::Exception(file, line, what) { };
};
class DCfgContextBase;
#if 0
/// @brief Pointer to a configuration context.
typedef boost::shared_ptr<DCfgContextBase> DCfgContextBasePtr;
// typedef boost::shared_ptr<ConfigBase> ConfigPtr;
class ConfigBase;
/// @brief Abstract class that implements a container for configuration context.
/// It provides a single enclosure for the storage of configuration parameters
......@@ -56,65 +50,25 @@ typedef boost::shared_ptr<DCfgContextBase> DCfgContextBasePtr;
/// the following:
///
/// // Make a backup copy
/// DCfgContextBasePtr backup_copy(context_->clone());
/// ConfigPtr backup_copy(context_->clone());
/// :
/// // Restore from backup
/// context_ = backup_copy;
///
class DCfgContextBase : public ConfigBase {
class ConfigBase : public ConfigBase {
public:
/// @brief Constructor
DCfgContextBase();
ConfigBase();
/// @brief Destructor
virtual ~DCfgContextBase();
/// @brief Creates a clone of this context object.
///
/// As mentioned in the the class brief, derivation must supply an
/// implementation that initializes the base class storage as well as its
/// own. Typically the derivation's clone method would return the result
/// of passing "*this" into its own copy constructor:
///
/// @code
/// class DStubContext : public DCfgContextBase {
/// public:
/// :
/// // Clone calls its own copy constructor
/// virtual DCfgContextBasePtr clone() {
/// return (DCfgContextBasePtr(new DStubContext(*this)));
/// }
///
/// // Note that the copy constructor calls the base class copy ctor
/// // then initializes its additional storage.
/// DStubContext(const DStubContext& rhs) : DCfgContextBase(rhs),
/// extra_values_(new Uint32Storage(*(rhs.extra_values_))) {
/// }
/// :
/// // Here's the derivation's additional storage.
/// isc::dhcp::Uint32StoragePtr extra_values_;
/// :
/// @endcode
///
/// @return returns a pointer to the new clone.
virtual DCfgContextBasePtr clone() = 0;
/// @brief Unparse a configuration object
///
/// Returns an element which must parse into the same object, i.e.
/// @code
/// for all valid config C parse(parse(C)->toElement()) == parse(C)
/// @endcode
///
/// @return a pointer to a configuration which can be parsed into
/// the initial configuration object
virtual isc::data::ElementPtr toElement() const = 0;
virtual ~ConfigBase();
private:
/// @brief Private assignment operator to avoid potential for slicing.
DCfgContextBase& operator=(const DCfgContextBase& rhs);
ConfigBase& operator=(const ConfigBase& rhs);
};
#endif
/// @brief Configuration Manager
///
......@@ -197,7 +151,7 @@ public:
/// will use for storing parsed results.
///
/// @throw throws DCfgMgrBaseError if context is null
DCfgMgrBase(DCfgContextBasePtr context);
DCfgMgrBase(ConfigPtr context);
/// @brief Destructor
virtual ~DCfgMgrBase();
......@@ -232,7 +186,7 @@ public:
/// @brief Fetches the configuration context.
///
/// @return returns a pointer reference to the configuration context.
DCfgContextBasePtr& getContext() {
ConfigPtr& getContext() {
return (context_);
}
......@@ -265,8 +219,8 @@ protected:
/// and will replace the existing context provided the configuration
/// process completes without error.
///
/// @return Returns a DCfgContextBasePtr to the new context instance.
virtual DCfgContextBasePtr createNewContext() = 0;
/// @return Returns a ConfigPtr to the new context instance.
virtual ConfigPtr createNewContext() = 0;
/// @brief Replaces existing context with a new, empty context.
void resetContext();
......@@ -276,7 +230,7 @@ protected:
/// Replaces the existing context with the given context.
/// @param context Pointer to the new context.
/// @throw DCfgMgrBaseError if context is NULL.
void setContext(DCfgContextBasePtr& context);
void setContext(ConfigPtr& context);
/// @brief Parses actual configuration.
///
......@@ -298,7 +252,7 @@ protected:
private:
/// @brief Pointer to the configuration context instance.
DCfgContextBasePtr context_;
ConfigPtr context_;
};
/// @brief Defines a shared pointer to DCfgMgrBase.
......
......@@ -32,7 +32,7 @@ class DCtorTestCfgMgr : public DCfgMgrBase {
public:
/// @brief Constructor - Note that is passes in an empty configuration
/// pointer to the base class constructor.
DCtorTestCfgMgr() : DCfgMgrBase(DCfgContextBasePtr()) {
DCtorTestCfgMgr() : DCfgMgrBase(ConfigPtr()) {
}
/// @brief Destructor
......@@ -40,8 +40,8 @@ public:
}
/// @brief Dummy implementation as this method is abstract.
virtual DCfgContextBasePtr createNewContext() {
return (DCfgContextBasePtr());
virtual ConfigPtr createNewContext() {
return (ConfigPtr());
}
/// @brief Returns summary of configuration in the textual format.
......@@ -92,7 +92,7 @@ TEST(DCfgMgrBase, construction) {
ASSERT_NO_THROW(cfg_mgr.reset(new DStubCfgMgr()));
// Verify that the context can be retrieved and is not null.
DCfgContextBasePtr context = cfg_mgr->getContext();
ConfigPtr context = cfg_mgr->getContext();
EXPECT_TRUE(context);
// Verify that the manager can be destructed without error.
......
......@@ -10,6 +10,7 @@
#include <process/io_service_signal.h>
#include <process/testutils/d_test_stubs.h>
#include <boost/bind.hpp>
#include <gtest/gtest.h>
#include <queue>
......
......@@ -10,6 +10,7 @@
#include <process/testutils/d_test_stubs.h>
#include <process/daemon.h>
#include <cc/command_interpreter.h>
#include <boost/bind.hpp>
using namespace boost::asio;
......@@ -245,9 +246,9 @@ DControllerTest::getCfgMgr() {
return (p);
}
DCfgContextBasePtr
ConfigPtr
DControllerTest::getContext() {
DCfgContextBasePtr p;
ConfigPtr p;
if (getCfgMgr()) {
p = getCfgMgr()->getContext();
}
......@@ -269,12 +270,12 @@ DStubContext::DStubContext() {
DStubContext::~DStubContext() {
}
DCfgContextBasePtr
ConfigPtr
DStubContext::clone() {
return (DCfgContextBasePtr(new DStubContext(*this)));
return (ConfigPtr(new DStubContext(*this)));
}
DStubContext::DStubContext(const DStubContext& rhs): DCfgContextBase(rhs) {
DStubContext::DStubContext(const DStubContext& rhs): ConfigBase(rhs) {
}
isc::data::ElementPtr
......@@ -285,15 +286,15 @@ DStubContext::toElement() const {
//************************** DStubCfgMgr *************************
DStubCfgMgr::DStubCfgMgr()
: DCfgMgrBase(DCfgContextBasePtr(new DStubContext())) {
: DCfgMgrBase(ConfigPtr(new DStubContext())) {
}
DStubCfgMgr::~DStubCfgMgr() {
}
DCfgContextBasePtr
ConfigPtr
DStubCfgMgr::createNewContext() {
return (DCfgContextBasePtr (new DStubContext()));
return (ConfigPtr (new DStubContext()));
}
isc::data::ConstElementPtr
......
......@@ -542,7 +542,7 @@ public:
///
/// @return A pointer to the context which may be null if it has not yet
/// been instantiated.
DCfgContextBasePtr getContext();
ConfigPtr getContext();
/// @brief Timer used for delayed configuration file writing.
asiolink::IntervalTimerPtr write_timer_;
......@@ -554,11 +554,7 @@ public:
static const char* CFG_TEST_FILE;
};
/// @brief a collection of elements that store uint32 values
typedef isc::dhcp::ValueStorage<isc::data::ConstElementPtr> ObjectStorage;
typedef boost::shared_ptr<ObjectStorage> ObjectStoragePtr;
/// @brief Test Derivation of the DCfgContextBase class.
/// @brief Test Derivation of the ConfigBase class.
///
/// This class is used to test basic functionality of configuration context.
/// It adds an additional storage container "extra values" to mimic an
......@@ -566,7 +562,7 @@ typedef boost::shared_ptr<ObjectStorage> ObjectStoragePtr;
/// both the base class content as well as the application content is
/// correctly copied during cloning. This is vital to configuration backup
/// and rollback during configuration parsing.
class DStubContext : public DCfgContextBase {
class DStubContext : public ConfigBase {
public:
/// @brief Constructor
......@@ -578,7 +574,7 @@ public:
/// @brief Creates a clone of a DStubContext.
///
/// @return returns a pointer to the new clone.
virtual DCfgContextBasePtr clone();
virtual ConfigPtr clone();
protected:
/// @brief Copy constructor
......@@ -643,7 +639,7 @@ public:
}
/// @todo
virtual DCfgContextBasePtr createNewContext();
virtual ConfigPtr createNewContext();
};
/// @brief Defines a pointer to DStubCfgMgr.
......
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