SMACC2
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
smacc2::client_bases::SmaccServiceServerClient< TService > Class Template Reference

#include <smacc_service_server_client.hpp>

Inheritance diagram for smacc2::client_bases::SmaccServiceServerClient< TService >:
Inheritance graph
Collaboration diagram for smacc2::client_bases::SmaccServiceServerClient< TService >:
Collaboration graph

Public Member Functions

 SmaccServiceServerClient ()
 
 SmaccServiceServerClient (std::string service_name)
 
virtual ~SmaccServiceServerClient ()
 
template<typename T >
boost::signals2::connection onServiceRequestReceived (void(T::*callback)(const std::shared_ptr< typename TService::Request >, std::shared_ptr< typename TService::Response >), T *object)
 
void onInitialize () override
 
- Public Member Functions inherited from smacc2::ISmaccClient
 ISmaccClient ()
 
virtual ~ISmaccClient ()
 
virtual void onInitialize ()
 
virtual std::string getName () const
 
template<typename TComponent >
TComponent * getComponent ()
 
template<typename TComponent >
TComponent * getComponent (std::string name)
 
template<typename TComponent >
TComponent * getComponent (int index)
 
virtual smacc2::introspection::TypeInfo::Ptr getType ()
 
ISmaccStateMachinegetStateMachine ()
 
template<typename TSmaccSignal , typename T >
void connectSignal (TSmaccSignal &signal, void(T::*callback)(), T *object)
 
template<typename SmaccClientType >
void requiresClient (SmaccClientType *&storage)
 
void getComponents (std::vector< std::shared_ptr< ISmaccComponent > > &components)
 
const std::vector< std::shared_ptr< ISmaccComponent > > & iterateComponents () const
 
template<typename EventType >
void postEvent (const EventType &ev)
 
template<typename EventType >
void postEvent ()
 

Public Attributes

std::optional< std::string > serviceName_
 
smacc2::SmaccSignal< void(const std::shared_ptr< typename TService::Request >, std::shared_ptr< typename TService::Response >)> onServiceRequestReceived_
 

Private Types

using TServiceRequest = typename TService::Request
 
using TServiceResponse = typename TService::Response
 

Private Member Functions

void serviceCallback (const std::shared_ptr< typename TService::Request > req, std::shared_ptr< typename TService::Response > res)
 

Private Attributes

rclcpp::Service< TService >::SharedPtr server_
 
bool initialized_
 

Additional Inherited Members

- Protected Member Functions inherited from smacc2::ISmaccClient
template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentType * createComponent (TArgs... targs)
 
template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentType * createNamedComponent (std::string name, TArgs... targs)
 
rclcpp::Node::SharedPtr getNode ()
 
rclcpp::Logger getLogger ()
 
- Protected Attributes inherited from smacc2::ISmaccClient
std::map< ComponentKey, std::shared_ptr< smacc2::ISmaccComponent > > components_
 

Detailed Description

template<typename TService>
class smacc2::client_bases::SmaccServiceServerClient< TService >

Definition at line 32 of file smacc_service_server_client.hpp.

Member Typedef Documentation

◆ TServiceRequest

template<typename TService >
using smacc2::client_bases::SmaccServiceServerClient< TService >::TServiceRequest = typename TService::Request
private

Definition at line 34 of file smacc_service_server_client.hpp.

◆ TServiceResponse

template<typename TService >
using smacc2::client_bases::SmaccServiceServerClient< TService >::TServiceResponse = typename TService::Response
private

Definition at line 35 of file smacc_service_server_client.hpp.

Constructor & Destructor Documentation

◆ SmaccServiceServerClient() [1/2]

template<typename TService >
smacc2::client_bases::SmaccServiceServerClient< TService >::SmaccServiceServerClient ( )
inline

◆ SmaccServiceServerClient() [2/2]

template<typename TService >
smacc2::client_bases::SmaccServiceServerClient< TService >::SmaccServiceServerClient ( std::string  service_name)
inline

◆ ~SmaccServiceServerClient()

template<typename TService >
virtual smacc2::client_bases::SmaccServiceServerClient< TService >::~SmaccServiceServerClient ( )
inlinevirtual

Definition at line 46 of file smacc_service_server_client.hpp.

46{}

Member Function Documentation

◆ onInitialize()

template<typename TService >
void smacc2::client_bases::SmaccServiceServerClient< TService >::onInitialize ( )
inlineoverridevirtual

Reimplemented from smacc2::ISmaccClient.

Definition at line 64 of file smacc_service_server_client.hpp.

65 {
66 if (!initialized_)
67 {
68 if (!serviceName_)
69 {
70 RCLCPP_ERROR_STREAM(
71 getLogger(),
72 "[" << this->getName() << "] service server with no service name set. Skipping.");
73 }
74 else
75 {
76 RCLCPP_INFO_STREAM(
77 getLogger(), "[" << this->getName() << "] Client Service: " << *serviceName_);
78
79 server_ = getNode()->create_service<TService>(
80 *serviceName_, std::bind(
82 std::placeholders::_1, std::placeholders::_2));
83
84 this->initialized_ = true;
85 }
86 }
87 }
rclcpp::Node::SharedPtr getNode()
Definition: client.cpp:60
virtual std::string getName() const
Definition: client.cpp:42
rclcpp::Logger getLogger()
void serviceCallback(const std::shared_ptr< typename TService::Request > req, std::shared_ptr< typename TService::Response > res)

References smacc2::ISmaccClient::getLogger(), smacc2::ISmaccClient::getName(), smacc2::ISmaccClient::getNode(), smacc2::client_bases::SmaccServiceServerClient< TService >::initialized_, smacc2::client_bases::SmaccServiceServerClient< TService >::server_, and smacc2::client_bases::SmaccServiceServerClient< TService >::serviceName_.

Here is the call graph for this function:

◆ onServiceRequestReceived()

template<typename TService >
template<typename T >
boost::signals2::connection smacc2::client_bases::SmaccServiceServerClient< TService >::onServiceRequestReceived ( void(T::*)(const std::shared_ptr< typename TService::Request >, std::shared_ptr< typename TService::Response >)  callback,
T *  object 
)
inline

Definition at line 54 of file smacc_service_server_client.hpp.

59 {
61 onServiceRequestReceived_, callback, object);
62 }
ISmaccStateMachine * getStateMachine()
boost::signals2::connection createSignalConnection(TSmaccSignal &signal, TMemberFunctionPrototype callback, TSmaccObjectType *object)
smacc2::SmaccSignal< void(const std::shared_ptr< typename TService::Request >, std::shared_ptr< typename TService::Response >)> onServiceRequestReceived_

References smacc2::ISmaccStateMachine::createSignalConnection(), smacc2::ISmaccClient::getStateMachine(), and smacc2::client_bases::SmaccServiceServerClient< TService >::onServiceRequestReceived_.

Here is the call graph for this function:

◆ serviceCallback()

template<typename TService >
void smacc2::client_bases::SmaccServiceServerClient< TService >::serviceCallback ( const std::shared_ptr< typename TService::Request >  req,
std::shared_ptr< typename TService::Response >  res 
)
inlineprivate

Member Data Documentation

◆ initialized_

template<typename TService >
bool smacc2::client_bases::SmaccServiceServerClient< TService >::initialized_
private

◆ onServiceRequestReceived_

template<typename TService >
smacc2::SmaccSignal<void( const std::shared_ptr<typename TService::Request>, std::shared_ptr<typename TService::Response>)> smacc2::client_bases::SmaccServiceServerClient< TService >::onServiceRequestReceived_

◆ server_

template<typename TService >
rclcpp::Service<TService>::SharedPtr smacc2::client_bases::SmaccServiceServerClient< TService >::server_
private

◆ serviceName_

template<typename TService >
std::optional<std::string> smacc2::client_bases::SmaccServiceServerClient< TService >::serviceName_

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