Represents signal emitter with a specified event type.
More...
#include <Event.hpp>
|
| using | Function = void(*)(const S &, const E &) |
| |
| using | Lambda = std::function< void(const S &sender, const E &event)> |
| |
|
| | Event (const S &sender) |
| | Constructor. More...
|
| |
| template<typename T > |
| void | subscribe (const T &instance, void(T::*method)(const S &, const E &)) const |
| | Subscribes method of instance to the event passed by constant reference. The subscription is unique. More...
|
| |
| template<typename T > |
| void | subscribe (std::shared_ptr< T > instance, void(T::*method)(const S &, const E &)) const |
| | Subscribes method of instance to the event passed by constant reference. The subscription is unique. More...
|
| |
| void | subscribe (Function subscriber) const |
| | Subscribes function to the event. More...
|
| |
| void | subscribe (Lambda subscriber) const |
| | Subscribes lambda expression to the event. More...
|
| |
| template<typename T > |
| bool | unsubscribe (const T &instance, void(T::*method)(const S &, const E &)) const |
| | Unsubscribes from the event. More...
|
| |
| template<typename T > |
| bool | unsubscribe (std::shared_ptr< T > instance, void(T::*method)(const S &, const E &)) const |
| | Unsubscribes from the event. More...
|
| |
| bool | unsubscribe (Function subscriber) const |
| | Unsubscribes from the event. More...
|
| |
| template<typename T > |
| bool | hasSubscriber (const T &instance, void(T::*method)(const S &, const E &)) const |
| | Indicates that the receiver is already subscribed to the event. More...
|
| |
| template<typename T > |
| bool | hasSubscriber (std::shared_ptr< T > instance, void(T::*method)(const S &, const E &)) const |
| | Indicates that the receiver is already subscribed to the event. More...
|
| |
| bool | hasSubscriber (Function subscriber) const |
| | Indicates that the receiver is already subscribed to the event. More...
|
| |
| bool | isEmpty () const |
| | Indicates that subsciprion is empty. More...
|
| |
| size_t | getSubscribersCount () const |
| | Returns number of recveivers. More...
|
| |
| void | emit (const E &event) |
| | Emits event. More...
|
| |
| void | unsubscribeAll () |
| | Clear all subscribers. More...
|
| |
template<typename E, typename S>
class CppMate::Event< E, S >
Represents signal emitter with a specified event type.
◆ Function
template<typename E , typename S >
Signature of event receiver function.
◆ Lambda
template<typename E , typename S >
Lambda type of the event receiver.
◆ Event()
template<typename E , typename S >
Constructor.
- Parameters
-
| sender | the instance of signal sender. |
◆ emit()
template<typename E , typename S >
◆ getSubscribersCount()
template<typename E , typename S >
Returns number of recveivers.
- Returns
- number of recveivers.
◆ hasSubscriber() [1/3]
template<typename E , typename S >
template<typename T >
| bool CppMate::Event< E, S >::hasSubscriber |
( |
const T & |
instance, |
|
|
void(T::*)(const S &, const E &) |
method |
|
) |
| const |
|
inline |
Indicates that the receiver is already subscribed to the event.
- Parameters
-
| instance | the class instance. |
| method | the class method. |
- Returns
true if receiver is subcribed; false otherwise.
◆ hasSubscriber() [2/3]
template<typename E , typename S >
Indicates that the receiver is already subscribed to the event.
- Parameters
-
| subscriber | the receiver function. |
- Returns
true if receiver is subcribed; false otherwise.
◆ hasSubscriber() [3/3]
template<typename E , typename S >
template<typename T >
| bool CppMate::Event< E, S >::hasSubscriber |
( |
std::shared_ptr< T > |
instance, |
|
|
void(T::*)(const S &, const E &) |
method |
|
) |
| const |
|
inline |
Indicates that the receiver is already subscribed to the event.
- Parameters
-
| instance | the shared pointer to class instance. |
| method | the class method. |
- Returns
true if receiver is subcribed; false otherwise.
◆ isEmpty()
template<typename E , typename S >
Indicates that subsciprion is empty.
- Returns
true if subscription list is empty; false otherwise.
◆ subscribe() [1/4]
template<typename E , typename S >
template<typename T >
| void CppMate::Event< E, S >::subscribe |
( |
const T & |
instance, |
|
|
void(T::*)(const S &, const E &) |
method |
|
) |
| const |
|
inline |
Subscribes method of instance to the event passed by constant reference. The subscription is unique.
- Parameters
-
| instance | the class instance. |
| method | the class method. |
- Note
- Signature of method should be:
void receiver(const S& sender, const E& event).
◆ subscribe() [2/4]
template<typename E , typename S >
Subscribes function to the event.
- Parameters
-
| subscriber | pointer to a function which receives an event. |
- Exceptions
-
◆ subscribe() [3/4]
template<typename E , typename S >
Subscribes lambda expression to the event.
- Parameters
-
| subscriber | the subscriber. |
◆ subscribe() [4/4]
template<typename E , typename S >
template<typename T >
| void CppMate::Event< E, S >::subscribe |
( |
std::shared_ptr< T > |
instance, |
|
|
void(T::*)(const S &, const E &) |
method |
|
) |
| const |
|
inline |
Subscribes method of instance to the event passed by constant reference. The subscription is unique.
- Parameters
-
| instance | the shared pointer to class instance. |
| method | the class method. |
- Note
- Signature of method should be:
void receiver(const S& sender, const E& event).
- Exceptions
-
◆ unsubscribe() [1/3]
template<typename E , typename S >
template<typename T >
| bool CppMate::Event< E, S >::unsubscribe |
( |
const T & |
instance, |
|
|
void(T::*)(const S &, const E &) |
method |
|
) |
| const |
|
inline |
Unsubscribes from the event.
- Parameters
-
| instance | the class instance. |
| method | the class method. |
- Returns
true if receiver was removed; false otherwise.
◆ unsubscribe() [2/3]
template<typename E , typename S >
Unsubscribes from the event.
- Parameters
-
| subscriber | the receiver function. |
- Returns
true if receiver was removed; false otherwise.
- Exceptions
-
◆ unsubscribe() [3/3]
template<typename E , typename S >
template<typename T >
| bool CppMate::Event< E, S >::unsubscribe |
( |
std::shared_ptr< T > |
instance, |
|
|
void(T::*)(const S &, const E &) |
method |
|
) |
| const |
|
inline |
Unsubscribes from the event.
- Parameters
-
| instance | the shared pointer to class instance. |
| method | the class method. |
- Returns
true if receiver was removed; false otherwise.
- Exceptions
-
◆ unsubscribeAll()
template<typename E , typename S >
The documentation for this class was generated from the following file: