The plugin timer class for plugins. More...
Header: | #include <PluginTimer> |
Inherits: | |
Inherited By: |
PluginTimer(QObject * parent = nullptr) | |
virtual | ~PluginTimer() |
virtual int | currentTick() const = 0 |
virtual int | interval() const = 0 |
virtual bool | running() const = 0 |
virtual void | pause() = 0 |
virtual void | reset() = 0 |
virtual void | resume() = 0 |
virtual void | start() = 0 |
virtual void | stop() = 0 |
void | currentTickChanged(const int & currentTick) |
void | pausedChanged(const bool & paused) |
void | runningChanged(const bool & running) |
void | timeout() |
The plugin timer class for plugins.
The plugin timer allowes to trigger repeating actions in a device plugin. This timer does not represent a precise timer should be used for not time critical things. The PluginTimerManager will schedule the requested timer as needed and trigger the timeout() method.
In order to do something repeatedly in a DevicePlugin you can register a new PluginTimer like this:
devicepluginexample.h
#include "plugintimer.h" class DevicePluginExample : public DevicePlugin { ... public: void init() override; private: PluginTimer *m_pluginTimer = nullptr; private slots: void onPluginTimerTimeout(); ... };
devicepluginexample.cpp
void DevicePluginExample::init() { m_pluginTimer = hardwareManager()->pluginTimerManager()->registerTimer(10); connect(m_pluginTimer, &PluginTimer::timeout, this, &DevicePluginExample::onPluginTimerTimeout); } DevicePluginExample::~DevicePluginExample() { hardwareManager()->pluginTimerManager()->unregisterTimer(m_pluginTimer); }
See also PluginTimerManager.
Constructs a PluginTimer with the given parent.
[virtual]
PluginTimer::~PluginTimer()The virtual destructor of the PluginTimer. You should always use the PluginTimerManager for destroying a PluginTimer object.
[pure virtual]
int PluginTimer::currentTick() constReturns the current timer tick of this PluginTimer in seconds.
[signal]
void PluginTimer::currentTickChanged(const int & currentTick)This signal will be emitted whenever the currentTick of this PluginTimer changed.
See also currentTick().
[pure virtual]
int PluginTimer::interval() constThis property holds the timeout interval in seconds.
[pure virtual slot]
void PluginTimer::pause()Pauses the timer.
See also running().
[signal]
void PluginTimer::pausedChanged(const bool & paused)This signal will be emitted whenever the paused status of this PluginTimer changed.
See also running().
[pure virtual slot]
void PluginTimer::reset()This method resets the timer to 0. This method does not change the current running state or the configured interval.
[pure virtual slot]
void PluginTimer::resume()Resumes the timer. If the timer was not on paused, this method has no effect.
See also pause().
[pure virtual]
bool PluginTimer::running() constReturns true, if this PluginTimer is currently running.
See also start(), stop(), pause(), resume(), and reset().
[signal]
void PluginTimer::runningChanged(const bool & running)This signal will be emitted whenever the running status of this PluginTimer changed.
See also running().
[pure virtual slot]
void PluginTimer::start()Starts the timer.
See also running() and runningChanged().
[pure virtual slot]
void PluginTimer::stop()Stops the timer.
See also running() and runningChanged().
[signal]
void PluginTimer::timeout()This signal will be emitted if the timer timeouted.