mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-31 05:55:28 +00:00
[master] Merged trac1205a (unparse design)
This commit is contained in:
14
configure.ac
14
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<typename ... Args>
|
||||
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(
|
||||
|
@@ -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
|
||||
|
||||
|
48
src/lib/cc/cfg_to_element.h
Normal file
48
src/lib/cc/cfg_to_element.h
Normal file
@@ -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 <exceptions/exceptions.h>
|
||||
#include <cc/data.h>
|
||||
|
||||
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
|
@@ -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
|
||||
|
Reference in New Issue
Block a user