TSDuck v3.45-4766
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::SubscriptionBase Class Reference

Base class for subscription to events. More...

#include <tsSubscriptionBase.h>

Inheritance diagram for ts::SubscriptionBase:

Public Member Functions

 SubscriptionBase ()=default
 Default constructor.
 
virtual ~SubscriptionBase ()
 Virtual destructor.
 
void addSubscription (SubscriptionHandlerInterface *handler)
 Add a subscriber to open/close events.
 
void cancelSubscription (SubscriptionHandlerInterface *handler)
 Remove a subscriber to open/close events.
 

Protected Member Functions

template<typename HANDLER , typename F >
requires std::derived_from<HANDLER, SubscriptionHandlerInterface>
void callSubscribers (F &&func)
 Call a handler on all subscribers, using a lambda expression.
 

Detailed Description

Base class for subscription to events.

Used as base class in Socket and other socket wrappers which intercept socket events.

Important: the subcription mechanism is not thread-safe. The instance of SubscriptionBase and all its subscribers must be used from one single thread.

Member Function Documentation

◆ addSubscription()

void ts::SubscriptionBase::addSubscription ( SubscriptionHandlerInterface handler)

Add a subscriber to open/close events.

Parameters
[in]handlerThe object to call on open() and close().

◆ cancelSubscription()

void ts::SubscriptionBase::cancelSubscription ( SubscriptionHandlerInterface handler)

Remove a subscriber to open/close events.

Parameters
[in]handlerThe object to no longer call on open() and close().

◆ callSubscribers()

template<typename HANDLER , typename F >
requires std::derived_from<HANDLER, SubscriptionHandlerInterface>
void ts::SubscriptionBase::callSubscribers ( F &&  func)
inlineprotected

Call a handler on all subscribers, using a lambda expression.

Parameters
[in]funcFunction to call as lambda expression.

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