Changeset 162 in pacpusframework for branches/2.0-beta1/include/Pacpus/PacpusTools/PeriodicWorker.h
- Timestamp:
- 08/01/13 16:46:07 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.0-beta1/include/Pacpus/PacpusTools/PeriodicWorker.h
r89 r162 15 15 #define DEF_PACPUS_PERIODIC_WORKER_H 16 16 17 // Includes, pacpus.18 17 #include <Pacpus/PacpusTools/AsyncWorkerBase.h> 18 #include <Pacpus/PacpusTools/PacpusToolsConfig.h> 19 19 20 20 class QTimer; … … 22 22 namespace pacpus 23 23 { 24 /** PeriodicWorker 25 * @brief A simple base class for periodic worker. 26 * 27 * @example 28 * class MyWorker 29 * : public PeriodicWorkder 30 * { 31 * public: 32 * void doWork() { std::cout << "Hey, I'm working!" << std::endl; } 33 * }; 34 * 35 * // Do its work every second. 36 * MyWorker worker; 37 * worker.startWork(1000); 38 */ 39 class PeriodicWorker 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 /// ~~~ 41 class PACPUSTOOLS_API PeriodicWorker 40 42 : public AsyncWorkerBase 41 43 { … … 48 50 virtual ~PeriodicWorker(); 49 51 50 /** Start the periodic worker. 51 * @param msec Period in mseconds. 52 */ 52 /// Start the periodic worker. 53 /// @param msec Period in mseconds. 53 54 void startWork(int msec); 54 55 55 /** Stop the periodic worker, but do not delete it. */56 /// Stop the periodic worker, but do not delete it. 56 57 void stopWork(); 57 58 58 public slots: 59 /** Do the work. 60 * This method need to be implemented in the subclasses, it will be called 61 * each time the timer has reached its period. 62 */ 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. 63 63 virtual void doWork() = 0; 64 64 … … 66 66 QTimer* mHeartbeat; 67 67 }; 68 } 68 69 } // namespace pacpus 69 70 70 71 #endif // DEF_PACPUS_PERIODIC_WORKER_H
Note:
See TracChangeset
for help on using the changeset viewer.