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