From f499437a13e1ba5f31722535b97bd9892748692b Mon Sep 17 00:00:00 2001 From: rex-schilasky <49162693+rex-schilasky@users.noreply.github.com> Date: Tue, 7 Jan 2025 09:40:44 +0100 Subject: [PATCH] implement GetServiceId of CServiceClient and CServiceServer --- ecal/core/include/ecal/ecal_client.h | 3 --- ecal/core/include/ecal/ecal_server.h | 3 --- ecal/core/src/service/ecal_service_client.cpp | 4 ++-- ecal/core/src/service/ecal_service_client_impl.cpp | 14 ++++++++++++++ ecal/core/src/service/ecal_service_client_impl.h | 3 +++ ecal/core/src/service/ecal_service_server.cpp | 4 ++-- ecal/core/src/service/ecal_service_server_impl.cpp | 14 ++++++++++++++ ecal/core/src/service/ecal_service_server_impl.h | 3 +++ 8 files changed, 38 insertions(+), 10 deletions(-) diff --git a/ecal/core/include/ecal/ecal_client.h b/ecal/core/include/ecal/ecal_client.h index d72c95c4b7..db6640a8a1 100644 --- a/ecal/core/include/ecal/ecal_client.h +++ b/ecal/core/include/ecal/ecal_client.h @@ -145,9 +145,6 @@ namespace eCAL * * @return The service id. **/ - - // TODO: Implement this - ECAL_API_EXPORTED_MEMBER Registration::SServiceMethodId GetServiceId() const; diff --git a/ecal/core/include/ecal/ecal_server.h b/ecal/core/include/ecal/ecal_server.h index 25a95edada..09342ad0ea 100644 --- a/ecal/core/include/ecal/ecal_server.h +++ b/ecal/core/include/ecal/ecal_server.h @@ -121,9 +121,6 @@ namespace eCAL * * @return The service id. **/ - - // TODO: Implement this - ECAL_API_EXPORTED_MEMBER Registration::SServiceMethodId GetServiceId() const; diff --git a/ecal/core/src/service/ecal_service_client.cpp b/ecal/core/src/service/ecal_service_client.cpp index c29aba46f2..4463c56aeb 100644 --- a/ecal/core/src/service/ecal_service_client.cpp +++ b/ecal/core/src/service/ecal_service_client.cpp @@ -186,8 +186,8 @@ namespace eCAL Registration::SServiceMethodId CServiceClient::GetServiceId() const { - // TODO: Implement this - return Registration::SServiceMethodId(); + if (m_service_client_impl == nullptr) return Registration::SServiceMethodId(); + return m_service_client_impl->GetServiceId(); } bool CServiceClient::IsConnected() const diff --git a/ecal/core/src/service/ecal_service_client_impl.cpp b/ecal/core/src/service/ecal_service_client_impl.cpp index 961a495e43..b33076f588 100644 --- a/ecal/core/src/service/ecal_service_client_impl.cpp +++ b/ecal/core/src/service/ecal_service_client_impl.cpp @@ -368,6 +368,20 @@ namespace eCAL return GetRegistrationSample(); } + Registration::SServiceMethodId CServiceClientImpl::GetServiceId() const + { + Registration::SServiceMethodId service_id; + + service_id.service_id.entity_id = m_client_id; + service_id.service_id.entity_id = Process::GetProcessID(); + service_id.service_id.host_name = Process::GetHostName(); + + service_id.service_name = m_service_name; + service_id.method_name = ""; + + return service_id; + } + std::string CServiceClientImpl::GetServiceName() const { return m_service_name; diff --git a/ecal/core/src/service/ecal_service_client_impl.h b/ecal/core/src/service/ecal_service_client_impl.h index f0bffdc0ce..69c88d6552 100644 --- a/ecal/core/src/service/ecal_service_client_impl.h +++ b/ecal/core/src/service/ecal_service_client_impl.h @@ -78,6 +78,9 @@ namespace eCAL // Called by the registration provider to get a registration sample Registration::Sample GetRegistration(); + // Retrieves the service id + Registration::SServiceMethodId GetServiceId() const; + // Retrieves the service name std::string GetServiceName() const; diff --git a/ecal/core/src/service/ecal_service_server.cpp b/ecal/core/src/service/ecal_service_server.cpp index fda2e33d92..3e3e2bf128 100644 --- a/ecal/core/src/service/ecal_service_server.cpp +++ b/ecal/core/src/service/ecal_service_server.cpp @@ -82,8 +82,8 @@ namespace eCAL Registration::SServiceMethodId CServiceServer::GetServiceId() const { - // TODO: Implement this - return Registration::SServiceMethodId(); + if (m_service_server_impl == nullptr) return Registration::SServiceMethodId(); + return m_service_server_impl->GetServiceId(); } bool CServiceServer::IsConnected() diff --git a/ecal/core/src/service/ecal_service_server_impl.cpp b/ecal/core/src/service/ecal_service_server_impl.cpp index 6be955148f..c09714b238 100644 --- a/ecal/core/src/service/ecal_service_server_impl.cpp +++ b/ecal/core/src/service/ecal_service_server_impl.cpp @@ -152,6 +152,20 @@ namespace eCAL return GetRegistrationSample(); } + Registration::SServiceMethodId CServiceServerImpl::GetServiceId() const + { + Registration::SServiceMethodId service_id; + + service_id.service_id.entity_id = m_service_id; + service_id.service_id.entity_id = Process::GetProcessID(); + service_id.service_id.host_name = Process::GetHostName(); + + service_id.service_name = m_service_name; + service_id.method_name = ""; + + return service_id; + } + std::string CServiceServerImpl::GetServiceName() const { return m_service_name; diff --git a/ecal/core/src/service/ecal_service_server_impl.h b/ecal/core/src/service/ecal_service_server_impl.h index be5ad0c44d..55b95db855 100644 --- a/ecal/core/src/service/ecal_service_server_impl.h +++ b/ecal/core/src/service/ecal_service_server_impl.h @@ -67,6 +67,9 @@ namespace eCAL // Called by the registration provider to get a registration sample Registration::Sample GetRegistration(); + // Retrieves the service id + Registration::SServiceMethodId GetServiceId() const; + // Retrieves the service name std::string GetServiceName() const;