Volume Cartographer 2.27.0
|
Basic signal class for implementing event callbacks. More...
#include <vc/core/util/Signals.hpp>
Classes | |
struct | Connection |
Public Types | |
using | SlotFnType = std::function< void(Types...)> |
Public Member Functions | |
void | connect (SlotFnType slot) |
Connect to a free, static, or lambda function. More... | |
template<class Obj , class ObjMemberFn > | |
void | connect (Obj *obj, ObjMemberFn &&fn) |
Connect to an object's member function. More... | |
template<class Obj , class Ret > | |
void | connect (Obj *obj, Ret(Obj::*fn)()) |
Connect a valued signal to a no-parameter object member function. More... | |
template<class Obj , class Ret > | |
void | connect (const Obj *obj, Ret(Obj::*fn)() const) |
Connect a valued signal to a no-parameter object member function. More... | |
template<class Enabled = typename std::enable_if< std::is_empty<std::tuple<Types...>(Types...)>::value, bool>> | |
void | connect (const std::function< void()> &slot) |
Connect signals with parameters to functions without parameters. More... | |
void | disconnect () |
Remove all connections. More... | |
std::size_t | numConnections () const |
Get the number of connected slots. More... | |
void | send (Types... args) const |
Signal all connections with parameters. More... | |
void | operator() (Types... args) const |
Convenience operator: Calls Signal::send(args) More... | |
Private Attributes | |
std::vector< Connection > | connections_ |
Basic signal class for implementing event callbacks.
This class provides a statically-typed signals implementation similar to what you would find in Qt or Boost.signals2. Parameters passed to send() are immediately passed by value to connected functions. There is currently no lifetime management for connected objects, so this class is not thread-safe and should only be used to implement simple callbacks.
Example Usage:
Types | List of types to be emitted by the signal |
Definition at line 37 of file Signals.hpp.
using volcart::Signal< Types >::SlotFnType = std::function<void(Types...)> |
Type of functions to which this signal can be connected
Definition at line 41 of file Signals.hpp.
|
inline |
Connect a valued signal to a no-parameter object member function.
cv-qualified version.
Definition at line 78 of file Signals.hpp.
|
inline |
Connect signals with parameters to functions without parameters.
Definition at line 91 of file Signals.hpp.
|
inline |
Connect to an object's member function.
obj | Pointer to an object |
fn | Reference to a member function of obj |
Definition at line 56 of file Signals.hpp.
|
inline |
Connect a valued signal to a no-parameter object member function.
Definition at line 66 of file Signals.hpp.
|
inline |
Connect to a free, static, or lambda function.
Definition at line 44 of file Signals.hpp.
|
inline |
Remove all connections.
Definition at line 97 of file Signals.hpp.
|
inline |
Get the number of connected slots.
Definition at line 100 of file Signals.hpp.
|
inline |
Convenience operator: Calls Signal::send(args)
Definition at line 111 of file Signals.hpp.
|
inline |
Signal all connections with parameters.
Definition at line 103 of file Signals.hpp.
|
private |
List of connections
Definition at line 120 of file Signals.hpp.