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

#include <smacc_subscriber_client.h>

Inheritance diagram for smacc::client_bases::SmaccSubscriberClient< MessageType >:
Inheritance graph
Collaboration diagram for smacc::client_bases::SmaccSubscriberClient< MessageType >:
Collaboration graph

Public Types

typedef MessageType TMessageType
 

Public Member Functions

 SmaccSubscriberClient ()
 
 SmaccSubscriberClient (std::string topicname)
 
virtual ~SmaccSubscriberClient ()
 
template<typename T >
boost::signals2::connection onMessageReceived (void(T::*callback)(const MessageType &), T *object)
 
template<typename T >
boost::signals2::connection onFirstMessageReceived (void(T::*callback)(const MessageType &), T *object)
 
template<typename TOrthogonal , typename TSourceObject >
void onOrthogonalAllocation ()
 
virtual void initialize ()
 
- 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 > topicName
 
boost::optional< int > queueSize
 
smacc::SmaccSignal< void(const MessageType &)> onFirstMessageReceived_
 
smacc::SmaccSignal< void(const MessageType &)> onMessageReceived_
 
std::function< void(const MessageType &)> postMessageEvent
 
std::function< void(const MessageType &)> postInitialMessageEvent
 

Protected Attributes

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

Private Member Functions

void messageCallback (const MessageType &msg)
 

Private Attributes

ros::Subscriber sub_
 
bool firstMessage_
 
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 MessageType>
class smacc::client_bases::SmaccSubscriberClient< MessageType >

Definition at line 22 of file smacc_subscriber_client.h.

Member Typedef Documentation

◆ TMessageType

template<typename MessageType >
typedef MessageType smacc::client_bases::SmaccSubscriberClient< MessageType >::TMessageType

Definition at line 28 of file smacc_subscriber_client.h.

Constructor & Destructor Documentation

◆ SmaccSubscriberClient() [1/2]

template<typename MessageType >
smacc::client_bases::SmaccSubscriberClient< MessageType >::SmaccSubscriberClient ( )
inline

◆ SmaccSubscriberClient() [2/2]

template<typename MessageType >
smacc::client_bases::SmaccSubscriberClient< MessageType >::SmaccSubscriberClient ( std::string  topicname)
inline

Definition at line 35 of file smacc_subscriber_client.h.

36 {
37 topicName = topicname;
38 }

References smacc::client_bases::SmaccSubscriberClient< MessageType >::topicName.

◆ ~SmaccSubscriberClient()

template<typename MessageType >
virtual smacc::client_bases::SmaccSubscriberClient< MessageType >::~SmaccSubscriberClient ( )
inlinevirtual

Member Function Documentation

◆ initialize()

template<typename MessageType >
virtual void smacc::client_bases::SmaccSubscriberClient< MessageType >::initialize ( )
inlinevirtual

Reimplemented from smacc::ISmaccClient.

Reimplemented in cl_keyboard::ClKeyboard, and cl_multirole_sensor::ClMultiroleSensor< MessageType >.

Definition at line 79 of file smacc_subscriber_client.h.

80 {
81 if (!initialized_)
82 {
83 firstMessage_ = true;
84
85 if (!queueSize)
86 queueSize = 1;
87
88 if (!topicName)
89 {
90 ROS_ERROR("topic client with no topic name set. Skipping subscribing");
91 }
92 else
93 {
94 ROS_INFO_STREAM("[" << this->getName() << "] Subscribing to topic: " << topicName);
95
97 this->initialized_ = true;
98 }
99 }
100 }
virtual std::string getName() const
Definition: client.cpp:34

References smacc::client_bases::SmaccSubscriberClient< MessageType >::firstMessage_, smacc::ISmaccClient::getName(), smacc::client_bases::SmaccSubscriberClient< MessageType >::initialized_, smacc::client_bases::SmaccSubscriberClient< MessageType >::nh_, smacc::client_bases::SmaccSubscriberClient< MessageType >::queueSize, smacc::client_bases::SmaccSubscriberClient< MessageType >::sub_, and smacc::client_bases::SmaccSubscriberClient< MessageType >::topicName.

Referenced by cl_multirole_sensor::ClMultiroleSensor< MessageType >::initialize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ messageCallback()

template<typename MessageType >
void smacc::client_bases::SmaccSubscriberClient< MessageType >::messageCallback ( const MessageType &  msg)
inlineprivate

◆ onFirstMessageReceived()

template<typename MessageType >
template<typename T >
boost::signals2::connection smacc::client_bases::SmaccSubscriberClient< MessageType >::onFirstMessageReceived ( void(T::*)(const MessageType &)  callback,
T *  object 
)
inline

Definition at line 58 of file smacc_subscriber_client.h.

59 {
60 return this->getStateMachine()->createSignalConnection(onFirstMessageReceived_, callback, object);
61 }
ISmaccStateMachine * getStateMachine()
boost::signals2::connection createSignalConnection(TSmaccSignal &signal, TMemberFunctionPrototype callback, TSmaccObjectType *object)

References smacc::ISmaccStateMachine::createSignalConnection(), and smacc::ISmaccClient::getStateMachine().

Here is the call graph for this function:

◆ onMessageReceived()

template<typename MessageType >
template<typename T >
boost::signals2::connection smacc::client_bases::SmaccSubscriberClient< MessageType >::onMessageReceived ( void(T::*)(const MessageType &)  callback,
T *  object 
)
inline

Definition at line 52 of file smacc_subscriber_client.h.

53 {
54 return this->getStateMachine()->createSignalConnection(onMessageReceived_, callback, object);
55 }

References smacc::ISmaccStateMachine::createSignalConnection(), and smacc::ISmaccClient::getStateMachine().

Referenced by cl_multirole_sensor::ClMultiroleSensor< MessageType >::initialize(), and smacc::CbSubscriptionCallbackBase< TMsg >::onEntry().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onOrthogonalAllocation()

template<typename MessageType >
template<typename TOrthogonal , typename TSourceObject >
void smacc::client_bases::SmaccSubscriberClient< MessageType >::onOrthogonalAllocation ( )
inline

Definition at line 64 of file smacc_subscriber_client.h.

65 {
66 this->postMessageEvent = [=](auto msg) {
67 auto event = new EvTopicMessage<TSourceObject, TOrthogonal>();
68 event->msgData = msg;
69 this->postEvent(event);
70 };
71
72 this->postInitialMessageEvent = [=](auto msg) {
73 auto event = new EvTopicInitialMessage<TSourceObject, TOrthogonal>();
74 event->msgData = msg;
75 this->postEvent(event);
76 };
77 }

References smacc::ISmaccClient::postEvent().

Here is the call graph for this function:

Member Data Documentation

◆ firstMessage_

template<typename MessageType >
bool smacc::client_bases::SmaccSubscriberClient< MessageType >::firstMessage_
private

◆ initialized_

template<typename MessageType >
bool smacc::client_bases::SmaccSubscriberClient< MessageType >::initialized_
private

◆ nh_

template<typename MessageType >
ros::NodeHandle smacc::client_bases::SmaccSubscriberClient< MessageType >::nh_
protected

◆ onFirstMessageReceived_

template<typename MessageType >
smacc::SmaccSignal<void(const MessageType &)> smacc::client_bases::SmaccSubscriberClient< MessageType >::onFirstMessageReceived_

◆ onMessageReceived_

template<typename MessageType >
smacc::SmaccSignal<void(const MessageType &)> smacc::client_bases::SmaccSubscriberClient< MessageType >::onMessageReceived_

◆ postInitialMessageEvent

template<typename MessageType >
std::function<void(const MessageType &)> smacc::client_bases::SmaccSubscriberClient< MessageType >::postInitialMessageEvent

◆ postMessageEvent

template<typename MessageType >
std::function<void(const MessageType &)> smacc::client_bases::SmaccSubscriberClient< MessageType >::postMessageEvent

◆ queueSize

template<typename MessageType >
boost::optional<int> smacc::client_bases::SmaccSubscriberClient< MessageType >::queueSize

◆ sub_

template<typename MessageType >
ros::Subscriber smacc::client_bases::SmaccSubscriberClient< MessageType >::sub_
private

◆ topicName

template<typename MessageType >
boost::optional<std::string> smacc::client_bases::SmaccSubscriberClient< MessageType >::topicName

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