From: Marcin Siodelski Date: Tue, 6 Dec 2016 18:59:52 +0000 (+0100) Subject: [3175] Moved StateModel class from D2 to libkea-util. X-Git-Tag: trac5077_base~10^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ab7c9a978bc3c6c71e59fce7ea5dec04a91bfaa2;p=thirdparty%2Fkea.git [3175] Moved StateModel class from D2 to libkea-util. --- diff --git a/src/bin/d2/Makefile.am b/src/bin/d2/Makefile.am index 17c240f498..895865e4da 100644 --- a/src/bin/d2/Makefile.am +++ b/src/bin/d2/Makefile.am @@ -69,11 +69,9 @@ libd2_la_SOURCES += d2_update_message.cc d2_update_message.h libd2_la_SOURCES += d2_update_mgr.cc d2_update_mgr.h libd2_la_SOURCES += d2_zone.cc d2_zone.h libd2_la_SOURCES += dns_client.cc dns_client.h -libd2_la_SOURCES += labeled_value.cc labeled_value.h libd2_la_SOURCES += nc_add.cc nc_add.h libd2_la_SOURCES += nc_remove.cc nc_remove.h libd2_la_SOURCES += nc_trans.cc nc_trans.h -libd2_la_SOURCES += state_model.cc state_model.h libd2_la_SOURCES += d2_controller.cc d2_controller.h nodist_libd2_la_SOURCES = d2_messages.h d2_messages.cc diff --git a/src/bin/d2/d2.dox b/src/bin/d2/d2.dox index 518898e5d5..8e92fd732e 100644 --- a/src/bin/d2/d2.dox +++ b/src/bin/d2/d2.dox @@ -215,7 +215,7 @@ The transaction classes are shown in the following diagram: - isc::d2::NameAddTransaction - carries out a @c NameChangeRequest to add entries - isc::d2::NameRemoveTransaction - carries out a @c NameChangeRequest to remove entries -- isc::d2::StateModel - abstract state model described in @ref d2StateModel +- isc::util::StateModel - abstract state model described in @ref d2StateModel The state models for these two transactions implement DDNS with conflict resolution as described in RFC 4703. @@ -244,7 +244,7 @@ a common library. @image html state_model_classes.svg "State Model Classes" -- isc::d2::StateModel - provides the mechanics for executing a state model +- isc::util::StateModel - provides the mechanics for executing a state model described by a dictionary events and states. It provides methods to: - initialize the model - constructs the dictionary of events and states - start the model - sets the model to its initial state, posts a "start" diff --git a/src/bin/d2/nc_trans.cc b/src/bin/d2/nc_trans.cc index f0ac67d537..793410d368 100644 --- a/src/bin/d2/nc_trans.cc +++ b/src/bin/d2/nc_trans.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2016 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 @@ -12,6 +12,8 @@ #include +using namespace isc::util; + namespace isc { namespace d2 { diff --git a/src/bin/d2/nc_trans.h b/src/bin/d2/nc_trans.h index 4fc70e9cc2..77f8fb3fb7 100644 --- a/src/bin/d2/nc_trans.h +++ b/src/bin/d2/nc_trans.h @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2016 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 @@ -13,9 +13,9 @@ #include #include #include -#include #include #include +#include #include #include @@ -74,7 +74,7 @@ typedef isc::dhcp_ddns::D2Dhcid TransactionKey; /// as needed, but it must support the common set. NameChangeTransaction /// does not supply any state handlers. These are the sole responsibility of /// derivations. -class NameChangeTransaction : public DNSClient::Callback, public StateModel { +class NameChangeTransaction : public DNSClient::Callback, public util::StateModel { public: //@{ States common to all transactions. diff --git a/src/bin/d2/tests/Makefile.am b/src/bin/d2/tests/Makefile.am index 7ab1c65fe7..a28ed6e863 100644 --- a/src/bin/d2/tests/Makefile.am +++ b/src/bin/d2/tests/Makefile.am @@ -50,12 +50,10 @@ d2_unittests_SOURCES += d2_update_message_unittests.cc d2_unittests_SOURCES += d2_update_mgr_unittests.cc d2_unittests_SOURCES += d2_zone_unittests.cc d2_unittests_SOURCES += dns_client_unittests.cc -d2_unittests_SOURCES += labeled_value_unittests.cc d2_unittests_SOURCES += nc_add_unittests.cc d2_unittests_SOURCES += nc_remove_unittests.cc d2_unittests_SOURCES += nc_test_utils.cc nc_test_utils.h d2_unittests_SOURCES += nc_trans_unittests.cc -d2_unittests_SOURCES += state_model_unittests.cc d2_unittests_SOURCES += d2_controller_unittests.cc d2_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) diff --git a/src/bin/d2/tests/d2_update_mgr_unittests.cc b/src/bin/d2/tests/d2_update_mgr_unittests.cc index 25bfe96fe2..b1492ca3c4 100644 --- a/src/bin/d2/tests/d2_update_mgr_unittests.cc +++ b/src/bin/d2/tests/d2_update_mgr_unittests.cc @@ -24,6 +24,7 @@ using namespace isc; using namespace isc::dhcp_ddns; using namespace isc::d2; using namespace isc::process; +using namespace isc::util; namespace { diff --git a/src/bin/d2/tests/nc_add_unittests.cc b/src/bin/d2/tests/nc_add_unittests.cc index 6d17ba0f81..9bc90aa935 100644 --- a/src/bin/d2/tests/nc_add_unittests.cc +++ b/src/bin/d2/tests/nc_add_unittests.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2016 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 @@ -20,6 +20,7 @@ using namespace std; using namespace isc; using namespace isc::d2; +using namespace isc::util; namespace { diff --git a/src/bin/d2/tests/nc_remove_unittests.cc b/src/bin/d2/tests/nc_remove_unittests.cc index 71b996abf6..0b8c07f808 100644 --- a/src/bin/d2/tests/nc_remove_unittests.cc +++ b/src/bin/d2/tests/nc_remove_unittests.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2016 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 @@ -20,6 +20,8 @@ using namespace std; using namespace isc; using namespace isc::d2; +using namespace isc::util; + namespace { diff --git a/src/bin/d2/tests/nc_trans_unittests.cc b/src/bin/d2/tests/nc_trans_unittests.cc index a4fe05dc0f..ff0179581d 100644 --- a/src/bin/d2/tests/nc_trans_unittests.cc +++ b/src/bin/d2/tests/nc_trans_unittests.cc @@ -24,6 +24,7 @@ using namespace std; using namespace isc; using namespace isc::d2; +using namespace isc::util; using namespace boost::posix_time; namespace { diff --git a/src/lib/util/Makefile.am b/src/lib/util/Makefile.am index 2f2b5350b4..e897fe743f 100644 --- a/src/lib/util/Makefile.am +++ b/src/lib/util/Makefile.am @@ -8,11 +8,10 @@ AM_CXXFLAGS = $(KEA_CXXFLAGS) lib_LTLIBRARIES = libkea-util.la libkea_util_la_SOURCES = boost_time_utils.h boost_time_utils.cc +libkea_util_la_SOURCES += buffer.h io_utilities.h libkea_util_la_SOURCES += csv_file.h csv_file.cc libkea_util_la_SOURCES += filename.h filename.cc -libkea_util_la_SOURCES += strutil.h strutil.cc -libkea_util_la_SOURCES += buffer.h io_utilities.h -libkea_util_la_SOURCES += time_utilities.h time_utilities.cc +libkea_util_la_SOURCES += labeled_value.h labeled_value.cc libkea_util_la_SOURCES += memory_segment.h libkea_util_la_SOURCES += memory_segment_local.h memory_segment_local.cc libkea_util_la_SOURCES += optional_value.h @@ -22,8 +21,11 @@ libkea_util_la_SOURCES += process_spawn.h process_spawn.cc libkea_util_la_SOURCES += range_utilities.h libkea_util_la_SOURCES += signal_set.cc signal_set.h libkea_util_la_SOURCES += staged_value.h +libkea_util_la_SOURCES += state_model.cc state_model.h libkea_util_la_SOURCES += stopwatch.cc stopwatch.h libkea_util_la_SOURCES += stopwatch_impl.cc stopwatch_impl.h +libkea_util_la_SOURCES += strutil.h strutil.cc +libkea_util_la_SOURCES += time_utilities.h time_utilities.cc libkea_util_la_SOURCES += versioned_csv_file.h versioned_csv_file.cc libkea_util_la_SOURCES += watch_socket.cc watch_socket.h libkea_util_la_SOURCES += encode/base16_from_binary.h diff --git a/src/bin/d2/labeled_value.cc b/src/lib/util/labeled_value.cc similarity index 95% rename from src/bin/d2/labeled_value.cc rename to src/lib/util/labeled_value.cc index 6483b9453c..137c639e0c 100644 --- a/src/bin/d2/labeled_value.cc +++ b/src/lib/util/labeled_value.cc @@ -1,13 +1,13 @@ -// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2016 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/. -#include +#include namespace isc { -namespace d2 { +namespace util { /**************************** LabeledValue ****************************/ @@ -111,5 +111,5 @@ LabeledValueSet::getLabel(const int value) const { return (std::string(UNDEFINED_LABEL)); } -} // namespace isc::d2 +} // namespace isc::util } // namespace isc diff --git a/src/bin/d2/labeled_value.h b/src/lib/util/labeled_value.h similarity index 98% rename from src/bin/d2/labeled_value.h rename to src/lib/util/labeled_value.h index baf2f1cdbd..e85b537904 100644 --- a/src/bin/d2/labeled_value.h +++ b/src/lib/util/labeled_value.h @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2016 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 @@ -18,7 +18,7 @@ /// LabeledValueSet. namespace isc { -namespace d2 { +namespace util { /// @brief Thrown if an error is encountered handling a LabeledValue. class LabeledValueError : public isc::Exception { @@ -171,6 +171,6 @@ private: LabeledValueMap map_; }; -} // namespace isc::d2 +} // namespace isc::util } // namespace isc #endif diff --git a/src/bin/d2/state_model.cc b/src/lib/util/state_model.cc similarity index 98% rename from src/bin/d2/state_model.cc rename to src/lib/util/state_model.cc index 57f8e0948c..80c163b32e 100644 --- a/src/bin/d2/state_model.cc +++ b/src/lib/util/state_model.cc @@ -1,18 +1,16 @@ -// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2016 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/. #include - -#include -#include - +#include +#include #include namespace isc { -namespace d2 { +namespace util { /********************************** State *******************************/ @@ -377,5 +375,5 @@ StateModel::getPrevContextStr() const { return(stream.str()); } -} // namespace isc::d2 +} // namespace isc::util } // namespace isc diff --git a/src/bin/d2/state_model.h b/src/lib/util/state_model.h similarity index 99% rename from src/bin/d2/state_model.h rename to src/lib/util/state_model.h index 8b07bd0335..832670b02d 100644 --- a/src/bin/d2/state_model.h +++ b/src/lib/util/state_model.h @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2016 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 @@ -10,17 +10,14 @@ /// @file state_model.h This file defines the class StateModel. #include -#include -#include -#include -#include - +#include +#include #include #include #include namespace isc { -namespace d2 { +namespace util { /// @brief Thrown if the state machine encounters a general error. class StateModelError : public isc::Exception { @@ -666,6 +663,6 @@ private: /// @brief Defines a pointer to a StateModel. typedef boost::shared_ptr StateModelPtr; -} // namespace isc::d2 +} // namespace isc::util } // namespace isc #endif diff --git a/src/lib/util/tests/Makefile.am b/src/lib/util/tests/Makefile.am index 96cd389fd6..6bd1727ffb 100644 --- a/src/lib/util/tests/Makefile.am +++ b/src/lib/util/tests/Makefile.am @@ -36,6 +36,7 @@ run_unittests_SOURCES += fd_tests.cc run_unittests_SOURCES += filename_unittest.cc run_unittests_SOURCES += hex_unittest.cc run_unittests_SOURCES += io_utilities_unittest.cc +run_unittests_SOURCES += labeled_value_unittest.cc run_unittests_SOURCES += memory_segment_local_unittest.cc run_unittests_SOURCES += memory_segment_common_unittest.h run_unittests_SOURCES += memory_segment_common_unittest.cc @@ -46,6 +47,7 @@ run_unittests_SOURCES += qid_gen_unittest.cc run_unittests_SOURCES += random_number_generator_unittest.cc run_unittests_SOURCES += socketsession_unittest.cc run_unittests_SOURCES += staged_value_unittest.cc +run_unittests_SOURCES += state_model_unittest.cc run_unittests_SOURCES += strutil_unittest.cc run_unittests_SOURCES += time_utilities_unittest.cc run_unittests_SOURCES += range_utilities_unittest.cc diff --git a/src/bin/d2/tests/labeled_value_unittests.cc b/src/lib/util/tests/labeled_value_unittest.cc similarity index 96% rename from src/bin/d2/tests/labeled_value_unittests.cc rename to src/lib/util/tests/labeled_value_unittest.cc index a13e20b5aa..5ef6af59d0 100644 --- a/src/bin/d2/tests/labeled_value_unittests.cc +++ b/src/lib/util/tests/labeled_value_unittest.cc @@ -1,16 +1,16 @@ -// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2016 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/. -#include +#include #include using namespace std; using namespace isc; -using namespace isc::d2; +using namespace isc::util; namespace { diff --git a/src/bin/d2/tests/state_model_unittests.cc b/src/lib/util/tests/state_model_unittest.cc similarity index 99% rename from src/bin/d2/tests/state_model_unittests.cc rename to src/lib/util/tests/state_model_unittest.cc index d812bff243..5dfcd7be36 100644 --- a/src/bin/d2/tests/state_model_unittests.cc +++ b/src/lib/util/tests/state_model_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2013-2016 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 @@ -6,7 +6,7 @@ #include -#include +#include #include #include @@ -14,7 +14,7 @@ using namespace std; using namespace isc; -using namespace isc::d2; +using namespace isc::util; namespace {