Skip to content

Commit

Permalink
renaming Add -> Set
Browse files Browse the repository at this point in the history
comments
  • Loading branch information
rex-schilasky committed Dec 17, 2024
1 parent fb2a15f commit 99c4b20
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 24 deletions.
10 changes: 5 additions & 5 deletions ecal/core/include/ecal/ecal_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<int(const std::string& method_, const std::string& req_type_, const std::string& resp_type_, const std::string& request_, std::string& response_)>"

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_);
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion ecal/core/src/service/ecal_service_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
Expand Down
4 changes: 2 additions & 2 deletions ecal/core/src/service/ecal_service_server_v5_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_)
Expand All @@ -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_)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
24 changes: 12 additions & 12 deletions ecal/tests/cpp/clientserver_test/src/clientserver_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 99c4b20

Please sign in to comment.