7 #ifndef NAZARA_SIGNAL_HPP 8 #define NAZARA_SIGNAL_HPP 14 #define NazaraDetailSignal(Keyword, SignalName, ...) using SignalName ## Type = Nz::Signal<__VA_ARGS__>; \ 15 Keyword SignalName ## Type SignalName 17 #define NazaraSignal(SignalName, ...) NazaraDetailSignal(mutable, SignalName, __VA_ARGS__) 18 #define NazaraStaticSignal(SignalName, ...) NazaraDetailSignal(static, SignalName, __VA_ARGS__) 19 #define NazaraStaticSignalImpl(Class, SignalName) Class :: SignalName ## Type Class :: SignalName 21 #define NazaraSlotType(Class, SignalName) Class::SignalName ## Type::ConnectionGuard 22 #define NazaraSlot(Class, SignalName, SlotName) NazaraSlotType(Class, SignalName) SlotName 26 template<
typename... Args>
30 using Callback = std::function<void(Args...)>;
45 template<
typename O>
Connection Connect(
const O&
object,
void (O::*method)(Args...)
const);
46 template<
typename O>
Connection Connect(
const O*
object,
void (O::*method)(Args...)
const);
56 using SlotPtr = std::shared_ptr<Slot>;
57 using SlotList = std::vector<SlotPtr>;
58 using SlotListIndex =
typename SlotList::size_type;
75 mutable SlotListIndex m_slotIterator;
78 template<
typename... Args>
90 template<
typename... ConnectArgs>
91 void Connect(BaseClass& signal, ConnectArgs&&... args);
94 bool IsConnected()
const;
102 std::weak_ptr<Slot> m_ptr;
105 template<
typename... Args>
119 template<
typename... ConnectArgs>
120 void Connect(BaseClass& signal, ConnectArgs&&... args);
123 Connection& GetConnection();
125 bool IsConnected()
const;
133 Connection m_connection;
137 #include <Nazara/Core/Signal.inl> 139 #endif // NAZARA_SIGNAL_HPP TODO: Inherit SoundEmitter from Node.
Definition: Algorithm.hpp:12
void Clear()
Clears the list of actions attached to the signal.
Definition: Signal.inl:45
Core class that represents a signal, a list of objects waiting for its message.
Definition: Signal.hpp:27
void operator()(Args... args) const
Applies the list of arguments to every callback functions.
Definition: Signal.inl:171
Core class that represents a RAII for a connection attached to a signal.
Definition: Signal.hpp:106
Signal()
Constructs a Signal object by default.
Definition: Signal.inl:23
Connection Connect(const Callback &func)
Connects a function to the signal.
Definition: Signal.inl:59
Core class that represents a connection attached to a signal.
Definition: Signal.hpp:79