|
ActiveLib
|
#include <Subscriber.h>


Public Types | |
| enum class | Action { issue = 0 , suspend , renew , discontinue } |
| The action awaited by the subscriber. More... | |
| using | Unique = std::unique_ptr<Subscriber> |
| Unique pointer. | |
| using | Shared = std::shared_ptr<Subscriber> |
| Shared pointer. | |
| using | Weak = std::weak_ptr<Subscriber> |
| Weak pointer. | |
| using | Subscription = std::set<NameID> |
| An event subscription list. | |
Public Types inherited from active::utility::NameID | |
| using | Option = std::optional<NameID> |
| Optional. | |
Public Member Functions | |
| Subscriber (int32_t priority=0) | |
| Subscriber (const utility::NameID &identity, int32_t priority=0) | |
| virtual | ~Subscriber ()=default |
| bool | operator== (const Subscriber &ref) const |
| bool | operator!= (const Subscriber &ref) const |
| virtual bool | getPriority () const |
| virtual Action | action () const |
| virtual Subscription | subscription () const =0 |
| virtual bool | receive (const Event &event)=0 |
Public Member Functions inherited from active::event::Participant | |
| Participant (const utility::NameID &identity=utility::NameID{}) | |
| virtual | ~Participant ()=default |
| bool | operator== (const Participant &ref) const |
| bool | operator!= (const Participant &ref) const |
Public Member Functions inherited from active::utility::NameID | |
| NameID () | |
| NameID (const String &str, const Guid &guid=Guid{}) | |
| NameID (const char *str, const Guid &guid=Guid{}) | |
| NameID (const Guid &guid, const String &str=String{}) | |
| bool | operator== (const NameID &ref) const |
| bool | operator!= (const NameID &ref) const |
| bool | operator< (const NameID &ref) const |
| operator bool () const | |
| void | clear () |
Protected Member Functions | |
| void | setAction (Action action) |
Protected Member Functions inherited from active::event::Participant | |
| virtual bool | audit () |
| virtual bool | attach () |
| virtual bool | start () |
| virtual void | stop () |
Friends | |
| class | Publisher |
Additional Inherited Members | |
Public Attributes inherited from active::utility::NameID | |
| String | name |
| Guid | id |
A class representing an event subscriber
A Subscriber registers an interest with a Publisher for one or more Events. Incoming Events will be issued to Subscribers with a registered interest in order of priority (defined by the Subscriber). Any Subscriber can signal that the Event has been closed, at which point distribution of the event to other Subscribers will cease (e.g. a speific tool has completed a requested task that can only be solved once).
Subscribers are asked to fullfil several tasks:
Note that many subscribers don't need to do anything to fullfil these requirements, e.g. a subscriber with no dependencies has nothing to audit. Generally an 'attach' function is only needed where a subscriber has to notity some other system of its presence in order to receive events, e.g. a tool acting on the selection of a menu in the UI might need to register the menu resources with the UI manager.
Subscribers should wait for the publisher to instigate tasks like attach, initialise or shutdown. This will allow a manager acting as a Publisher to coordinate the actions of all its subscribers (which may be critical in some contexts).
|
strong |
|
inline |
Default constructor
| priority | The subscriber priority (determines the order in which subscribers receive events) |
|
inline |
Constructor
| identity | Name/ID for the subscriber |
| priority | The subscriber priority (determines the order in which subscribers receive events) |
|
virtualdefault |
Destructor
|
inlinevirtual |
Get the subscriber action

|
inlinevirtual |
Get the subscriber priority
|
inline |
Inequality operator
| ref | The object to compare with this |
|
inline |
Equality operator
| ref | The object to compare with this |

|
pure virtual |
Receive a subscribed event
| event | The incoming event |
|
inlineprotected |
Get the subscriber action
| action | The subscriber action |

|
pure virtual |
Get the event subscription list