Signal.hpp
Allow functions to be bundled (as Actions) and triggered enmasse.
- Todo:
Setup easier mechanism to control the order in which actions are triggered.
Signals should have default parameters so not all need be supplied when triggered.
Note
Status: Beta
-
class SignalKey
- #include <Signal.hpp>
SignalKey tracks a specific function triggered by a signal. For now, its just a value pair.
Public Functions
-
inline SignalKey(uint32_t _kid = 0, uint32_t _sid = 0)
-
inline ~SignalKey()
-
inline uint32_t GetID() const
What is the KeyID associated with this signal key.
-
inline uint32_t GetSignalID() const
What is the ID of the signal that this key is associated with.
-
inline bool IsActive() const
Is this key currently pointing to a signal action?
-
inline void Set(uint32_t _kid = 0, uint32_t _sid = 0)
Set this key to specified values.
-
inline void Clear()
Clear this key.
-
inline operator bool()
-
inline SignalKey(uint32_t _kid = 0, uint32_t _sid = 0)
-
class SignalBase
- #include <Signal.hpp>
Base class for all signals.
Subclassed by Signal< RETURN(ARGS…)>, Signal< void(ARGS…)>
Public Functions
-
SignalBase() = delete
-
SignalBase(const SignalBase&) = delete
-
SignalBase(SignalBase&&) = delete
-
SignalBase &operator=(const SignalBase&) = delete
-
SignalBase &operator=(SignalBase&&) = delete
-
inline virtual ~SignalBase()
-
virtual SignalBase *Clone() const = 0
-
virtual size_t GetNumArgs() const = 0
-
virtual size_t GetNumActions() const = 0
-
template<typename ...ARGS>
SignalKey AddAction(const std::function<void(ARGS...)> &in_fun) Actions without arguments or a return type can be associated with any signal.
-
virtual SignalKey AddAction(ActionBase&) = 0
Add an action using an Action object.
-
virtual bool TestMatch(ActionBase&) = 0
Test if an action is compatible with a signal.
-
inline void Clear()
Remove all actions from this signal.
Protected Types
-
using man_t = internal::SignalManager_Base
Protected Functions
Protected Attributes
-
uint32_t signal_id
What is the unique ID of this signal?
-
uint32_t next_link_id
What ID should the next link have?
Friends
- friend class SignalManager
-
SignalBase() = delete
-
template<typename ...ARGS>
class Signal - #include <Signal.hpp>
Generic version of Signals; needs specialization to a function type..
-
template<typename ...ARGS>
class Signal<void(ARGS...)> : public SignalBase - #include <Signal.hpp>
Signals with void return.
Public Functions
-
inline virtual size_t GetNumArgs() const
-
inline virtual size_t GetNumActions() const
-
inline SignalKey AddAction(const std::function<void(ARGS...)> &in_fun)
Add an action that takes the proper arguments.
-
inline virtual SignalKey AddAction(ActionBase &in_action)
Add a specified action to this signal.
-
inline virtual bool TestMatch(ActionBase &in_action)
Test if an action is compatible with a signal.
-
template<typename ...FUN_ARGS, typename ...EXTRA_ARGS>
inline SignalKey AddAction(const std::function<void(FUN_ARGS...)> &in_fun, TypePack<EXTRA_ARGS...>) Add an action that takes too few arguments… but provide specific padding info.
-
template<typename ...FUN_ARGS>
inline SignalKey AddAction(const std::function<void(FUN_ARGS...)> &in_fun) Add an std::function that takes the wrong number of arguments. For now, we will assume that there are too few and we need to figure out how to pad it out.
Protected Attributes
-
FunctionSet<void(ARGS...)> actions
Set of functions (actions) to be triggered with this signal.
-
inline virtual size_t GetNumArgs() const
-
template<typename RETURN, typename ...ARGS>
class Signal<RETURN(ARGS...)> : public SignalBase - #include <Signal.hpp>
Public Functions
-
inline virtual size_t GetNumArgs() const
-
inline virtual size_t GetNumActions() const
-
inline virtual SignalKey AddAction(ActionBase &in_action)
Add an action using an Action object.
-
inline virtual bool TestMatch(ActionBase &in_action)
Test if an action is compatible with a signal.
-
template<typename ...FUN_ARGS, typename ...EXTRA_ARGS>
inline SignalKey AddAction(const std::function<RETURN(FUN_ARGS...)> &in_fun, TypePack<EXTRA_ARGS...>)
Protected Attributes
-
FunctionSet<RETURN(ARGS...)> actions
-
inline virtual size_t GetNumArgs() const