Template Class CMsgSubscriber#

Inheritance Relationships#

Base Type#

Class Documentation#

template<typename T>
class CMsgSubscriber : public eCAL::CSubscriber#

eCAL abstract message subscriber class.

Abstract subscriber template class for messages. For details see documentation of CPublisher class.

Public Types

typedef std::function<void(const char *topic_name_, const T &msg_, long long time_, long long clock_, long long id_)> MsgReceiveCallbackT#

eCAL message receive callback function

Param topic_name_:

Topic name of the data source (publisher).

Param msg_:

Message content.

Param time_:

Message time stamp.

Param clock_:

Message writer clock.

Param id_:

Message id.

Public Functions

inline CMsgSubscriber()#

Constructor.

inline CMsgSubscriber(const std::string &topic_name_, const std::string &topic_type_ = "", const std::string &topic_desc_ = "")#

Constructor.

Deprecated:

Please use the constructor CMsgSubscriber(const std::string& topic_name_, const SDataTypeInformation& topic_info_) instead. This function will be removed in future eCAL versions.

Parameters:
  • topic_name_ – Unique topic name.

  • topic_type_ – Type name (optional for type checking).

  • topic_desc_ – Type description (optional for description checking).

inline CMsgSubscriber(const std::string &topic_name_, const SDataTypeInformation &topic_info_)#

Constructor.

Parameters:
  • topic_name_ – Unique topic name.

  • topic_info_ – Topic type information (encoding, type, descriptor).

virtual ~CMsgSubscriber() = default#
CMsgSubscriber(const CMsgSubscriber&) = delete#

Copy Constructor is not available.

CMsgSubscriber &operator=(const CMsgSubscriber&) = delete#

Copy Constructor is not available.

inline CMsgSubscriber(CMsgSubscriber &&rhs)#

Move Constructor.

inline CMsgSubscriber &operator=(CMsgSubscriber &&rhs)#

Move assignment.

inline bool Create(const std::string &topic_name_, const std::string &topic_type_ = "", const std::string &topic_desc_ = "")#

Creates this object.

Deprecated:

Please use the method CMsgSubscriber(const std::string& topic_name_, const SDataTypeInformation& topic_info_) instead. This function will be removed in future eCAL versions.

Parameters:
  • topic_name_ – Unique topic name.

  • topic_type_ – Type name (optional for type checking).

  • topic_desc_ – Type description (optional for description checking).

Returns:

true if it succeeds, false if it fails.

inline bool Create(const std::string &topic_name_, const SDataTypeInformation &topic_info_)#

Creates this object.

Parameters:
  • topic_name_ – Unique topic name.

  • topic_info_ – Topic type information (encoding, type, descriptor).

Returns:

true if it succeeds, false if it fails.

inline bool Destroy()#

Destroys this object.

Returns:

true if it succeeds, false if it fails.

inline bool Receive(T &msg_, long long *time_ = nullptr, int rcv_timeout_ = 0) const#

Receive deserialized message.

Parameters:
  • msg_[out] The message object.

  • time_[out] Optional receive time stamp.

  • rcv_timeout_ – Receive timeout in ms.

Returns:

True if a message could received, false otherwise.

inline bool AddReceiveCallback(MsgReceiveCallbackT callback_)#

Add receive callback for incoming messages.

Parameters:

callback_ – The callback function.

Returns:

True if it succeeds, false if it fails.

inline bool RemReceiveCallback()#

Remove receive callback for incoming messages.

Returns:

True if it succeeds, false if it fails.