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

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() [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 58 of file smacc_service_client.hpp.

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

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