Zserio C++ runtime library  1.1.0
Built for Zserio 2.15.0
zserio::IPubsub Class Referenceabstract

#include <IPubsub.h>

Classes

class  OnTopicCallback
 

Public Types

using SubscriptionId = size_t
 

Public Member Functions

virtual ~IPubsub ()=default
 
virtual void publish (StringView topic, Span< const uint8_t > data, void *context)=0
 
virtual SubscriptionId subscribe (StringView topic, const std::shared_ptr< OnTopicCallback > &callback, void *context)=0
 
virtual void unsubscribe (SubscriptionId id)=0
 

Detailed Description

Interface for Pub/Sub client backends.

Definition at line 14 of file IPubsub.h.

Member Typedef Documentation

◆ SubscriptionId

Subscription ID which is unique for each single subscription.

Definition at line 22 of file IPubsub.h.

Constructor & Destructor Documentation

◆ ~IPubsub()

virtual zserio::IPubsub::~IPubsub ( )
virtualdefault

Member Function Documentation

◆ publish()

virtual void zserio::IPubsub::publish ( StringView  topic,
Span< const uint8_t >  data,
void *  context 
)
pure virtual

Publishes given data as a specified topic.

Parameters
topicTopic definition.
dataData to publish.
contextContext specific for a particular Pub/Sub implementation.
Exceptions
PubsubExceptionwhen publishing fails.

◆ subscribe()

virtual SubscriptionId zserio::IPubsub::subscribe ( StringView  topic,
const std::shared_ptr< OnTopicCallback > &  callback,
void *  context 
)
pure virtual

Subscribes a topic.

Parameters
topicTopic definition to subscribe. Note that the definition format depends on the particular Pub/Sub backend implementation and therefore e.g. wildcards can be used only if they are supported by Pub/Sub backend.
callbackCallback to be called when a message with the specified topic arrives.
contextContext specific for a particular Pub/Sub implementation.
Returns
Subscription ID.
Exceptions
PubsubExceptionwhen subscribing fails.

◆ unsubscribe()

virtual void zserio::IPubsub::unsubscribe ( SubscriptionId  id)
pure virtual

Unsubscribes the subscription with the given ID.

Parameters
idID of the subscription to be unsubscribed.
Exceptions
PubsubExceptionwhen unsubscribing fails.

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