Parcourir la source

[3175] Moved StateModel class from D2 to libkea-util.

Marcin Siodelski il y a 8 ans
Parent
commit
ab7c9a978b

+ 0 - 2
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_update_mgr.cc d2_update_mgr.h
 libd2_la_SOURCES += d2_zone.cc d2_zone.h
 libd2_la_SOURCES += d2_zone.cc d2_zone.h
 libd2_la_SOURCES += dns_client.cc dns_client.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_add.cc nc_add.h
 libd2_la_SOURCES += nc_remove.cc nc_remove.h
 libd2_la_SOURCES += nc_remove.cc nc_remove.h
 libd2_la_SOURCES += nc_trans.cc nc_trans.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
 libd2_la_SOURCES += d2_controller.cc d2_controller.h
 
 
 nodist_libd2_la_SOURCES = d2_messages.h d2_messages.cc
 nodist_libd2_la_SOURCES = d2_messages.h d2_messages.cc

+ 2 - 2
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::NameAddTransaction - carries out a @c NameChangeRequest to add entries
 - isc::d2::NameRemoveTransaction - carries out a @c NameChangeRequest to remove 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
 The state models for these two transactions implement DDNS with conflict
 resolution as described in <a href="https://tools.ietf.org/html/rfc4703">RFC 4703</a>.
 resolution as described in <a href="https://tools.ietf.org/html/rfc4703">RFC 4703</a>.
@@ -244,7 +244,7 @@ a common library.
 
 
 @image html state_model_classes.svg "State Model Classes"
 @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:
 described by a dictionary events and states.  It provides methods to:
     - initialize the model - constructs the dictionary of events and states
     - initialize the model - constructs the dictionary of events and states
     - start the model - sets the model to its initial state, posts a "start"
     - start the model - sets the model to its initial state, posts a "start"

+ 3 - 1
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
 // 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
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -12,6 +12,8 @@
 
 
 #include <sstream>
 #include <sstream>
 
 
+using namespace isc::util;
+
 namespace isc {
 namespace isc {
 namespace d2 {
 namespace d2 {
 
 

+ 3 - 3
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
 // 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
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -13,9 +13,9 @@
 #include <exceptions/exceptions.h>
 #include <exceptions/exceptions.h>
 #include <d2/d2_cfg_mgr.h>
 #include <d2/d2_cfg_mgr.h>
 #include <d2/dns_client.h>
 #include <d2/dns_client.h>
-#include <d2/state_model.h>
 #include <dhcp_ddns/ncr_msg.h>
 #include <dhcp_ddns/ncr_msg.h>
 #include <dns/tsig.h>
 #include <dns/tsig.h>
+#include <util/state_model.h>
 
 
 #include <boost/shared_ptr.hpp>
 #include <boost/shared_ptr.hpp>
 #include <map>
 #include <map>
@@ -74,7 +74,7 @@ typedef isc::dhcp_ddns::D2Dhcid TransactionKey;
 /// as needed, but it must support the common set.  NameChangeTransaction
 /// as needed, but it must support the common set.  NameChangeTransaction
 /// does not supply any state handlers.  These are the sole responsibility of
 /// does not supply any state handlers.  These are the sole responsibility of
 /// derivations.
 /// derivations.
-class NameChangeTransaction : public DNSClient::Callback, public StateModel {
+class NameChangeTransaction : public DNSClient::Callback, public util::StateModel {
 public:
 public:
 
 
     //@{ States common to all transactions.
     //@{ States common to all transactions.

+ 0 - 2
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_update_mgr_unittests.cc
 d2_unittests_SOURCES += d2_zone_unittests.cc
 d2_unittests_SOURCES += d2_zone_unittests.cc
 d2_unittests_SOURCES += dns_client_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_add_unittests.cc
 d2_unittests_SOURCES += nc_remove_unittests.cc
 d2_unittests_SOURCES += nc_remove_unittests.cc
 d2_unittests_SOURCES += nc_test_utils.cc nc_test_utils.h
 d2_unittests_SOURCES += nc_test_utils.cc nc_test_utils.h
 d2_unittests_SOURCES += nc_trans_unittests.cc
 d2_unittests_SOURCES += nc_trans_unittests.cc
-d2_unittests_SOURCES += state_model_unittests.cc
 d2_unittests_SOURCES += d2_controller_unittests.cc
 d2_unittests_SOURCES += d2_controller_unittests.cc
 
 
 d2_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
 d2_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)

+ 1 - 0
src/bin/d2/tests/d2_update_mgr_unittests.cc

@@ -24,6 +24,7 @@ using namespace isc;
 using namespace isc::dhcp_ddns;
 using namespace isc::dhcp_ddns;
 using namespace isc::d2;
 using namespace isc::d2;
 using namespace isc::process;
 using namespace isc::process;
+using namespace isc::util;
 
 
 namespace {
 namespace {
 
 

+ 2 - 1
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
 // 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
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -20,6 +20,7 @@
 using namespace std;
 using namespace std;
 using namespace isc;
 using namespace isc;
 using namespace isc::d2;
 using namespace isc::d2;
+using namespace isc::util;
 
 
 namespace {
 namespace {
 
 

+ 3 - 1
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
 // 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
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -20,6 +20,8 @@
 using namespace std;
 using namespace std;
 using namespace isc;
 using namespace isc;
 using namespace isc::d2;
 using namespace isc::d2;
+using namespace isc::util;
+
 
 
 namespace {
 namespace {
 
 

+ 1 - 0
src/bin/d2/tests/nc_trans_unittests.cc

@@ -24,6 +24,7 @@
 using namespace std;
 using namespace std;
 using namespace isc;
 using namespace isc;
 using namespace isc::d2;
 using namespace isc::d2;
+using namespace isc::util;
 using namespace boost::posix_time;
 using namespace boost::posix_time;
 
 
 namespace {
 namespace {

+ 5 - 3
src/lib/util/Makefile.am

@@ -8,11 +8,10 @@ AM_CXXFLAGS = $(KEA_CXXFLAGS)
 
 
 lib_LTLIBRARIES = libkea-util.la
 lib_LTLIBRARIES = libkea-util.la
 libkea_util_la_SOURCES  = boost_time_utils.h boost_time_utils.cc
 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 += csv_file.h csv_file.cc
 libkea_util_la_SOURCES += filename.h filename.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.h
 libkea_util_la_SOURCES += memory_segment_local.h memory_segment_local.cc
 libkea_util_la_SOURCES += memory_segment_local.h memory_segment_local.cc
 libkea_util_la_SOURCES += optional_value.h
 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 += range_utilities.h
 libkea_util_la_SOURCES += signal_set.cc signal_set.h
 libkea_util_la_SOURCES += signal_set.cc signal_set.h
 libkea_util_la_SOURCES += staged_value.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.cc stopwatch.h
 libkea_util_la_SOURCES += stopwatch_impl.cc stopwatch_impl.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 += versioned_csv_file.h versioned_csv_file.cc
 libkea_util_la_SOURCES += watch_socket.cc watch_socket.h
 libkea_util_la_SOURCES += watch_socket.cc watch_socket.h
 libkea_util_la_SOURCES += encode/base16_from_binary.h
 libkea_util_la_SOURCES += encode/base16_from_binary.h

+ 4 - 4
src/bin/d2/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
 // 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
 // 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/.
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 
-#include <d2/labeled_value.h>
+#include <util/labeled_value.h>
 
 
 namespace isc {
 namespace isc {
-namespace d2 {
+namespace util {
 
 
 /**************************** LabeledValue ****************************/
 /**************************** LabeledValue ****************************/
 
 
@@ -111,5 +111,5 @@ LabeledValueSet::getLabel(const int value) const {
     return (std::string(UNDEFINED_LABEL));
     return (std::string(UNDEFINED_LABEL));
 }
 }
 
 
-} // namespace isc::d2
+} // namespace isc::util
 } // namespace isc
 } // namespace isc

+ 3 - 3
src/bin/d2/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
 // 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
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -18,7 +18,7 @@
 /// LabeledValueSet.
 /// LabeledValueSet.
 
 
 namespace isc {
 namespace isc {
-namespace d2 {
+namespace util {
 
 
 /// @brief Thrown if an error is encountered handling a LabeledValue.
 /// @brief Thrown if an error is encountered handling a LabeledValue.
 class LabeledValueError : public isc::Exception {
 class LabeledValueError : public isc::Exception {
@@ -171,6 +171,6 @@ private:
     LabeledValueMap map_;
     LabeledValueMap map_;
 };
 };
 
 
-} // namespace isc::d2
+} // namespace isc::util
 } // namespace isc
 } // namespace isc
 #endif
 #endif

+ 5 - 7
src/bin/d2/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
 // 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
 // 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/.
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 
 #include <config.h>
 #include <config.h>
-
-#include <d2/d2_log.h>
-#include <d2/state_model.h>
-
+#include <util/state_model.h>
+#include <boost/bind.hpp>
 #include <string>
 #include <string>
 
 
 namespace isc {
 namespace isc {
-namespace d2 {
+namespace util {
 
 
 /********************************** State *******************************/
 /********************************** State *******************************/
 
 
@@ -377,5 +375,5 @@ StateModel::getPrevContextStr() const {
     return(stream.str());
     return(stream.str());
 }
 }
 
 
-} // namespace isc::d2
+} // namespace isc::util
 } // namespace isc
 } // namespace isc

+ 5 - 8
src/bin/d2/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
 // 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
 // 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.
 /// @file state_model.h This file defines the class StateModel.
 
 
 #include <exceptions/exceptions.h>
 #include <exceptions/exceptions.h>
-#include <d2/d2_config.h>
-#include <d2/dns_client.h>
-#include <d2/labeled_value.h>
-#include <dhcp_ddns/ncr_msg.h>
-
+#include <util/labeled_value.h>
+#include <boost/function.hpp>
 #include <boost/shared_ptr.hpp>
 #include <boost/shared_ptr.hpp>
 #include <map>
 #include <map>
 #include <string>
 #include <string>
 
 
 namespace isc {
 namespace isc {
-namespace d2 {
+namespace util {
 
 
 /// @brief Thrown if the state machine encounters a general error.
 /// @brief Thrown if the state machine encounters a general error.
 class StateModelError : public isc::Exception {
 class StateModelError : public isc::Exception {
@@ -666,6 +663,6 @@ private:
 /// @brief Defines a pointer to a StateModel.
 /// @brief Defines a pointer to a StateModel.
 typedef boost::shared_ptr<StateModel> StateModelPtr;
 typedef boost::shared_ptr<StateModel> StateModelPtr;
 
 
-} // namespace isc::d2
+} // namespace isc::util
 } // namespace isc
 } // namespace isc
 #endif
 #endif

+ 2 - 0
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 += filename_unittest.cc
 run_unittests_SOURCES += hex_unittest.cc
 run_unittests_SOURCES += hex_unittest.cc
 run_unittests_SOURCES += io_utilities_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_local_unittest.cc
 run_unittests_SOURCES += memory_segment_common_unittest.h
 run_unittests_SOURCES += memory_segment_common_unittest.h
 run_unittests_SOURCES += memory_segment_common_unittest.cc
 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 += random_number_generator_unittest.cc
 run_unittests_SOURCES += socketsession_unittest.cc
 run_unittests_SOURCES += socketsession_unittest.cc
 run_unittests_SOURCES += staged_value_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 += strutil_unittest.cc
 run_unittests_SOURCES += time_utilities_unittest.cc
 run_unittests_SOURCES += time_utilities_unittest.cc
 run_unittests_SOURCES += range_utilities_unittest.cc
 run_unittests_SOURCES += range_utilities_unittest.cc

+ 3 - 3
src/bin/d2/tests/labeled_value_unittests.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
 // 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
 // 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/.
 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 
-#include <d2/labeled_value.h>
+#include <util/labeled_value.h>
 
 
 #include <gtest/gtest.h>
 #include <gtest/gtest.h>
 
 
 using namespace std;
 using namespace std;
 using namespace isc;
 using namespace isc;
-using namespace isc::d2;
+using namespace isc::util;
 
 
 namespace {
 namespace {
 
 

+ 3 - 3
src/bin/d2/tests/state_model_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
 // 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
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -6,7 +6,7 @@
 
 
 #include <config.h>
 #include <config.h>
 
 
-#include <d2/state_model.h>
+#include <util/state_model.h>
 
 
 #include <boost/function.hpp>
 #include <boost/function.hpp>
 #include <boost/bind.hpp>
 #include <boost/bind.hpp>
@@ -14,7 +14,7 @@
 
 
 using namespace std;
 using namespace std;
 using namespace isc;
 using namespace isc;
-using namespace isc::d2;
+using namespace isc::util;
 
 
 namespace {
 namespace {