From 99c4b205ecff15054b868aca64a7856536ae58dc Mon Sep 17 00:00:00 2001 From: rex-schilasky <49162693+rex-schilasky@users.noreply.github.com> Date: Tue, 17 Dec 2024 10:27:16 +0100 Subject: [PATCH] renaming Add -> Set comments --- ecal/core/include/ecal/ecal_server.h | 10 ++++---- ecal/core/src/service/ecal_service_server.cpp | 2 +- .../service/ecal_service_server_v5_impl.cpp | 4 ++-- .../latency_server/src/latency_server.cpp | 2 +- .../minimal_server/src/minimal_server.cpp | 2 +- .../src/clientserver_test.cpp | 24 +++++++++---------- .../src/registration_getservices.cpp | 4 ++-- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/ecal/core/include/ecal/ecal_server.h b/ecal/core/include/ecal/ecal_server.h index 1e51b66556..25a95edada 100644 --- a/ecal/core/include/ecal/ecal_server.h +++ b/ecal/core/include/ecal/ecal_server.h @@ -84,26 +84,26 @@ namespace eCAL CServiceServer& operator=(CServiceServer&& rhs) noexcept; /** - * @brief Add method callback. + * @brief Set/overwrite method callback. * * @param method_ Service method name. * @param method_info_ Service method information (request & response types). * @param callback_ Callback function for client request. * - * @return True if successful. + * @return True if succeeded, false if not. **/ // TODO: Provide new MethodCallbackT type using SServiceMethodInformation instead "MethodCallbackT = std::function" ECAL_API_EXPORTED_MEMBER - bool AddMethodCallback(const std::string& method_, const SServiceMethodInformation& method_info_, const MethodCallbackT& callback_); + bool SetMethodCallback(const std::string& method_, const SServiceMethodInformation& method_info_, const MethodCallbackT& callback_); /** * @brief Remove method callback. * * @param method_ Service method name. * - * @return True if successful. + * @return True if succeeded, false if not. **/ ECAL_API_EXPORTED_MEMBER bool RemoveMethodCallback(const std::string& method_); @@ -130,7 +130,7 @@ namespace eCAL /** * @brief Check connection state. * - * @return True if connected, false if not. + * @return True if succeeded, false if not. **/ ECAL_API_EXPORTED_MEMBER bool IsConnected(); diff --git a/ecal/core/src/service/ecal_service_server.cpp b/ecal/core/src/service/ecal_service_server.cpp index 002b4e3fbd..fda2e33d92 100644 --- a/ecal/core/src/service/ecal_service_server.cpp +++ b/ecal/core/src/service/ecal_service_server.cpp @@ -62,7 +62,7 @@ namespace eCAL return *this; } - bool CServiceServer::AddMethodCallback(const std::string& method_, const SServiceMethodInformation& method_info_, const MethodCallbackT& callback_) + bool CServiceServer::SetMethodCallback(const std::string& method_, const SServiceMethodInformation& method_info_, const MethodCallbackT& callback_) { if (m_service_server_impl == nullptr) return false; return m_service_server_impl->AddMethodCallback(method_, method_info_, callback_); diff --git a/ecal/core/src/service/ecal_service_server_v5_impl.cpp b/ecal/core/src/service/ecal_service_server_v5_impl.cpp index 715812eda4..d715455f02 100644 --- a/ecal/core/src/service/ecal_service_server_v5_impl.cpp +++ b/ecal/core/src/service/ecal_service_server_v5_impl.cpp @@ -105,7 +105,7 @@ namespace eCAL method_info.response_type.name = resp_type_; method_info.response_type.descriptor = resp_desc_; - return m_service_server_impl->AddMethodCallback(method_, method_info, nullptr); + return m_service_server_impl->SetMethodCallback(method_, method_info, nullptr); } bool CServiceServerImpl::AddMethodCallback(const std::string& method_, const std::string& req_type_, const std::string& resp_type_, const MethodCallbackT& callback_) @@ -122,7 +122,7 @@ namespace eCAL method_info.request_type.name = req_type_; method_info.response_type.name = resp_type_; - return m_service_server_impl->AddMethodCallback(method_, method_info, callback_); + return m_service_server_impl->SetMethodCallback(method_, method_info, callback_); } bool CServiceServerImpl::RemMethodCallback(const std::string& method_) diff --git a/ecal/samples/cpp/services/latency_server/src/latency_server.cpp b/ecal/samples/cpp/services/latency_server/src/latency_server.cpp index 213a5cd06a..2003da72a3 100644 --- a/ecal/samples/cpp/services/latency_server/src/latency_server.cpp +++ b/ecal/samples/cpp/services/latency_server/src/latency_server.cpp @@ -37,7 +37,7 @@ int main() eCAL::CServiceServer latency_service("latency"); // add hello method callback - latency_service.AddMethodCallback("hello", eCAL::SServiceMethodInformation(), OnHello); + latency_service.SetMethodCallback("hello", eCAL::SServiceMethodInformation(), OnHello); // idle main thread while (eCAL::Ok()) std::this_thread::sleep_for(std::chrono::milliseconds(100)); diff --git a/ecal/samples/cpp/services/minimal_server/src/minimal_server.cpp b/ecal/samples/cpp/services/minimal_server/src/minimal_server.cpp index 42e23040b2..6c8a1e8100 100644 --- a/ecal/samples/cpp/services/minimal_server/src/minimal_server.cpp +++ b/ecal/samples/cpp/services/minimal_server/src/minimal_server.cpp @@ -42,7 +42,7 @@ int main() eCAL::CServiceServer minimal_server("service1"); // add method callback - minimal_server.AddMethodCallback("echo", eCAL::SServiceMethodInformation(), OnMethodCallback); + minimal_server.SetMethodCallback("echo", eCAL::SServiceMethodInformation(), OnMethodCallback); // idle while(eCAL::Ok()) diff --git a/ecal/tests/cpp/clientserver_test/src/clientserver_test.cpp b/ecal/tests/cpp/clientserver_test/src/clientserver_test.cpp index 1e18d876e2..0e4be483bc 100644 --- a/ecal/tests/cpp/clientserver_test/src/clientserver_test.cpp +++ b/ecal/tests/cpp/clientserver_test/src/clientserver_test.cpp @@ -272,8 +272,8 @@ TEST(core_cpp_clientserver, ClientServerBaseCallback) { eCAL::SServiceMethodInformation method1_info{ {"foo::req_type1", "", ""}, {"foo::resp_type1", "", ""}}; eCAL::SServiceMethodInformation method2_info{ {"foo::req_type2", "", ""}, {"foo::resp_type2", "", ""} }; - service->AddMethodCallback("foo::method1", method1_info, method_callback); - service->AddMethodCallback("foo::method2", method2_info, method_callback); + service->SetMethodCallback("foo::method1", method1_info, method_callback); + service->SetMethodCallback("foo::method2", method2_info, method_callback); } // create service clients @@ -377,8 +377,8 @@ TEST(core_cpp_clientserver, ClientServerBaseCallbackTimeout) { eCAL::SServiceMethodInformation method1_info{ {"foo::req_type1", "", ""}, {"foo::resp_type1", "", ""} }; eCAL::SServiceMethodInformation method2_info{ {"foo::req_type2", "", ""}, {"foo::resp_type2", "", ""} }; - service->AddMethodCallback("foo::method1", method1_info, method_callback); - service->AddMethodCallback("foo::method2", method2_info, method_callback); + service->SetMethodCallback("foo::method1", method1_info, method_callback); + service->SetMethodCallback("foo::method2", method2_info, method_callback); } // event callback for timeout event @@ -530,8 +530,8 @@ TEST(core_cpp_clientserver, ClientServerBaseAsyncCallback) // add callback for client request eCAL::SServiceMethodInformation method1_info{ {"foo::req_type1", "", ""}, {"foo::resp_type1", "", ""} }; eCAL::SServiceMethodInformation method2_info{ {"foo::req_type2", "", ""}, {"foo::resp_type2", "", ""} }; - server.AddMethodCallback("foo::method1", method1_info, method_callback); - server.AddMethodCallback("foo::method2", method2_info, method_callback); + server.SetMethodCallback("foo::method1", method1_info, method_callback); + server.SetMethodCallback("foo::method2", method2_info, method_callback); // create service client eCAL::CServiceClient client("service"); @@ -605,8 +605,8 @@ TEST(core_cpp_clientserver, ClientServerBaseAsync) // add callback for client request eCAL::SServiceMethodInformation method1_info{ {"foo::req_type1", "", ""}, {"foo::resp_type1", "", ""} }; eCAL::SServiceMethodInformation method2_info{ {"foo::req_type2", "", ""}, {"foo::resp_type2", "", ""} }; - server.AddMethodCallback("foo::method1", method1_info, method_callback); - server.AddMethodCallback("foo::method2", method2_info, method_callback); + server.SetMethodCallback("foo::method1", method1_info, method_callback); + server.SetMethodCallback("foo::method2", method2_info, method_callback); // create service client eCAL::CServiceClient client("service"); @@ -716,8 +716,8 @@ TEST(core_cpp_clientserver, ClientServerBaseBlocking) { eCAL::SServiceMethodInformation method1_info{ {"foo::req_type1", "", ""}, {"foo::resp_type1", "", ""} }; eCAL::SServiceMethodInformation method2_info{ {"foo::req_type2", "", ""}, {"foo::resp_type2", "", ""} }; - service->AddMethodCallback("foo::method1", method1_info, method_callback); - service->AddMethodCallback("foo::method2", method2_info, method_callback); + service->SetMethodCallback("foo::method1", method1_info, method_callback); + service->SetMethodCallback("foo::method2", method2_info, method_callback); } // create service clients @@ -811,8 +811,8 @@ TEST(core_cpp_clientserver, NestedRPCCall) // add callback for client request eCAL::SServiceMethodInformation method1_info{ {"foo::req_type1", "", ""}, {"foo::resp_type1", "", ""} }; eCAL::SServiceMethodInformation method2_info{ {"foo::req_type2", "", ""}, {"foo::resp_type2", "", ""} }; - server.AddMethodCallback("foo::method1", method1_info, method_callback); - server.AddMethodCallback("foo::method2", method2_info, method_callback); + server.SetMethodCallback("foo::method1", method1_info, method_callback); + server.SetMethodCallback("foo::method2", method2_info, method_callback); // create service client eCAL::CServiceClient client1("service"); diff --git a/ecal/tests/cpp/registration_test_public/src/registration_getservices.cpp b/ecal/tests/cpp/registration_test_public/src/registration_getservices.cpp index acd25ac68f..1e80539523 100644 --- a/ecal/tests/cpp/registration_test_public/src/registration_getservices.cpp +++ b/ecal/tests/cpp/registration_test_public/src/registration_getservices.cpp @@ -61,7 +61,7 @@ TEST_P(ServicesTestFixture, ServiceExpiration) { // create service eCAL::CServiceServer service("foo::service"); - service.AddMethodCallback("foo::method", { { "foo::req_type", "foo::req_desc" }, { "foo::resp_type", "foo::resp_desc" } }, eCAL::MethodCallbackT()); + service.SetMethodCallback("foo::method", { { "foo::req_type", "foo::req_desc" }, { "foo::resp_type", "foo::resp_desc" } }, eCAL::MethodCallbackT()); // let's register eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH_MS); @@ -116,7 +116,7 @@ TEST_P(ServicesTestFixture, GetServiceIDs) service_method_info.request_type.descriptor = "foo::req_desc"; service_method_info.response_type.name = "foo::resp_type"; service_method_info.response_type.descriptor = "foo::resp_desc"; - service.AddMethodCallback("method", service_method_info, eCAL::MethodCallbackT()); + service.SetMethodCallback("method", service_method_info, eCAL::MethodCallbackT()); // let's register eCAL::Process::SleepMS(2 * CMN_REGISTRATION_REFRESH_MS);