SMACC2
Loading...
Searching...
No Matches
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 (std::string serviceName)
 
 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 ()
 
 ISmaccClient (const ISmaccClient &)=delete
 
ISmaccClient & operator= (const ISmaccClient &)=delete
 
 ISmaccClient (ISmaccClient &&)=delete
 
ISmaccClient & operator= (ISmaccClient &&)=delete
 
virtual std::string getName () const
 
template<typename TComponent >
TComponent * getComponent ()
 
template<typename TComponent >
TComponent * getComponent (const std::string &name)
 
template<typename TComponent >
TComponent * getComponent (int index)
 
virtual smacc2::introspection::TypeInfo::Ptr getType ()
 
ISmaccStateMachine * getStateMachine ()
 
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_
 

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 TClient >
void onComponentInitialization ()
 
template<typename TOrthogonal , typename TSourceObject >
void onStateOrthogonalAllocation ()
 
template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentType * createComponent (const TArgs &... targs)
 
template<typename SmaccComponentType , typename TOrthogonal , typename TClient , typename... TArgs>
SmaccComponentType * createNamedComponent (const std::string &name, const 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() [1/2]

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

◆ SmaccServiceClient() [2/2]

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 61 of file smacc_service_client.hpp.

63 {
64 auto result = client_->async_send_request(request);
65 //rclcpp::spin_until_future_complete(getNode(), result);
66 return result.get();
67 }
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 43 of file smacc_service_client.hpp.

44 {
45 if (!initialized_)
46 {
47 if (!serviceName_)
48 {
49 RCLCPP_ERROR(getLogger(), "service client with no service name set. Skipping.");
50 }
51 else
52 {
53 RCLCPP_INFO_STREAM(
54 getLogger(), "[" << this->getName() << "] Client Service: " << *serviceName_);
55 this->initialized_ = true;
56 client_ = getNode()->template create_client<ServiceType>(*serviceName_);
57 }
58 }
59 }
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_

◆ 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: