source: pacpusframework/trunk/include/Pacpus/PacpusTools/PeriodicWorker.h

Last change on this file was 162, checked in by Marek Kurdej, 11 years ago

Update: merged changes from trunk.

  • Property svn:executable set to *
File size: 1.9 KB
RevLine 
[89]1// %pacpus:license{
2// This file is part of the PACPUS framework distributed under the
3// CECILL-C License, Version 1.0.
4// %pacpus:license}
5/// @file
6/// @author Samuel Gosselin <firstname.surname@utc.fr>
7/// @date December, 2012
8/// @version $Id: PeriodicWorker.h 76 2013-01-10 17:05:10Z kurdejma $
9/// @copyright Copyright (c) UTC/CNRS Heudiasyc 2006 - 2013. All rights reserved.
10/// @brief Periodic worker base class
11///
12/// Detailed description.
13
14#ifndef DEF_PACPUS_PERIODIC_WORKER_H
15#define DEF_PACPUS_PERIODIC_WORKER_H
16
17#include <Pacpus/PacpusTools/AsyncWorkerBase.h>
[162]18#include <Pacpus/PacpusTools/PacpusToolsConfig.h>
[89]19
20class QTimer;
21
22namespace pacpus
23{
[162]24
25/// @brief A simple base class for periodic worker.
26///
27/// @example
28/// To use the PeriodicWorker, simply inherit from this class when creating your worker.
29/// ~~~
30/// class MyWorker
31/// : public PeriodicWorkder
32/// {
33/// public:
34/// void doWork() { std::cout << "Hey, I'm working!" << std::endl; }
35/// };
36///
37/// // Do its work every second.
38/// MyWorker worker;
39/// worker.startWork(1000);
40/// ~~~
41class PACPUSTOOLS_API PeriodicWorker
[89]42 : public AsyncWorkerBase
43 {
44 Q_OBJECT
45 public:
46 /// Ctor of PeriodicWorker.
47 PeriodicWorker();
48
49 /// Dtor of PeriodicWorker.
50 virtual ~PeriodicWorker();
51
[162]52 /// Start the periodic worker.
53 /// @param msec Period in mseconds.
[89]54 void startWork(int msec);
55
[162]56 /// Stop the periodic worker, but do not delete it.
[89]57 void stopWork();
58
[162]59 public Q_SLOTS:
60 /// Do the work.
61 /// This method need to be implemented in the subclasses, it will be called
62 /// each time the timer has reached its period.
[89]63 virtual void doWork() = 0;
64
65 private:
66 QTimer* mHeartbeat;
67 };
68
[162]69} // namespace pacpus
70
[89]71#endif // DEF_PACPUS_PERIODIC_WORKER_H
Note: See TracBrowser for help on using the repository browser.