]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#6,!54] Removed DCfgContextBase class.
authorTomek Mrugalski <tomasz@isc.org>
Fri, 28 Sep 2018 19:18:47 +0000 (21:18 +0200)
committerTomek Mrugalski <tomasz@isc.org>
Fri, 28 Sep 2018 19:18:47 +0000 (21:18 +0200)
14 files changed:
src/bin/agent/ca_cfg_mgr.cc
src/bin/agent/ca_cfg_mgr.h
src/bin/agent/ca_controller.cc
src/bin/agent/ca_process.cc
src/bin/agent/tests/ca_cfg_mgr_unittests.cc
src/bin/d2/d2_cfg_mgr.cc
src/bin/d2/d2_cfg_mgr.h
src/bin/d2/d2_config.h
src/lib/process/d_cfg_mgr.cc
src/lib/process/d_cfg_mgr.h
src/lib/process/tests/d_cfg_mgr_unittests.cc
src/lib/process/tests/io_service_signal_unittests.cc
src/lib/process/testutils/d_test_stubs.cc
src/lib/process/testutils/d_test_stubs.h

index 166defde412c288d59824ae801607212112a76c4..9086457e028d71d5d2308fb72adb1b858c9170d6 100644 (file)
@@ -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
index c0a0e4765aa4b2210113ead079cefffe85b148ee..830b55494736574b191b03b80add210611ca72c0 100644 (file)
@@ -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.
index 02ad66ac9db40d0c13eca2517888ee977300bf64..11920670c987ec849a266a3520d3de0ac6eb259f 100644 (file)
@@ -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;
 
index 0e96ceb6d40b6aa9f9cd77f482f8036b82baf1d3..e789ceb182f32a14427ea5803d645bcbf8463b19 100644 (file)
@@ -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);
 
index d4e3ab10c1d612caa3052a45f87e03f569d351ad..f49035b31eb5f11e9928b791f780dff45dd9272f 100644 (file)
@@ -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);
 
index fd16344185626cd51d41b92c3decb94a929227fb..9c172ce098752f246aeaeef0b250905be347b74f 100644 (file)
@@ -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
index 1f67eec57beb390af62a57956ee6629f6604d66a..83f9d167c8d4351a0f078432a005a018ae6e5f3b 100644 (file)
@@ -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.
index 51a9d4c515c00ab4a358fb81292bdeafae1f29b2..97d754d04e5e0955633a28d6fa69c73cecac5695 100644 (file)
@@ -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:
index b8fdb543c5f8c9362f3320d9a4dfda5aac2d3365..800b7751bd69a9fc62553caa20088194253bacc7 100644 (file)
@@ -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.
index 89decf0c08a0dd0dfc627e17e7e0174e7a6b6b26..dcaa98345e0848889aa06e938c28d3d259560eb2 100644 (file)
 #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.
index 14ed0feb010ad62272d8fdc7d64af7b43cbed23e..fa5ad7fcd714515cd79740387e0671e9eaf394c7 100644 (file)
@@ -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.
index 4f67f8bbcd70412efbec0f119e767025f4c65a2a..3a9bb711f9ea230a5c5d53f1b923e38493485db8 100644 (file)
@@ -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>
index ed15e0a854d2496cd117da53534f0a2bc371ef03..be0ff5610f64909640dfdd661a3f1d43e8876d71 100644 (file)
@@ -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
index 505de4880a0a4f888e3fc71ad3dee627deb4614c..e3c5658658d116a4b762fee757cf365255e6cd0b 100644 (file)
@@ -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.