Template Class CMsgSubscriber

Inheritance Relationships

Base Type

Class Documentation

template<typename T>
class eCAL::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

Parameters
  • topic_name_: Topic name of the data source (publisher).

  • msg_: Message content.

  • time_: Message time stamp.

  • clock_: Message writer clock.

  • id_: Message id.

Public Functions

CMsgSubscriber()

Constructor.

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

Constructor.

Parameters
  • topic_name_: Unique topic name.

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

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

CMsgSubscriber(const CMsgSubscriber&) = delete

Copy Constructor is not available.

CMsgSubscriber &operator=(const CMsgSubscriber&) = delete

Copy Constructor is not available.

CMsgSubscriber(CMsgSubscriber &&rhs)

Move Constructor.

CMsgSubscriber &operator=(CMsgSubscriber &&rhs)

Move assignment.

~CMsgSubscriber()
bool Create(const std::string &topic_name_, const std::string &topic_type_ = "", const std::string &topic_desc_ = "")

Creates this object.

Return

true if it succeeds, false if it fails.

Parameters
  • topic_name_: Unique topic name.

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

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

bool Destroy()

Destroys this object.

Return

true if it succeeds, false if it fails.

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

Receive deserialized message.

Return

True if a message could received, false otherwise.

Parameters
  • [out] msg_: The message object.

  • [out] time_: Optional receive time stamp.

  • rcv_timeout_: Receive timeout in ms.

bool AddReceiveCallback(MsgReceiveCallbackT callback_)

Add receive callback for incoming messages.

Return

True if it succeeds, false if it fails.

Parameters
  • callback_: The callback function.

bool RemReceiveCallback()

Remove receive callback for incoming messages.

Return

True if it succeeds, false if it fails.