hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
iroha::subscription::SubscriberImpl< EventKey, Dispatcher, Receiver, Arguments > Class Template Reference

#include "subscription_fwd.hpp"

Inheritance diagram for iroha::subscription::SubscriberImpl< EventKey, Dispatcher, Receiver, Arguments >:
Inheritance graph
Collaboration diagram for iroha::subscription::SubscriberImpl< EventKey, Dispatcher, Receiver, Arguments >:
Collaboration graph

Public Types

using ReceiverType = Receiver
 
using Hash = size_t
 
using Parent = Subscriber< EventKey, Dispatcher, Arguments... >
 
using SubscriptionEngineType = SubscriptionEngine< typename Parent::EventType, Dispatcher, Subscriber< typename Parent::EventType, Dispatcher, Arguments... > >
 
using SubscriptionEnginePtr = std::shared_ptr< SubscriptionEngineType >
 
using SubscriptionEngineWPtr = std::weak_ptr< SubscriptionEngineType >
 
using CallbackFnType = std::function< void(SubscriptionSetId, ReceiverType &, const typename Parent::EventType &, Arguments &&...)>
 
- Public Types inherited from iroha::subscription::Subscriber< EventKey, Dispatcher, Arguments... >
using EventType = EventKey
 

Public Member Functions

 ~SubscriberImpl ()
 
void setCallback (CallbackFnType &&f)
 
SubscriptionSetId generateSubscriptionSetId ()
 
void subscribe (SubscriptionSetId id, const typename Parent::EventType &key, typename Dispatcher::Tid tid=Dispatcher::kExecuteInPool)
 
bool unsubscribe (SubscriptionSetId id, const typename Parent::EventType &key)
 
bool unsubscribe (SubscriptionSetId id)
 
void unsubscribe ()
 
void on_notify (SubscriptionSetId set_id, const typename Parent::EventType &key, Arguments &&... args) override
 
ReceiverTypeget ()
 
- Public Member Functions inherited from iroha::subscription::Subscriber< EventKey, Dispatcher, Arguments... >
virtual ~Subscriber ()=default
 
virtual void on_notify (SubscriptionSetId set_id, const EventType &key, Arguments &&... args)=0
 

Static Public Member Functions

template<typename... SubscriberConstructorArgs>
static std::shared_ptr< SubscriberImplcreate (SubscriptionEnginePtr const &ptr, SubscriberConstructorArgs &&... args)
 

Detailed Description

template<typename EventKey, typename Dispatcher, typename Receiver, typename... Arguments>
class iroha::subscription::SubscriberImpl< EventKey, Dispatcher, Receiver, Arguments >

Is a wrapper class, which provides subscription to events from SubscriptionEngine

Template Parameters
EventKeyis a type of a particular subscription event (might be a key from an observed storage or a specific event type from an enumeration).
Dispatcherthread dispatcher
Receiveris a type of an object which is a part of Subscriber's internal state and can be accessed on every event notification.
Argumentsis a set of types of objects that are passed on every event notification.

Member Typedef Documentation

◆ CallbackFnType

template<typename EventKey , typename Dispatcher , typename Receiver , typename... Arguments>
using iroha::subscription::SubscriberImpl< EventKey, Dispatcher, Receiver, Arguments >::CallbackFnType = std::function<void(SubscriptionSetId, ReceiverType &, const typename Parent::EventType &, Arguments &&...)>

◆ Hash

template<typename EventKey , typename Dispatcher , typename Receiver , typename... Arguments>
using iroha::subscription::SubscriberImpl< EventKey, Dispatcher, Receiver, Arguments >::Hash = size_t

◆ Parent

template<typename EventKey , typename Dispatcher , typename Receiver , typename... Arguments>
using iroha::subscription::SubscriberImpl< EventKey, Dispatcher, Receiver, Arguments >::Parent = Subscriber<EventKey, Dispatcher, Arguments...>

◆ ReceiverType

template<typename EventKey , typename Dispatcher , typename Receiver , typename... Arguments>
using iroha::subscription::SubscriberImpl< EventKey, Dispatcher, Receiver, Arguments >::ReceiverType = Receiver

◆ SubscriptionEnginePtr

template<typename EventKey , typename Dispatcher , typename Receiver , typename... Arguments>
using iroha::subscription::SubscriberImpl< EventKey, Dispatcher, Receiver, Arguments >::SubscriptionEnginePtr = std::shared_ptr<SubscriptionEngineType>

◆ SubscriptionEngineType

template<typename EventKey , typename Dispatcher , typename Receiver , typename... Arguments>
using iroha::subscription::SubscriberImpl< EventKey, Dispatcher, Receiver, Arguments >::SubscriptionEngineType = SubscriptionEngine< typename Parent::EventType, Dispatcher, Subscriber<typename Parent::EventType, Dispatcher, Arguments...> >

◆ SubscriptionEngineWPtr

template<typename EventKey , typename Dispatcher , typename Receiver , typename... Arguments>
using iroha::subscription::SubscriberImpl< EventKey, Dispatcher, Receiver, Arguments >::SubscriptionEngineWPtr = std::weak_ptr<SubscriptionEngineType>

Constructor & Destructor Documentation

◆ ~SubscriberImpl()

template<typename EventKey , typename Dispatcher , typename Receiver , typename... Arguments>
iroha::subscription::SubscriberImpl< EventKey, Dispatcher, Receiver, Arguments >::~SubscriberImpl ( )
inline

Member Function Documentation

◆ create()

template<typename EventKey , typename Dispatcher , typename Receiver , typename... Arguments>
template<typename... SubscriberConstructorArgs>
static std::shared_ptr<SubscriberImpl> iroha::subscription::SubscriberImpl< EventKey, Dispatcher, Receiver, Arguments >::create ( SubscriptionEnginePtr const &  ptr,
SubscriberConstructorArgs &&...  args 
)
inlinestatic
Here is the caller graph for this function:

◆ generateSubscriptionSetId()

template<typename EventKey , typename Dispatcher , typename Receiver , typename... Arguments>
SubscriptionSetId iroha::subscription::SubscriberImpl< EventKey, Dispatcher, Receiver, Arguments >::generateSubscriptionSetId ( )
inline

◆ get()

template<typename EventKey , typename Dispatcher , typename Receiver , typename... Arguments>
ReceiverType& iroha::subscription::SubscriberImpl< EventKey, Dispatcher, Receiver, Arguments >::get ( )
inline

◆ on_notify()

template<typename EventKey , typename Dispatcher , typename Receiver , typename... Arguments>
void iroha::subscription::SubscriberImpl< EventKey, Dispatcher, Receiver, Arguments >::on_notify ( SubscriptionSetId  set_id,
const typename Parent::EventType key,
Arguments &&...  args 
)
inlineoverride

◆ setCallback()

template<typename EventKey , typename Dispatcher , typename Receiver , typename... Arguments>
void iroha::subscription::SubscriberImpl< EventKey, Dispatcher, Receiver, Arguments >::setCallback ( CallbackFnType &&  f)
inline

◆ subscribe()

template<typename EventKey , typename Dispatcher , typename Receiver , typename... Arguments>
void iroha::subscription::SubscriberImpl< EventKey, Dispatcher, Receiver, Arguments >::subscribe ( SubscriptionSetId  id,
const typename Parent::EventType key,
typename Dispatcher::Tid  tid = Dispatcher::kExecuteInPool 
)
inline

Here we check first local subscriptions because of strong connection with SubscriptionEngine.

◆ unsubscribe() [1/3]

template<typename EventKey , typename Dispatcher , typename Receiver , typename... Arguments>
bool iroha::subscription::SubscriberImpl< EventKey, Dispatcher, Receiver, Arguments >::unsubscribe ( SubscriptionSetId  id,
const typename Parent::EventType key 
)
inline
Parameters
id– subscription set id that unsubscribes from
  • key
key– event key to unsubscribe from
Returns
true if was subscribed to
  • key, false otherwise

◆ unsubscribe() [2/3]

template<typename EventKey , typename Dispatcher , typename Receiver , typename... Arguments>
bool iroha::subscription::SubscriberImpl< EventKey, Dispatcher, Receiver, Arguments >::unsubscribe ( SubscriptionSetId  id)
inline
Parameters
id– subscription set id to unsubscribe from
Returns
true if was subscribed to
  • id, false otherwise

◆ unsubscribe() [3/3]

template<typename EventKey , typename Dispatcher , typename Receiver , typename... Arguments>
void iroha::subscription::SubscriberImpl< EventKey, Dispatcher, Receiver, Arguments >::unsubscribe ( )
inline

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