mrs_lib
Various reusable classes, functions and utilities for use in MRS projects
Loading...
Searching...
No Matches
mrs_lib::ServiceServer< ServiceType > Class Template Reference

rclcpp::Service wrapper with coroutines support. More...

#include <service_server.hpp>

Public Types

using ServiceCallback = std::function<void(std::shared_ptr<const Request> req, std::shared_ptr<Response>)>
 Type of the accepted callback.
using ServiceCoroCallback = CoroCallback<void(std::shared_ptr<const Request> req, std::shared_ptr<Response>)>
 Type of the accepted coroutine callback.

Public Member Functions

 ServiceServer (const ServiceServerOptions &options, std::string_view service_name, ServiceCallback callback)
 Construct the service server with the specified callback.
 ServiceServer (const ServiceServerOptions &options, std::string_view service_name, ServiceCoroCallback callback)
 Construct the service server with the specified coroutine callback.
std::string get_service_name () const
 Returns the resolved (full) name of the service handled by this service server.
std::string get_unresolved_service_name () const
 Returns the unresolved name of the service handled by this service server.

Detailed Description

template<class ServiceType>
class mrs_lib::ServiceServer< ServiceType >

rclcpp::Service wrapper with coroutines support.

Template Parameters
ServiceTypeType of the service this server will provide.

Constructor & Destructor Documentation

◆ ServiceServer() [1/2]

template<class ServiceType>
mrs_lib::ServiceServer< ServiceType >::ServiceServer ( const ServiceServerOptions & options,
std::string_view service_name,
ServiceCallback callback )

Construct the service server with the specified callback.

options Options to configure the service server.

Parameters
service_nameName of the service to provide.
callbackCallback to call when a request is received.

◆ ServiceServer() [2/2]

template<class ServiceType>
mrs_lib::ServiceServer< ServiceType >::ServiceServer ( const ServiceServerOptions & options,
std::string_view service_name,
ServiceCoroCallback callback )

Construct the service server with the specified coroutine callback.

options Options to configure the service server.

Parameters
service_nameName of the service to provide.
callbackCoroutine callback to call when a request is received.

Member Function Documentation

◆ get_service_name()

template<class ServiceType>
std::string mrs_lib::ServiceServer< ServiceType >::get_service_name ( ) const
nodiscard

Returns the resolved (full) name of the service handled by this service server.

Returns
The name of the handled service.

◆ get_unresolved_service_name()

template<class ServiceType>
std::string mrs_lib::ServiceServer< ServiceType >::get_unresolved_service_name ( ) const
nodiscard

Returns the unresolved name of the service handled by this service server.

Returns
The name of the handled service.

The documentation for this class was generated from the following files: