ActiveLib
Loading...
Searching...
No Matches
Active
Event
Event.h
1
6
#ifndef ACTIVE_EVENT_EVENT
7
#define ACTIVE_EVENT_EVENT
8
9
#include "Active/Event/PostBox.h"
10
#include "Active/Setting/SettingList.h"
11
#include "Active/Utility/NameID.h"
12
13
namespace
active::event
{
14
15
class
Message
;
16
28
class
Event
:
public
utility::NameID
,
public
setting::SettingList
{
29
public
:
30
31
// MARK: - Types
32
34
using
Unique
= std::unique_ptr<Event>;
36
using
Shared
= std::shared_ptr<Event>;
38
using
Option
= std::optional<Event>;
39
40
// MARK: - Constructors
41
45
Event
() {}
51
Event
(
const
utility::NameID
& nameID,
PostBox
* postBox =
nullptr
) : utility::
NameID
{nameID}, setting::
SettingList
{} { m_postBox = postBox; }
58
Event
(
const
NameID
& nameID,
setting::SettingList
&& settings,
PostBox
* postBox =
nullptr
) :
59
utility::
NameID
{nameID}, setting::
SettingList
{std::move(settings)} { m_postBox = postBox; }
63
virtual
~Event
() {}
64
69
virtual
Event
*
clonePtr
()
const
{
return
new
Event
{*
this
}; }
70
71
// MARK: - Operators
72
78
bool
operator==
(
const
Event
& ref)
const
{
return
utility::NameID::operator==
(ref); }
//Events are matched by identity
84
bool
operator==
(
const
NameID
& ref)
const
{
return
utility::NameID::operator==
(ref); }
90
bool
operator!=
(
const
Event
& ref)
const
{
return
!(*
this
== ref); }
91
92
// MARK: - Functions (const)
93
98
void
tellAuthor
(
Message
&& message)
const
{
99
if
(m_postBox !=
nullptr
)
100
m_postBox->
receive
(std::move(message));
101
}
102
103
// MARK: - Functions (mutating)
104
105
106
private
:
107
//The post box for message sent from subscribers to the published event author
108
PostBox
* m_postBox =
nullptr
;
109
};
110
111
}
112
113
#endif
//ACTIVE_EVENT_EVENT
active::event::Event
Definition
Event.h:28
active::event::Event::Event
Event(const NameID &nameID, setting::SettingList &&settings, PostBox *postBox=nullptr)
Definition
Event.h:58
active::event::Event::operator==
bool operator==(const Event &ref) const
Definition
Event.h:78
active::event::Event::clonePtr
virtual Event * clonePtr() const
Definition
Event.h:69
active::event::Event::tellAuthor
void tellAuthor(Message &&message) const
Definition
Event.h:98
active::event::Event::Unique
std::unique_ptr< Event > Unique
Unique pointer.
Definition
Event.h:34
active::event::Event::Event
Event(const utility::NameID &nameID, PostBox *postBox=nullptr)
Definition
Event.h:51
active::event::Event::operator!=
bool operator!=(const Event &ref) const
Definition
Event.h:90
active::event::Event::Option
std::optional< Event > Option
Optional.
Definition
Event.h:38
active::event::Event::Event
Event()
Definition
Event.h:45
active::event::Event::Shared
std::shared_ptr< Event > Shared
Shared pointer.
Definition
Event.h:36
active::event::Event::~Event
virtual ~Event()
Definition
Event.h:63
active::event::Message
Definition
Message.h:18
active::event::PostBox
Definition
PostBox.h:18
active::event::PostBox::receive
virtual void receive(Message &&message)
Definition
PostBox.h:32
active::setting::SettingList
A list of settings.
Definition
SettingList.h:15
active::setting::SettingList::SettingList
SettingList()
Definition
SettingList.h:36
active::utility::NameID
Definition
NameID.h:21
active::utility::NameID::NameID
NameID()
Definition
NameID.h:34
active::utility::NameID::operator==
bool operator==(const NameID &ref) const
Definition
NameID.h:68
active::event
Definition
Event.h:13
Generated by
1.10.0