SMACC2
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Attributes | List of all members
smacc2::client_bases::SmaccServiceClient< ServiceType > Class Template Reference

#include <smacc_service_client.hpp>

Inheritance diagram for smacc2::client_bases::SmaccServiceClient< ServiceType >:
Inheritance graph
Collaboration diagram for smacc2::client_bases::SmaccServiceClient< ServiceType >:
Collaboration graph

Public Member Functions

 SmaccServiceClient ()
 
void onInitialize () override
 
std::shared_ptr< typename ServiceType::Response > call (std::shared_ptr< typename ServiceType::Request > &request)
 
- 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)
 
template<typename EventType >
void postEvent (const EventType &ev)
 
template<typename EventType >
void postEvent ()
 

Public Attributes

std::optional< std::string > serviceName_
 

Protected Attributes

std::shared_ptr< rclcpp::Client< ServiceType > > client_
 
bool initialized_
 
- Protected Attributes inherited from smacc2::ISmaccClient
std::map< ComponentKey, std::shared_ptr< smacc2::ISmaccComponent > > components_
 

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 ()
 

Detailed Description

template<typename ServiceType>
class smacc2::client_bases::SmaccServiceClient< ServiceType >

Definition at line 31 of file smacc_service_client.hpp.

Constructor & Destructor Documentation

◆ SmaccServiceClient()

template<typename ServiceType >
smacc2::client_bases::SmaccServiceClient< ServiceType >::SmaccServiceClient ( )
inline

Member Function Documentation

◆ call()

template<typename ServiceType >
std::shared_ptr< typename ServiceType::Response > smacc2::client_bases::SmaccServiceClient< ServiceType >::call ( std::shared_ptr< typename ServiceType::Request > &  request)
inline

Definition at line 56 of file smacc_service_client.hpp.

58 {
59 auto result = client_->async_send_request(request);
60 //rclcpp::spin_until_future_complete(getNode(), result);
61 return result.get();
62 }
std::shared_ptr< rclcpp::Client< ServiceType > > client_

References smacc2::client_bases::SmaccServiceClient< ServiceType >::client_.

◆ onInitialize()

template<typename ServiceType >
void smacc2::client_bases::SmaccServiceClient< ServiceType >::onInitialize ( )
inlineoverridevirtual

Reimplemented from smacc2::ISmaccClient.

Definition at line 38 of file smacc_service_client.hpp.

39 {
40 if (!initialized_)
41 {
42 if (!serviceName_)
43 {
44 RCLCPP_ERROR(getLogger(), "service client with no service name set. Skipping.");
45 }
46 else
47 {
48 RCLCPP_INFO_STREAM(
49 getLogger(), "[" << this->getName() << "] Client Service: " << *serviceName_);
50 this->initialized_ = true;
51 client_ = getNode()->create_client<ServiceType>(*serviceName_);
52 }
53 }
54 }
rclcpp::Node::SharedPtr getNode()
Definition: client.cpp:60
virtual std::string getName() const
Definition: client.cpp:42
rclcpp::Logger getLogger()

References smacc2::client_bases::SmaccServiceClient< ServiceType >::client_, smacc2::ISmaccClient::getLogger(), smacc2::ISmaccClient::getName(), smacc2::ISmaccClient::getNode(), smacc2::client_bases::SmaccServiceClient< ServiceType >::initialized_, and smacc2::client_bases::SmaccServiceClient< ServiceType >::serviceName_.

Here is the call graph for this function:

Member Data Documentation

◆ client_

template<typename ServiceType >
std::shared_ptr<rclcpp::Client<ServiceType> > smacc2::client_bases::SmaccServiceClient< ServiceType >::client_
protected

◆ initialized_

template<typename ServiceType >
bool smacc2::client_bases::SmaccServiceClient< ServiceType >::initialized_
protected

◆ serviceName_

template<typename ServiceType >
std::optional<std::string> smacc2::client_bases::SmaccServiceClient< ServiceType >::serviceName_

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