}
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() {
return (s.str());
}
-DCfgContextBasePtr
+ConfigPtr
CtrlAgentCfgMgr::createNewContext() {
- return (DCfgContextBasePtr(new CtrlAgentCfgContext()));
+ return (ConfigPtr(new CtrlAgentCfgContext()));
}
isc::data::ConstElementPtr
/// 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
/// 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
/// 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.
#include <agent/ca_process.h>
#include <agent/ca_command_mgr.h>
#include <agent/parser_context.h>
+#include <boost/bind.hpp>
using namespace isc::process;
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);
using namespace isc::agent;
using namespace isc::data;
-using namespace isc::dhcp;
using namespace isc::hooks;
using namespace isc::process;
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);
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()));
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
/// 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();
/// @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
/// 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.
///
/// 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
/// @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
protected:
/// @brief Copy constructor
- DScalarContext(const DScalarContext& rhs) : DCfgContextBase(rhs) {
+ DScalarContext(const DScalarContext& rhs) : ConfigBase(rhs) {
}
private:
namespace isc {
namespace process {
-// *********************** DCfgContextBase *************************
-
-DCfgContextBase::DCfgContextBase() {
- }
-
-DCfgContextBase::~DCfgContextBase() {
-}
-
// *********************** DCfgMgrBase *************************
-DCfgMgrBase::DCfgMgrBase(DCfgContextBasePtr context) {
+DCfgMgrBase::DCfgMgrBase(ConfigPtr context) {
setContext(context);
}
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");
}
// 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.
#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 {
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
/// 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
///
/// will use for storing parsed results.
///
/// @throw throws DCfgMgrBaseError if context is null
- DCfgMgrBase(DCfgContextBasePtr context);
+ DCfgMgrBase(ConfigPtr context);
/// @brief Destructor
virtual ~DCfgMgrBase();
/// @brief Fetches the configuration context.
///
/// @return returns a pointer reference to the configuration context.
- DCfgContextBasePtr& getContext() {
+ ConfigPtr& getContext() {
return (context_);
}
/// 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();
/// 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.
///
private:
/// @brief Pointer to the configuration context instance.
- DCfgContextBasePtr context_;
+ ConfigPtr context_;
};
/// @brief Defines a shared pointer to 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
}
/// @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.
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.
#include <process/io_service_signal.h>
#include <process/testutils/d_test_stubs.h>
+#include <boost/bind.hpp>
#include <gtest/gtest.h>
#include <queue>
#include <process/testutils/d_test_stubs.h>
#include <process/daemon.h>
#include <cc/command_interpreter.h>
+#include <boost/bind.hpp>
using namespace boost::asio;
return (p);
}
-DCfgContextBasePtr
+ConfigPtr
DControllerTest::getContext() {
- DCfgContextBasePtr p;
+ ConfigPtr p;
if (getCfgMgr()) {
p = getCfgMgr()->getContext();
}
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
//************************** 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
///
/// @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_;
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
/// 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
/// @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
}
/// @todo
- virtual DCfgContextBasePtr createNewContext();
+ virtual ConfigPtr createNewContext();
};
/// @brief Defines a pointer to DStubCfgMgr.