Class Subscription

Inheritance Relationships

Base Type

Class Documentation

class Subscription : public email::PubSubObject

Message subscription.

Uses emails, with the topic name as the email subject and the data as the email body. TODO(christophebedard) add take to get a vector of all available messages?

Public Functions

explicit Subscription(const std::string &topic_name)

Constructor.

Parameters:

topic_name – the topic name to subscribe to

virtual ~Subscription()
bool has_message() const

Check if the subscription has a message.

Returns:

true if there is a message, false otherwise

std::optional<std::string> get_message()

Get a message if there is one.

This is the same as “taking” a message if there is one.

Returns:

the message, or std::nullopt if there is none

std::optional<std::pair<std::string, MessageInfo>> get_message_with_info()

Get a message with info if there is one.

This is the same as “taking” a message with its info if there is one.

Returns:

the message & message info pair, or std::nullopt if there is none