Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] get service id implementation #1875

Merged
merged 3 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions ecal/core/include/ecal/ecal_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,6 @@ namespace eCAL
*
* @return The service id.
**/

// TODO: Implement this

ECAL_API_EXPORTED_MEMBER
Registration::SServiceMethodId GetServiceId() const;

Expand Down
3 changes: 0 additions & 3 deletions ecal/core/include/ecal/ecal_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,6 @@ namespace eCAL
*
* @return The service id.
**/

// TODO: Implement this

ECAL_API_EXPORTED_MEMBER
Registration::SServiceMethodId GetServiceId() const;

Expand Down
4 changes: 2 additions & 2 deletions ecal/core/src/service/ecal_service_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions ecal/core/src/service/ecal_service_client_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.process_id = Process::GetProcessID();
service_id.service_id.host_name = Process::GetHostName();

service_id.service_name = m_service_name;
service_id.method_name = "";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the method_name an empty string?

Copy link
Contributor Author

@rex-schilasky rex-schilasky Jan 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method_name field is used in other internal contexts (for example as key in ServiceIdInfoMap) but here the method name makes no sense. I will introduce a new SServiceId type additional to the existing SServiceMethodId for now. The new type will cover service and client instance id's and the other one will be used to get ID's of service-methods. Let me try .. ;-)


return service_id;
}

std::string CServiceClientImpl::GetServiceName() const
{
return m_service_name;
Expand Down
3 changes: 3 additions & 0 deletions ecal/core/src/service/ecal_service_client_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions ecal/core/src/service/ecal_service_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
14 changes: 14 additions & 0 deletions ecal/core/src/service/ecal_service_server_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.process_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;
Expand Down
3 changes: 3 additions & 0 deletions ecal/core/src/service/ecal_service_server_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading