|
cxxitimer 2.0.5
A C++ library to handle linux interval timer
|
class ITimer_Virtual More...
#include <cxxitimer.hpp>
Public Member Functions | |
| ITimer_Virtual (const timeval &interval={.tv_sec=1,.tv_usec=0}) | |
| create ITimer_Virtual instance | |
| ITimer_Virtual (const timeval &interval, const timeval &value) | |
| create ITimer_Virtual instance | |
| ITimer_Virtual (double interval) | |
| create ITimer_Virtual instance | |
| ITimer_Virtual (double interval, double value) | |
| create ITimer_Virtual instance | |
| ~ITimer_Virtual () override | |
| ITimer_Virtual (const ITimer_Virtual &other)=delete | |
| ITimer_Virtual (ITimer_Virtual &&other)=delete | |
| ITimer_Virtual & | operator= (const ITimer_Virtual &other)=delete |
| ITimer_Virtual & | operator= (ITimer_Virtual &&other)=delete |
| void | start () |
| start timer | |
| void | stop () |
| stop timer | |
| void | set_speed_factor (double factor) |
| set speed factor | |
| void | set_interval (const timeval &interval) |
| set interval (timeval) | |
| void | set_interval (double interval) |
| set interval (double) | |
| void | set_interval_value (const timeval &interval, const timeval &value) |
| set interval and value | |
| void | set_interval_value (double interval, double value) |
| set interval and value | |
| void | set_speed_to_normal () |
| set speed to normal | |
| void | to_fstream (std::ofstream &fstream) const |
| write to binary file stream | |
| void | from_fstream (std::ifstream &fstream) |
| read from binary filestream | |
| timeval | get_timer_value () const |
| get timer value | |
| bool | is_running () const noexcept |
| check if timer is running | |
Private Member Functions | |
| virtual void | adjust_speed (double new_factor) |
Private Attributes | |
| timeval | timer_value |
| timeval | timer_interval |
| int | type |
| double | speed_factor |
| speed adjustment factor | |
| bool | running |
Static Private Attributes | |
| static bool | instance_exists = false |
class ITimer_Virtual
"This timer counts down against the user-mode CPU time consumed by the process. (The measurement includes CPU time consumed by all threads in the process.) At each expiration, a SIGVTALRM signal is generated." (man getitimer)
Definition at line 243 of file cxxitimer.hpp.
|
explicit |
create ITimer_Virtual instance
only one instance is allowed
| interval | timer interval |
| std::logic_error | instance exists |
Definition at line 228 of file cxxitimer.cpp.
References instance_exists, and cxxitimer::ITimer::ITimer().
| cxxitimer::ITimer_Virtual::ITimer_Virtual | ( | const timeval & | interval, |
| const timeval & | value | ||
| ) |
create ITimer_Virtual instance
only one instance is allowed
| interval | interval at which the timer is triggered |
| value | ime period after which the timer expires for the first time |
| std::logic_error | instance exists |
Definition at line 234 of file cxxitimer.cpp.
References instance_exists, and cxxitimer::ITimer::ITimer().
|
explicit |
create ITimer_Virtual instance
only one instance is allowed
| interval | timer interval |
| std::logic_error | instance exists |
Definition at line 241 of file cxxitimer.cpp.
References instance_exists, and cxxitimer::ITimer::ITimer().
| cxxitimer::ITimer_Virtual::ITimer_Virtual | ( | double | interval, |
| double | value | ||
| ) |
create ITimer_Virtual instance
only one instance is allowed
| interval | interval at which the timer is triggered |
| value | ime period after which the timer expires for the first time |
| std::logic_error | instance exists |
Definition at line 247 of file cxxitimer.cpp.
References instance_exists, and cxxitimer::ITimer::ITimer().
|
override |
Definition at line 253 of file cxxitimer.cpp.
References instance_exists.
|
delete |
|
delete |
|
privatevirtualinherited |
Definition at line 71 of file cxxitimer.cpp.
References cxxitimer::operator*=(), cxxitimer::operator/(), cxxitimer::ITimer::running, cxxitimer::ITimer::speed_factor, cxxitimer::STOP_TIMER, cxxitimer::ITimer::timer_interval, and cxxitimer::ITimer::type.
Referenced by cxxitimer::ITimer::set_speed_factor(), and cxxitimer::ITimer::set_speed_to_normal().
|
inherited |
read from binary filestream
| fstream | file stream to read from |
| std::logic_error | timer is running |
Definition at line 180 of file cxxitimer.cpp.
References cxxitimer::ITimer::running, cxxitimer::ITimer::timer_interval, and cxxitimer::ITimer::timer_value.
|
inherited |
get timer value
returns the stored timer value if the timer is stopped or the actual timer value if running
Definition at line 189 of file cxxitimer.cpp.
References cxxitimer::operator*(), cxxitimer::ITimer::running, cxxitimer::ITimer::speed_factor, cxxitimer::ITimer::timer_value, and cxxitimer::ITimer::type.
|
inlinenoexceptinherited |
check if timer is running
Definition at line 175 of file cxxitimer.hpp.
References cxxitimer::ITimer::running.
|
delete |
|
delete |
|
inlineinherited |
set interval (timeval)
only allowed if the timer is stopped! set the timer value to the same time
| interval | timer interval |
| std::logic_error | timer is started |
Definition at line 109 of file cxxitimer.hpp.
References cxxitimer::ITimer::set_interval_value().
|
inlineinherited |
set interval (double)
only allowed if the timer is stopped! set the timer value to the same time
| interval | timer interval (seconds) |
| std::logic_error | timer is started |
Definition at line 119 of file cxxitimer.hpp.
References cxxitimer::ITimer::set_interval_value().
|
inherited |
set interval and value
only allowed if the timer is stopped
| interval | timer interval |
| value | timer value |
| std::logic_error | timer is started |
Definition at line 146 of file cxxitimer.cpp.
References cxxitimer::ITimer::running, cxxitimer::ITimer::timer_interval, and cxxitimer::ITimer::timer_value.
Referenced by cxxitimer::ITimer::set_interval(), and cxxitimer::ITimer::set_interval_value().
|
inherited |
set interval and value
only allowed if the timer is stopped
| interval | timer interval (seconds) |
| value | timer value (seconds) |
| std::logic_error | timer is started |
Definition at line 153 of file cxxitimer.cpp.
References cxxitimer::double_to_timeval(), and cxxitimer::ITimer::set_interval_value().
Referenced by cxxitimer::ITimer::set_interval().
|
inherited |
set speed factor
is applied directly, even if the timer is running
| factor | speed factor |
| std::invalid_argument | negative values or nan/inf |
| std::system_error | call of setitimer failed |
Definition at line 135 of file cxxitimer.cpp.
References cxxitimer::ITimer::adjust_speed(), cxxitimer::ITimer::running, and cxxitimer::ITimer::speed_factor.
|
inherited |
set speed to normal
like calling set_speed_factor with 1.0
| std::system_error | call of setitimer failed |
Definition at line 157 of file cxxitimer.cpp.
References cxxitimer::ITimer::adjust_speed(), cxxitimer::ITimer::running, and cxxitimer::ITimer::speed_factor.
|
inherited |
start timer
| std::logic_error | timer already started |
| std::runtime_error | invalid timer values due to a too small speed factor |
| std::system_error | call of setitimer failed |
Definition at line 96 of file cxxitimer.cpp.
References cxxitimer::operator/(), cxxitimer::ITimer::running, cxxitimer::ITimer::speed_factor, cxxitimer::ITimer::timer_interval, cxxitimer::ITimer::timer_value, and cxxitimer::ITimer::type.
|
inherited |
stop timer
| std::logic_error | timer already stopped |
| std::system_error | call of setitimer failed |
Definition at line 121 of file cxxitimer.cpp.
References cxxitimer::operator*(), cxxitimer::ITimer::running, cxxitimer::ITimer::speed_factor, cxxitimer::STOP_TIMER, cxxitimer::ITimer::timer_value, and cxxitimer::ITimer::type.
Referenced by cxxitimer::ITimer::~ITimer().
|
inherited |
write to binary file stream
writes interval and value to file stream. type and speed factor is not stored!
| fstream | file stream to write to |
| std::system_error | call of getitimer failed |
Definition at line 164 of file cxxitimer.cpp.
References cxxitimer::operator*=(), cxxitimer::ITimer::running, cxxitimer::ITimer::speed_factor, cxxitimer::ITimer::timer_interval, cxxitimer::ITimer::timer_value, and cxxitimer::ITimer::type.
|
staticprivate |
Definition at line 245 of file cxxitimer.hpp.
Referenced by ITimer_Virtual(), ITimer_Virtual(), ITimer_Virtual(), ITimer_Virtual(), and ~ITimer_Virtual().
|
privateinherited |
Definition at line 37 of file cxxitimer.hpp.
Referenced by cxxitimer::ITimer::adjust_speed(), cxxitimer::ITimer::from_fstream(), cxxitimer::ITimer::get_timer_value(), cxxitimer::ITimer::is_running(), cxxitimer::ITimer::ITimer(), cxxitimer::ITimer::ITimer(), cxxitimer::ITimer::ITimer(), cxxitimer::ITimer::ITimer(), cxxitimer::ITimer::set_interval_value(), cxxitimer::ITimer::set_speed_factor(), cxxitimer::ITimer::set_speed_to_normal(), cxxitimer::ITimer::start(), cxxitimer::ITimer::stop(), cxxitimer::ITimer::to_fstream(), and cxxitimer::ITimer::~ITimer().
|
privateinherited |
speed adjustment factor
Definition at line 34 of file cxxitimer.hpp.
Referenced by cxxitimer::ITimer::adjust_speed(), cxxitimer::ITimer::get_timer_value(), cxxitimer::ITimer::ITimer(), cxxitimer::ITimer::ITimer(), cxxitimer::ITimer::ITimer(), cxxitimer::ITimer::ITimer(), cxxitimer::ITimer::set_speed_factor(), cxxitimer::ITimer::set_speed_to_normal(), cxxitimer::ITimer::start(), cxxitimer::ITimer::stop(), and cxxitimer::ITimer::to_fstream().
|
privateinherited |
Definition at line 22 of file cxxitimer.hpp.
Referenced by cxxitimer::ITimer::adjust_speed(), cxxitimer::ITimer::from_fstream(), cxxitimer::ITimer::ITimer(), cxxitimer::ITimer::ITimer(), cxxitimer::ITimer::ITimer(), cxxitimer::ITimer::ITimer(), cxxitimer::ITimer::set_interval_value(), cxxitimer::ITimer::start(), and cxxitimer::ITimer::to_fstream().
|
privateinherited |
Definition at line 19 of file cxxitimer.hpp.
Referenced by cxxitimer::ITimer::from_fstream(), cxxitimer::ITimer::get_timer_value(), cxxitimer::ITimer::ITimer(), cxxitimer::ITimer::ITimer(), cxxitimer::ITimer::ITimer(), cxxitimer::ITimer::ITimer(), cxxitimer::ITimer::set_interval_value(), cxxitimer::ITimer::start(), cxxitimer::ITimer::stop(), and cxxitimer::ITimer::to_fstream().
|
privateinherited |
Definition at line 25 of file cxxitimer.hpp.
Referenced by cxxitimer::ITimer::adjust_speed(), cxxitimer::ITimer::get_timer_value(), cxxitimer::ITimer::ITimer(), cxxitimer::ITimer::ITimer(), cxxitimer::ITimer::ITimer(), cxxitimer::ITimer::ITimer(), cxxitimer::ITimer::start(), cxxitimer::ITimer::stop(), and cxxitimer::ITimer::to_fstream().