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 all 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
5 changes: 1 addition & 4 deletions ecal/core/include/ecal/ecal_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,8 @@ namespace eCAL
*
* @return The service id.
**/

// TODO: Implement this

ECAL_API_EXPORTED_MEMBER
Registration::SServiceMethodId GetServiceId() const;
Registration::SServiceId GetServiceId() const;

/**
* @brief Check connection to at least one service.
Expand Down
3 changes: 1 addition & 2 deletions ecal/core/include/ecal/ecal_registration.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ namespace eCAL
deleted_entity //!< Represents a deletion of an entity
};

using TopicIDCallbackT = std::function<void(const STopicId&, RegistrationEventType)>;
using ServiceIDCallbackT = std::function<void(const SServiceMethodId&, RegistrationEventType)>;
using TopicIDCallbackT = std::function<void(const STopicId&, RegistrationEventType)>;

/**
* @brief Get complete snapshot of all known publisher.
Expand Down
5 changes: 1 addition & 4 deletions ecal/core/include/ecal/ecal_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,8 @@ namespace eCAL
*
* @return The service id.
**/

// TODO: Implement this

ECAL_API_EXPORTED_MEMBER
Registration::SServiceMethodId GetServiceId() const;
Registration::SServiceId GetServiceId() const;

/**
* @brief Check connection state.
Expand Down
16 changes: 16 additions & 0 deletions ecal/core/include/ecal/ecal_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,22 @@ namespace eCAL
return os;
}

struct SServiceId
{
SEntityId service_id;
std::string service_name;

bool operator==(const SServiceId& other) const
{
return service_id == other.service_id && service_name == other.service_name;
}

bool operator<(const SServiceId& other) const
{
return std::tie(service_id, service_name) < std::tie(other.service_id, other.service_name);
}
};

struct SServiceMethodId
{
SEntityId service_id;
Expand Down
6 changes: 3 additions & 3 deletions ecal/core/src/service/ecal_service_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ namespace eCAL
return m_service_client_impl->GetServiceName();
}

Registration::SServiceMethodId CServiceClient::GetServiceId() const
Registration::SServiceId CServiceClient::GetServiceId() const
{
// TODO: Implement this
return Registration::SServiceMethodId();
if (m_service_client_impl == nullptr) return Registration::SServiceId();
return m_service_client_impl->GetServiceId();
}

bool CServiceClient::IsConnected() const
Expand Down
12 changes: 12 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,18 @@ namespace eCAL
return GetRegistrationSample();
}

Registration::SServiceId CServiceClientImpl::GetServiceId() const
{
Registration::SServiceId 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;

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::SServiceId GetServiceId() const;

// Retrieves the service name
std::string GetServiceName() const;

Expand Down
6 changes: 3 additions & 3 deletions ecal/core/src/service/ecal_service_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ namespace eCAL
return m_service_server_impl->GetServiceName();
}

Registration::SServiceMethodId CServiceServer::GetServiceId() const
Registration::SServiceId CServiceServer::GetServiceId() const
{
// TODO: Implement this
return Registration::SServiceMethodId();
if (m_service_server_impl == nullptr) return Registration::SServiceId();
return m_service_server_impl->GetServiceId();
}

bool CServiceServer::IsConnected()
Expand Down
12 changes: 12 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,18 @@ namespace eCAL
return GetRegistrationSample();
}

Registration::SServiceId CServiceServerImpl::GetServiceId() const
{
Registration::SServiceId 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;

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::SServiceId GetServiceId() const;

// Retrieves the service name
std::string GetServiceName() const;

Expand Down
Loading