Commit 6cb3d5c7 authored by Francis Dupont's avatar Francis Dupont
Browse files

[3859] redeclare and redefine the getVersion()

parent f78c8011
......@@ -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
......@@ -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:
///
......
......@@ -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;
......
......@@ -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
......
......@@ -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':
......
......@@ -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;
......
......@@ -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
......
......@@ -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
......
// 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");
}
};
};
......@@ -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);
......
// 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.
......
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