From: Tomek Mrugalski Date: Fri, 28 Sep 2018 19:18:47 +0000 (+0200) Subject: [#6,!54] Removed DCfgContextBase class. X-Git-Tag: 128-netconf-config_base~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f0341f0a0935be873dc242b95d237b1ced8db4d6;p=thirdparty%2Fkea.git [#6,!54] Removed DCfgContextBase class. --- diff --git a/src/bin/agent/ca_cfg_mgr.cc b/src/bin/agent/ca_cfg_mgr.cc index 166defde41..9086457e02 100644 --- a/src/bin/agent/ca_cfg_mgr.cc +++ b/src/bin/agent/ca_cfg_mgr.cc @@ -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 diff --git a/src/bin/agent/ca_cfg_mgr.h b/src/bin/agent/ca_cfg_mgr.h index c0a0e4765a..830b554947 100644 --- a/src/bin/agent/ca_cfg_mgr.h +++ b/src/bin/agent/ca_cfg_mgr.h @@ -27,8 +27,8 @@ typedef boost::shared_ptr 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. diff --git a/src/bin/agent/ca_controller.cc b/src/bin/agent/ca_controller.cc index 02ad66ac9d..11920670c9 100644 --- a/src/bin/agent/ca_controller.cc +++ b/src/bin/agent/ca_controller.cc @@ -10,6 +10,7 @@ #include #include #include +#include using namespace isc::process; diff --git a/src/bin/agent/ca_process.cc b/src/bin/agent/ca_process.cc index 0e96ceb6d4..e789ceb182 100644 --- a/src/bin/agent/ca_process.cc +++ b/src/bin/agent/ca_process.cc @@ -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(base_ctx); diff --git a/src/bin/agent/tests/ca_cfg_mgr_unittests.cc b/src/bin/agent/tests/ca_cfg_mgr_unittests.cc index d4e3ab10c1..f49035b31e 100644 --- a/src/bin/agent/tests/ca_cfg_mgr_unittests.cc +++ b/src/bin/agent/tests/ca_cfg_mgr_unittests.cc @@ -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(copy_base); ASSERT_TRUE(copy); diff --git a/src/bin/d2/d2_cfg_mgr.cc b/src/bin/d2/d2_cfg_mgr.cc index fd16344185..9c172ce098 100644 --- a/src/bin/d2/d2_cfg_mgr.cc +++ b/src/bin/d2/d2_cfg_mgr.cc @@ -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 diff --git a/src/bin/d2/d2_cfg_mgr.h b/src/bin/d2/d2_cfg_mgr.h index 1f67eec57b..83f9d167c8 100644 --- a/src/bin/d2/d2_cfg_mgr.h +++ b/src/bin/d2/d2_cfg_mgr.h @@ -29,8 +29,8 @@ typedef boost::shared_ptr 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. diff --git a/src/bin/d2/d2_config.h b/src/bin/d2/d2_config.h index 51a9d4c515..97d754d04e 100644 --- a/src/bin/d2/d2_config.h +++ b/src/bin/d2/d2_config.h @@ -701,7 +701,7 @@ typedef boost::shared_ptr 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: diff --git a/src/lib/process/d_cfg_mgr.cc b/src/lib/process/d_cfg_mgr.cc index b8fdb543c5..800b7751bd 100644 --- a/src/lib/process/d_cfg_mgr.cc +++ b/src/lib/process/d_cfg_mgr.cc @@ -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. diff --git a/src/lib/process/d_cfg_mgr.h b/src/lib/process/d_cfg_mgr.h index 89decf0c08..dcaa98345e 100644 --- a/src/lib/process/d_cfg_mgr.h +++ b/src/lib/process/d_cfg_mgr.h @@ -12,19 +12,11 @@ #include #include #include -#include #include #include #include -// 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 DCfgContextBasePtr; +// typedef boost::shared_ptr 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 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. diff --git a/src/lib/process/tests/d_cfg_mgr_unittests.cc b/src/lib/process/tests/d_cfg_mgr_unittests.cc index 14ed0feb01..fa5ad7fcd7 100644 --- a/src/lib/process/tests/d_cfg_mgr_unittests.cc +++ b/src/lib/process/tests/d_cfg_mgr_unittests.cc @@ -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. diff --git a/src/lib/process/tests/io_service_signal_unittests.cc b/src/lib/process/tests/io_service_signal_unittests.cc index 4f67f8bbcd..3a9bb711f9 100644 --- a/src/lib/process/tests/io_service_signal_unittests.cc +++ b/src/lib/process/tests/io_service_signal_unittests.cc @@ -10,6 +10,7 @@ #include #include +#include #include #include diff --git a/src/lib/process/testutils/d_test_stubs.cc b/src/lib/process/testutils/d_test_stubs.cc index ed15e0a854..be0ff5610f 100644 --- a/src/lib/process/testutils/d_test_stubs.cc +++ b/src/lib/process/testutils/d_test_stubs.cc @@ -10,6 +10,7 @@ #include #include #include +#include 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 diff --git a/src/lib/process/testutils/d_test_stubs.h b/src/lib/process/testutils/d_test_stubs.h index 505de4880a..e3c5658658 100644 --- a/src/lib/process/testutils/d_test_stubs.h +++ b/src/lib/process/testutils/d_test_stubs.h @@ -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 ObjectStorage; -typedef boost::shared_ptr 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 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.