]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3859] redeclare and redefine the getVersion() trac3882_base
authorFrancis Dupont <fdupont@isc.org>
Fri, 22 May 2015 06:29:03 +0000 (08:29 +0200)
committerFrancis Dupont <fdupont@isc.org>
Fri, 22 May 2015 06:29:03 +0000 (08:29 +0200)
src/bin/d2/d_controller.cc
src/bin/d2/d_controller.h
src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp4/dhcp4_srv.h
src/bin/dhcp4/main.cc
src/bin/dhcp6/dhcp6_srv.cc
src/bin/dhcp6/dhcp6_srv.h
src/bin/dhcp6/main.cc
src/lib/dhcpsrv/daemon.cc
src/lib/dhcpsrv/daemon.h
src/lib/dhcpsrv/tests/daemon_unittest.cc

index 7711c8dea1702a410cef7c89a199f98ee5ca5be7..2295e0906333e44893476de8a783d4c219b00595 100644 (file)
@@ -447,19 +447,15 @@ DControllerBase::~DControllerBase() {
 // Refer to config_report so it will be embedded in the binary
 const char* const* d2_config_report = isc::detail::config_report;
 
-}; // namespace isc::d2
-
-}; // namespace isc
-
 std::string
-isc::dhcp::Daemon::getVersion(bool extended) {
+DControllerBase::getVersion(bool extended) {
     std::stringstream tmp;
 
     tmp << VERSION;
     if (extended) {
         tmp << std::endl << EXTENDED_VERSION << std::endl;
-        tmp << "linked with " << isc::log::Logger::getVersion() << std::endl;
-        tmp << "and " << isc::cryptolink::CryptoLink::getVersion()
+        tmp << "linked with " << log::Logger::getVersion() << std::endl;
+        tmp << "and " << cryptolink::CryptoLink::getVersion()
             << std::endl;
 #ifdef HAVE_MYSQL
         tmp << "database: MySQL";
@@ -475,3 +471,7 @@ isc::dhcp::Daemon::getVersion(bool extended) {
 
     return (tmp.str());
 }
+
+}; // namespace isc::d2
+
+}; // namespace isc
index 6d1c4fc18746323c5c8574d7a9d06e34e32094ab..7f730480dbf2e32eb39cce5fce6588c16c8daf80 100644 (file)
@@ -113,6 +113,10 @@ public:
     /// @brief Destructor
     virtual ~DControllerBase();
 
+    /// @brief returns Kea version on stdout and exit.
+    /// redeclaration/redefinition. @ref Daemon::getVersion())
+    static std::string getVersion(bool extended);
     /// @brief Acts as the primary entry point into the controller execution
     /// and provides the outermost application control logic:
     ///
index 8190388d39603379420f7cae7a734939c14a89e6..c39e1cd5a7864eef3be70a7cdd041e2de8527b7e 100644 (file)
@@ -2215,7 +2215,7 @@ Dhcpv4Srv::d2ClientErrorHandler(const
 const char* const* dhcp4_config_report = isc::detail::config_report;
 
 std::string
-Daemon::getVersion(bool extended) {
+Dhcpv4Srv::getVersion(bool extended) {
     std::stringstream tmp;
 
     tmp << VERSION;
index 6a05a245a7a4c73090f7c74ce68722d25e71faf7..6b70c1c29f5266bd8d521afa50b7b1a437b68526 100644 (file)
@@ -186,6 +186,10 @@ public:
     /// @brief Destructor. Used during DHCPv4 service shutdown.
     virtual ~Dhcpv4Srv();
 
+    /// @brief returns Kea version on stdout and exit.
+    /// redeclaration/redefinition. @ref Daemon::getVersion())
+    static std::string getVersion(bool extended);
     /// @brief Main server processing loop.
     ///
     /// Main server processing loop. Receives incoming packets, verifies
index bf6ce7b8905842d23ab64922e0f624426bb5d1ac..efaa4de26b872785d0789a9f8a34fadb8e52a9a7 100644 (file)
@@ -76,11 +76,11 @@ main(int argc, char* argv[]) {
             break;
 
         case 'v':
-            cout << Daemon::getVersion(false) << endl;
+            cout << Dhcpv4Srv::getVersion(false) << endl;
             return (EXIT_SUCCESS);
 
         case 'V':
-            cout << Daemon::getVersion(true) << endl;
+            cout << Dhcpv4Srv::getVersion(true) << endl;
             return (EXIT_SUCCESS);
 
         case 'p':
index ad47fb2e5651b2ad73eb7594328ad70f62587866..43ea0014fe55c282369a3033961ddf7ee8dceeaa 100644 (file)
@@ -2762,7 +2762,7 @@ Dhcpv6Srv::d2ClientErrorHandler(const
 const char* const* dhcp6_config_report = isc::detail::config_report;
 
 std::string
-Daemon::getVersion(bool extended) {
+Dhcpv6Srv::getVersion(bool extended) {
     std::stringstream tmp;
 
     tmp << VERSION;
index 0099b7ea865182cf6ace4625530f741dbf53937a..384d1a92e72fce9092993a1bc7e443d9a9c5804e 100644 (file)
@@ -77,6 +77,10 @@ public:
     /// @brief Destructor. Used during DHCPv6 service shutdown.
     virtual ~Dhcpv6Srv();
 
+    /// @brief returns Kea version on stdout and exit.
+    /// redeclaration/redefinition. @ref Daemon::getVersion())
+    static std::string getVersion(bool extended);
     /// @brief Returns server-indentifier option.
     ///
     /// @return server-id option
index 9c74921f9ad52ac313a999ac5a5fd447d8382ef2..902c3a65d3722db19fdb2c8bbdcdb76ff3ac856b 100644 (file)
@@ -78,11 +78,11 @@ main(int argc, char* argv[]) {
             break;
 
         case 'v':
-            cout << Daemon::getVersion(false) << endl;
+            cout << Dhcpv6Srv::getVersion(false) << endl;
             return (EXIT_SUCCESS);
 
         case 'V':
-            cout << Daemon::getVersion(true) << endl;
+            cout << Dhcpv6Srv::getVersion(true) << endl;
             return (EXIT_SUCCESS);
 
         case 'p': // port number
index b6ab33b51fa762f60a7e7fb456331dafd07ad3b6..2733b926cd97fcc60abac9c8e1b5af8157a3c718 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014  Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014, 2015  Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -92,5 +92,9 @@ void Daemon::loggerInit(const char* name, bool verbose) {
     isc::log::setDefaultLoggingOutput(verbose);
 }
 
+std::string Daemon::getVersion(bool /*extended*/) {
+    isc_throw(isc::NotImplemented, "Daemon::getVersion() called");
+}
+
 };
 };
index 8009a796af67edd58905d45f4cd159f14d5791bd..77664720533fb9059b5abb87e6a32d8e2d80357a 100644 (file)
@@ -153,6 +153,10 @@ public:
     /// also additional information about sources. It is expected to
     /// return extra information about dependencies and used DB backends.
     ///
+    /// As there is no static virtual methods in C++ this class method
+    /// has to be redefined in derived classes and called with the
+    /// derived class name or a child name.
+    ///
     /// @param extended print additional information?
     /// @return text string
     static std::string getVersion(bool extended);
index 059f7940a04dc23984f370397c4de623d38bd751..f9e6ccba326510337c05b98c13396b1cdcf35878 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2014, 2015 Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -27,7 +27,16 @@ using namespace isc;
 using namespace isc::dhcp;
 using namespace isc::data;
 
-std::string isc::dhcp::Daemon::getVersion(bool extended) {
+namespace isc {
+namespace dhcp {
+
+// @brief Derived Daemon class
+class DaemonImpl : public Daemon {
+public:
+    static std::string getVersion(bool extended);
+};
+
+std::string DaemonImpl::getVersion(bool extended) {
     if (extended) {
         return (std::string("EXTENDED"));
     } else {
@@ -35,6 +44,9 @@ std::string isc::dhcp::Daemon::getVersion(bool extended) {
     }
 }
 
+};
+};
+
 namespace {
 
 /// @brief Daemon Test test fixture class
@@ -105,6 +117,15 @@ TEST_F(DaemonTest, parsingConsoleOutput) {
     EXPECT_EQ("stdout" , storage->getLoggingInfo()[0].destinations_[0].output_);
 }
 
+// Test the getVersion() redefinition
+TEST_F(DaemonTest, getVersion) {
+    EXPECT_THROW(Daemon::getVersion(false), NotImplemented);
+
+    ASSERT_NO_THROW(DaemonImpl::getVersion(false));
+
+    EXPECT_EQ(DaemonImpl::getVersion(true), "EXTENDED");
+}
+
 
 // More tests will appear here as we develop Daemon class.