Zserio C++ runtime library  1.2.0
Built for Zserio 2.16.0
IPubsub.h
Go to the documentation of this file.
1 #ifndef ZSERIO_IPUBSUB_H_INC
2 #define ZSERIO_IPUBSUB_H_INC
3 
4 #include <memory>
5 
6 #include "zserio/Span.h"
7 #include "zserio/StringView.h"
8 #include "zserio/Types.h"
9 
10 namespace zserio
11 {
12 
14 class IPubsub
15 {
16 public:
17  virtual ~IPubsub() = default;
18 
22  using SubscriptionId = size_t;
23 
28  {
29  public:
30  virtual ~OnTopicCallback() = default;
31  virtual void operator()(StringView topic, Span<const uint8_t> data) = 0;
32  };
33 
43  virtual void publish(StringView topic, Span<const uint8_t> data, void* context) = 0;
44 
58  StringView topic, const std::shared_ptr<OnTopicCallback>& callback, void* context) = 0;
59 
67  virtual void unsubscribe(SubscriptionId id) = 0;
68 };
69 
70 } // namespace zserio
71 
72 #endif // ZSERIO_IPUBSUB_H_INC
virtual ~OnTopicCallback()=default
virtual void operator()(StringView topic, Span< const uint8_t > data)=0
virtual SubscriptionId subscribe(StringView topic, const std::shared_ptr< OnTopicCallback > &callback, void *context)=0
virtual void unsubscribe(SubscriptionId id)=0
virtual void publish(StringView topic, Span< const uint8_t > data, void *context)=0
size_t SubscriptionId
Definition: IPubsub.h:22
virtual ~IPubsub()=default