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

#include <smacc_service_server_client.h>

Inheritance diagram for smacc::client_bases::SmaccServiceServerClient< TService >:
Inheritance graph
Collaboration diagram for smacc::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)(TServiceRequest &, std::shared_ptr< TServiceResponse >), T *object)
 
virtual void initialize () override
 
- Public Member Functions inherited from smacc::ISmaccClient
 ISmaccClient ()
 
virtual ~ISmaccClient ()
 
virtual void initialize ()
 
virtual std::string getName () const
 
template<typename EventType >
void postEvent (const EventType &ev)
 
template<typename EventType >
void postEvent ()
 
template<typename TComponent >
TComponent * getComponent ()
 
template<typename TComponent >
TComponent * getComponent (std::string name)
 
virtual smacc::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)
 

Public Attributes

boost::optional< std::string > serviceName_
 
smacc::SmaccSignal< void(TServiceRequest &, std::shared_ptr< TServiceResponse >)> onServiceRequestReceived_
 

Protected Attributes

ros::NodeHandle nh_
 
- Protected Attributes inherited from smacc::ISmaccClient
std::map< ComponentKey, std::shared_ptr< smacc::ISmaccComponent > > components_
 

Private Types

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

Private Member Functions

bool serviceCallback (TServiceRequest &req, TServiceResponse &res)
 

Private Attributes

ros::ServiceServer server_
 
bool initialized_
 

Additional Inherited Members

- Protected Member Functions inherited from smacc::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)
 
void setStateMachine (ISmaccStateMachine *stateMachine)
 
void setOrthogonal (ISmaccOrthogonal *orthogonal)
 

Detailed Description

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

Definition at line 12 of file smacc_service_server_client.h.

Member Typedef Documentation

◆ TServiceRequest

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

Definition at line 13 of file smacc_service_server_client.h.

◆ TServiceResponse

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

Definition at line 14 of file smacc_service_server_client.h.

Constructor & Destructor Documentation

◆ SmaccServiceServerClient() [1/2]

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

◆ SmaccServiceServerClient() [2/2]

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

◆ ~SmaccServiceServerClient()

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

Member Function Documentation

◆ initialize()

template<typename TService >
virtual void smacc::client_bases::SmaccServiceServerClient< TService >::initialize ( )
inlineoverridevirtual

Reimplemented from smacc::ISmaccClient.

Definition at line 37 of file smacc_service_server_client.h.

37 {
38 if (!initialized_) {
39 if (!serviceName_) {
40 ROS_ERROR("service server with no service name set. Skipping.");
41 } else {
42 ROS_INFO_STREAM("[" << this->getName()
43 << "] Client Service: " << serviceName_);
44
45 server_ = nh_.advertiseService(
47 this);
48 this->initialized_ = true;
49 }
50 }
51 }
virtual std::string getName() const
Definition: client.cpp:34
bool serviceCallback(TServiceRequest &req, TServiceResponse &res)

References smacc::ISmaccClient::getName(), smacc::client_bases::SmaccServiceServerClient< TService >::initialized_, smacc::client_bases::SmaccServiceServerClient< TService >::nh_, smacc::client_bases::SmaccServiceServerClient< TService >::server_, and smacc::client_bases::SmaccServiceServerClient< TService >::serviceName_.

Here is the call graph for this function:

◆ onServiceRequestReceived()

template<typename TService >
template<typename T >
boost::signals2::connection smacc::client_bases::SmaccServiceServerClient< TService >::onServiceRequestReceived ( void(T::*)(TServiceRequest &, std::shared_ptr< TServiceResponse >)  callback,
T *  object 
)
inline

Definition at line 30 of file smacc_service_server_client.h.

32 {
34 onServiceRequestReceived_, callback, object);
35 }
ISmaccStateMachine * getStateMachine()
boost::signals2::connection createSignalConnection(TSmaccSignal &signal, TMemberFunctionPrototype callback, TSmaccObjectType *object)
smacc::SmaccSignal< void(TServiceRequest &, std::shared_ptr< TServiceResponse >)> onServiceRequestReceived_

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

Here is the call graph for this function:

◆ serviceCallback()

template<typename TService >
bool smacc::client_bases::SmaccServiceServerClient< TService >::serviceCallback ( TServiceRequest req,
TServiceResponse res 
)
inlineprivate

Definition at line 57 of file smacc_service_server_client.h.

58 {
59 std::shared_ptr<TServiceResponse> response{new TServiceResponse};
60 onServiceRequestReceived_(req, response);
61 res = *response;
62 return true;
63 }

References smacc::client_bases::SmaccServiceServerClient< TService >::onServiceRequestReceived_.

Member Data Documentation

◆ initialized_

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

◆ nh_

template<typename TService >
ros::NodeHandle smacc::client_bases::SmaccServiceServerClient< TService >::nh_
protected

◆ onServiceRequestReceived_

template<typename TService >
smacc::SmaccSignal<void(TServiceRequest&, std::shared_ptr<TServiceResponse>)> smacc::client_bases::SmaccServiceServerClient< TService >::onServiceRequestReceived_

◆ server_

template<typename TService >
ros::ServiceServer smacc::client_bases::SmaccServiceServerClient< TService >::server_
private

◆ serviceName_

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

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