33 #ifndef DART_COMMON_SIGNAL_HPP_
34 #define DART_COMMON_SIGNAL_HPP_
73 template <
typename _Signature,
template<
class>
class Combiner>
79 const std::weak_ptr<signal::detail::ConnectionBodyBase>& _connectionBody);
83 std::weak_ptr<signal::detail::ConnectionBodyBase>&& _connectionBody);
104 template <
typename _Signature,
109 template <
typename _Res,
typename... _ArgTypes,
template<
class>
class Combiner>
110 class Signal<_Res(_ArgTypes...), Combiner>
119 = std::set<std::shared_ptr<ConnectionBodyType>,
120 std::owner_less<std::shared_ptr<ConnectionBodyType>>>;
135 void disconnect(
const Connection& _connection)
const;
138 void disconnectAll();
141 void cleanupConnections();
144 std::size_t getNumConnections()
const;
147 template <
typename... ArgTypes>
151 template <
typename... ArgTypes>
160 template <
typename... _ArgTypes>
164 using SlotType = std::function<void(_ArgTypes...)>;
169 = std::set<std::shared_ptr<ConnectionBodyType>,
170 std::owner_less<std::shared_ptr<ConnectionBodyType>>>;
185 void disconnect(
const Connection& _connection)
const;
188 void disconnectAll();
191 void cleanupConnections();
194 std::size_t getNumConnections()
const;
197 template <
typename... ArgTypes>
198 void raise(ArgTypes&&... _args);
201 template <
typename... ArgTypes>
202 void operator()(ArgTypes&&... _args);
212 template <
typename T>
class Connection
Definition: Signal.hpp:47
void disconnect() const
Disconnect the connection.
Definition: Signal.cpp:107
virtual ~Connection()
Destructor.
Definition: Signal.cpp:89
Connection & operator=(const Connection &_other)
Assignment operator.
Definition: Signal.cpp:59
std::weak_ptr< signal::detail::ConnectionBodyBase > mWeakConnectionBody
Weak pointer to connection body in the signal.
Definition: Signal.hpp:87
Connection()
Default constructor.
Definition: Signal.cpp:39
bool isConnected() const
Get true if the slot is connected.
Definition: Signal.cpp:95
class ScopedConnection
Definition: Signal.hpp:92
virtual ~ScopedConnection()
Destructor.
Definition: Signal.cpp:133
ScopedConnection(const Connection &_other)
Default constructor.
Definition: Signal.cpp:119
Signal implements a signal/slot mechanism.
Definition: Signal.hpp:111
std::set< std::shared_ptr< ConnectionBodyType >, std::owner_less< std::shared_ptr< ConnectionBodyType > >> ConnectionSetType
Definition: Signal.hpp:120
_Res ResultType
Definition: Signal.hpp:113
ConnectionSetType mConnectionBodies
Connection set.
Definition: Signal.hpp:156
ResultType operator()(ArgTypes &&... _args)
Raise the signal.
std::function< ResultType(_ArgTypes...)> SlotType
Definition: Signal.hpp:114
Signal implements a signal/slot mechanism for the slots don't return a value.
Definition: Signal.hpp:162
std::function< void(_ArgTypes...)> SlotType
Definition: Signal.hpp:164
ConnectionSetType mConnectionBodies
Connection set.
Definition: Signal.hpp:206
std::set< std::shared_ptr< ConnectionBodyType >, std::owner_less< std::shared_ptr< ConnectionBodyType > >> ConnectionSetType
Definition: Signal.hpp:170
Definition: Signal.hpp:106
SlotRegister can be used as a public member for connecting slots to a private Signal member.
Definition: Signal.hpp:214
typename T::SignalType SignalType
Definition: Signal.hpp:217
SlotRegister(typename T::SignalType &_signal)
Constructor given signal.
Definition: Signal.hpp:258
typename T::SlotType SlotType
Definition: Signal.hpp:216
T::SignalType & mSignal
Signal.
Definition: Signal.hpp:227
Connection connect(const SlotType &_slot)
Connect a slot to the signal.
Definition: Signal.hpp:266
class ConnectionBody
Definition: ConnectionBody.hpp:68
Definition: BulletCollisionDetector.cpp:63
DefaultCombiner – return the last result.
Definition: ConnectionBody.hpp:120