Easy3D 2.6.1
|
A light-weight implementation of the simple signal-slot mechanism. More...
#include <easy3d/util/signal.h>
Public Member Functions | |
Signal (Signal const &) | |
Copy constructor and assignment create a new signal. | |
Signal (Signal &&other) noexcept | |
Move constructor. | |
Signal & | operator= (Signal &&other) noexcept |
The assignment operator. | |
Signal & | operator= (Signal const &other) |
The assignment operator. | |
int | connect (std::function< void(Args...)> const &slot) |
Connects a function to this signal. | |
template<typename Class> | |
int | connect (Class *inst, void(Class::*func)(Args...)) |
Connects a member function of an object to this signal. | |
template<typename Class> | |
int | connect (Class *inst, void(Class::*func)(Args...) const) |
Connects a const member function of an object to this signal. | |
int | connect (Signal< Args... > *receiver) |
Connects this signal to another signal receiver . | |
void | disconnect (int id) |
Disconnects a previously connected function. | |
void | disconnect_all () |
Disconnects all previously connected functions. | |
void | send (Args... p) |
Calls all connected functions. | |
void | send_for_all_but_one (int excludedConnectionID, Args... p) |
Calls all connected functions except for one. | |
void | emit_for (int connectionID, Args... p) |
Calls only one connected function. | |
A light-weight implementation of the simple signal-slot mechanism.
Signal supports any types of functions (functions, lambda functions, and member functions) with any number of arguments. Connected functions will be called when the send() method of the signal object is invoked. Any argument passed to send() will be passed to the given functions. Multiple slots can be connected to the same signal object. A signal (i.e., the sender) can be connected to another signal (e.g., the receiver). A typical usage of Signal in Easy3D is camera manipulation. When the camera has been manipulated, the viewer should be notified (e.g., a repaint event should be triggered). This is done by calling to the viewer's update() function. So in Easy3D, the viewer's update function is connected to the camera's corresponding signal.
|
inline |
Connects a const member function of an object to this signal.
The returned value can be used to disconnect the function from this signal, e.g.,
overload
for a lighter syntax.
|
inline |
Connects a member function of an object to this signal.
The returned value can be used to disconnect the function from this signal, e.g.,
overload
for a lighter syntax.
|
inline |
Connects this signal to another signal receiver
.
Upon return, the emission of this signal will trigger receiver
to emit. The returned value can be used to disconnect the connected signal.
|
inline |
Connects a function to this signal.
The returned value can be used to disconnect the function from this signal.
overload
for a lighter syntax.