semf
staticslot.h
Go to the documentation of this file.
1
11#ifndef SEMF_UTILS_CORE_SIGNALS_STATICSLOT_H_
12#define SEMF_UTILS_CORE_SIGNALS_STATICSLOT_H_
13
15#include <utility>
16
17namespace semf
18{
25template <typename... Arguments>
26class StaticSlot : public SlotBase<Arguments...>
27{
28public:
30 typedef void (*Function)(Arguments...);
31
37 virtual ~StaticSlot() = default;
47 Function function() const;
48
49protected:
50 void call(Arguments&&... arguments);
51
52private:
54 Function m_function;
55};
56
57template <typename... Arguments>
59: m_function(function)
60{
61}
62
63template <typename... Arguments>
65{
66 m_function = function;
67}
68
69template <typename... Arguments>
70typename StaticSlot<Arguments...>::Function StaticSlot<Arguments...>::function() const
71{
72 return m_function;
73}
74
75template <typename... Arguments>
76void StaticSlot<Arguments...>::call(Arguments&&... arguments)
77{
78 (*m_function)(std::forward<Arguments>(arguments)...);
79}
80
81} // namespace semf
82#endif // SEMF_UTILS_CORE_SIGNALS_STATICSLOT_H_
Base Class for all Slot implementations.
Definition: slotbase.h:25
StaticSlot for lightweight signal/slot implementation. This StaticSlot ist for connecting a signal to...
Definition: staticslot.h:27
void call(Arguments &&... arguments)
The invocation of the callback.
Definition: staticslot.h:76
void setFunction(Function function)
Set the callback function.
Definition: staticslot.h:64
Function function() const
function Get the pointer to the callback function.
Definition: staticslot.h:70
StaticSlot(Function function)
Constructor.
Definition: staticslot.h:58
virtual ~StaticSlot()=default
void(* Function)(Arguments...)
Definition: staticslot.h:30