A thread-safe class to manage a signal and its tracking connections.
More...
#include <TrackableSignal.hpp>
|
bool | connectTrackableSlot (ConnectionSharedPtr const &trackable, std::function< void(Args...)> slot) |
| Connect a slot to the signal, the slot will be called when the signal is emitted and trackable is still alive.
|
|
bool | disconnect (ConnectionPtr trackablePtr) |
| Disconnect a slot to the signal.
|
|
void | emit (Args const &... args) const |
| Calling all slots.
|
|
std::size_t | count () const |
| Get the number of connections.
|
|
template<typename Session, typename... Args>
class feed::impl::TrackableSignal< Session, Args >
A thread-safe class to manage a signal and its tracking connections.
- Parameters
-
Session | The type of the object that will be tracked, when the object is destroyed, the connection will be removed lazily. The pointer of the session object will also be the key to disconnect. |
Args | The types of the arguments that will be passed to the slot. |
◆ connectTrackableSlot()
template<typename Session , typename... Args>
bool feed::impl::TrackableSignal< Session, Args >::connectTrackableSlot |
( |
ConnectionSharedPtr const & | trackable, |
|
|
std::function< void(Args...)> | slot ) |
|
inline |
Connect a slot to the signal, the slot will be called when the signal is emitted and trackable is still alive.
- Parameters
-
trackable | Track this object's lifttime, if the object is destroyed, the connection will be removed lazily. When the slot is being called, the object is guaranteed to be alive. |
slot | The slot connecting to the signal, the slot will be called when the signal is emitted. |
- Returns
- true if the connection is successfully added, false if the connection already exists.
◆ disconnect()
template<typename Session , typename... Args>
Disconnect a slot to the signal.
- Parameters
-
trackablePtr | Disconnect the slot whose trackable is this pointer. Be aware that the pointer is a raw pointer, allowing disconnect to be called in the destructor of the trackable. |
- Returns
- true if the connection is successfully disconnected, false if the connection does not exist.
◆ emit()
template<typename Session , typename... Args>
Calling all slots.
- Parameters
-
args | The arguments to pass to the slots. |
The documentation for this class was generated from the following file: