diff --git a/configure.ac b/configure.ac index 0c19f0c023..2d7b098732 100644 --- a/configure.ac +++ b/configure.ac @@ -187,6 +187,20 @@ for retry in "none" "--std=c++11" "--std=c++0x" "--std=c++1x" "fail"; do [AC_MSG_RESULT([no]) continue]) + AC_MSG_CHECKING(variadic template support) + feature="variadic template" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [template + struct A { + void foo(Args... myargs) { return; }; + };], + [A<> a; + a.foo();])], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + continue]) + AC_MSG_CHECKING(lambda support) feature="lambda" AC_COMPILE_IFELSE( diff --git a/src/lib/cc/Makefile.am b/src/lib/cc/Makefile.am index cbce1325e1..8fd120b84a 100644 --- a/src/lib/cc/Makefile.am +++ b/src/lib/cc/Makefile.am @@ -6,7 +6,7 @@ AM_CXXFLAGS = $(KEA_CXXFLAGS) lib_LTLIBRARIES = libkea-cc.la libkea_cc_la_SOURCES = data.cc data.h -libkea_cc_la_SOURCES += dhcp_config_error.h +libkea_cc_la_SOURCES += cfg_to_element.h dhcp_config_error.h libkea_cc_la_SOURCES += command_interpreter.cc command_interpreter.h libkea_cc_la_SOURCES += simple_parser.cc simple_parser.h @@ -18,7 +18,7 @@ libkea_cc_la_LDFLAGS = -no-undefined -version-info 1:0:0 # Since data.h is now used in the hooks interface, it needs to be # installed on target system. libkea_cc_includedir = $(pkgincludedir)/cc -libkea_cc_include_HEADERS = data.h dhcp_config_error.h +libkea_cc_include_HEADERS = cfg_to_element.h data.h dhcp_config_error.h EXTRA_DIST = cc.dox diff --git a/src/lib/cc/cfg_to_element.h b/src/lib/cc/cfg_to_element.h new file mode 100644 index 0000000000..3fc8214751 --- /dev/null +++ b/src/lib/cc/cfg_to_element.h @@ -0,0 +1,48 @@ +// Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef CFG_TO_ELEMENT_H +#define CFG_TO_ELEMENT_H + +#include +#include + +namespace isc { + +/// @brief Cannot unparse error +/// +/// This exception is expected to be thrown when toElement fails +/// and to skip flawed elements is not wanted. +class ToElementError : public isc::Exception { +public: + ToElementError(const char* file, size_t line, const char* what) : + isc::Exception(file, line, what) { }; +}; + +namespace data { + +/// @brief Abstract class for configuration Cfg_* classes +/// +struct CfgToElement { + /// Destructor + virtual ~CfgToElement() { } + + /// @brief Unparse a configuration objet + /// + /// Returns an element which must parse into the same objet, 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; +}; + +}; // namespace isc::dhcp +}; // namespace isc + +#endif // CFG_TO_ELEMENT_H diff --git a/src/lib/dhcpsrv/libdhcpsrv.dox b/src/lib/dhcpsrv/libdhcpsrv.dox index c7d56a1314..7097b908aa 100644 --- a/src/lib/dhcpsrv/libdhcpsrv.dox +++ b/src/lib/dhcpsrv/libdhcpsrv.dox @@ -1,4 +1,4 @@ -// Copyright (C) 2012-2016 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2012-2017 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -79,6 +79,15 @@ configuration. For example: the value of 1 identifies an immediate predecessor of the current configuration, the value of 2 identifies the one that occurred before it etc. +All configuration classes are derived from the abstract base class +\ref isc::data::CfgToElement and define the toElement virtual method +which returns a \ref isc::data::ConstElementPtr which must be +parsed into the same object, i.e. fullfil this property: +@code +for all valid C: parse(parse(C)->toElement()) == parse(C) +@endcode + + @section hostmgr Host Manager Host Manager implemented by the \ref isc::dhcp::HostMgr is a singleton object