distortos  v0.7.0
object-oriented C++ RTOS for microcontrollers
StaticSoftwareTimer.hpp
Go to the documentation of this file.
1 
12 #ifndef INCLUDE_DISTORTOS_STATICSOFTWARETIMER_HPP_
13 #define INCLUDE_DISTORTOS_STATICSOFTWARETIMER_HPP_
14 
16 
17 #include <functional>
18 
19 namespace distortos
20 {
21 
24 
32 template<typename Function, typename... Args>
34 {
35 public:
36 
44  StaticSoftwareTimer(Function&& function, Args&&... args) :
46  boundFunction_{std::bind(std::forward<Function>(function), std::forward<Args>(args)...)}
47  {
48 
49  }
50 
51 private:
52 
59  void run() override
60  {
62  }
63 
65  decltype(std::bind(std::declval<Function>(), std::declval<Args>()...)) boundFunction_;
66 };
67 
80 template<typename Function, typename... Args>
81 StaticSoftwareTimer<Function, Args...> makeStaticSoftwareTimer(Function&& function, Args&&... args)
82 {
83  return {std::forward<Function>(function), std::forward<Args>(args)...};
84 }
85 
87 
88 } // namespace distortos
89 
90 #endif // INCLUDE_DISTORTOS_STATICSOFTWARETIMER_HPP_
StaticSoftwareTimer(Function &&function, Args &&... args)
StaticSoftwareTimer's constructor.
Definition: StaticSoftwareTimer.hpp:44
void run() override
"Run" function of software timer
Definition: StaticSoftwareTimer.hpp:59
Top-level namespace of distortos project.
Definition: buttons.hpp:33
StaticSoftwareTimer< Function, Args... > makeStaticSoftwareTimer(Function &&function, Args &&... args)
Helper factory function to make StaticSoftwareTimer object with deduced template arguments.
Definition: StaticSoftwareTimer.hpp:81
StaticSoftwareTimer class is a templated interface for software timer.
Definition: StaticSoftwareTimer.hpp:33
SoftwareTimerCommon class header.
SoftwareTimerCommon class implements common functionality of software timers.
Definition: SoftwareTimerCommon.hpp:28
decltype(std::bind(std::declval< Function >(), std::declval< Args >()...)) boundFunction_
bound function object
Definition: StaticSoftwareTimer.hpp:65