15 #ifndef A_UTIL_UTIL_SYSTEM_TIMER_DECL_INCLUDED
16 #define A_UTIL_UTIL_SYSTEM_TIMER_DECL_INCLUDED
25 template <
typename T,
typename U>
26 class ReferenceCountedObject;
31 namespace experimental {
34 class NullaryDelegate;
61 Timer(std::uint64_t period_us,
void (*
function)());
74 template <
typename M,
typename T>
75 Timer(std::uint64_t period_us, M method, T& instance);
90 template <
typename M,
typename T>
130 template <
typename T>
136 using value_type = T;
137 using pointer = value_type*;
138 using const_pointer =
const value_type*;
139 using reference = value_type&;
140 using const_reference =
const value_type&;
144 : _reference_counted_object{reference_counted_object}
166 _reference_counted_object = other._reference_counted_object;
173 : _reference_counted_object{other._reference_counted_object}
181 _reference_counted_object = other._reference_counted_object;
188 void addReference()
const noexcept
194 void removeReference()
const noexcept
200 void release() noexcept
202 _reference_counted_object =
nullptr;
205 auto operator->()
const noexcept -> const_pointer
207 return &(_reference_counted_object->
getObject());
210 auto operator->() noexcept -> pointer
212 return &(_reference_counted_object->
getObject());
215 auto operator*() noexcept -> reference
217 return *(this->operator->());
220 auto operator*()
const noexcept -> const_reference
222 return *(this->operator->());
229 template <
typename T,
typename... Args>
233 struct Implementation;
General delegate template: encapsulates a function or a method without a parameter.
virtual void removeReference() const
Decrease the reference count by 1, deleting *this if it was the last reference.
virtual void addReference() const
Increase the reference count by 1.
virtual const Interface & getObject() const
Get a reference to the handled object's interface - provided for const correctness.
Periodic timer running in a separate thread.
~Timer()
DTOR - Calls stop()
void setCallback(void(*function)())
Set the callback for the timer.
bool stop()
Stop the timer - blocks until the callback returns.
std::uint64_t getPeriod() const
Get the currently configured period of the timer.
bool start()
Start the timer.
Timer(std::uint64_t period_us, void(*function)())
CTOR for functions as callbacks.
bool isRunning() const
Check whether the timer is currently running.
void setPeriod(std::uint64_t period_us)
Set the period used by this timer, restarting the timer if already running.
Serves as the root component, with common functionality documented in core functionality.
Private implementation for Timer class.