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

Last change on this file since 52 was 36, checked in by DHERBOMEZ Gérald, 12 years ago
  • modif de chemins d'include non trouvés sur ma machine
  • modif entetes de fichiers, utiliser ce template :

/

*

  • This file is part of the PACPUS framework distributed under the
  • CECILL-C License, Version 1.0. *
  • @author Prenom Nom <Mail>
  • @date Month, Year
  • @version $Id$
  • @copyright Copyright (c) UTC/CNRS Heudiasyc 2006 - 2013. All rights reserved.
  • @brief Brief description of file... *
  • Detailed description of file...
  • */
File size: 1.6 KB
Line 
1/**
2 *
3 * This file is part of the PACPUS framework distributed under the
4 * CECILL-C License, Version 1.0.
5 *
6 * @author Samuel Gosselin
7 * @date December, 2012
8 * @version $Id$
9 * @copyright Copyright (c) UTC/CNRS Heudiasyc 2005 - 2013. All rights reserved.
10 * @brief Periodic worker base class
11 *
12 * Detailed description of file...
13 *
14 */
15
16#ifndef DEF_PACPUS_PERIODIC_WORKER_H
17#define DEF_PACPUS_PERIODIC_WORKER_H
18
19// Includes, pacpus.
20#include <Pacpus/PacpusTools/AsyncWorkerBase.h>
21
22class QTimer;
23
24namespace pacpus
25{
26 /** PeriodicWorker
27 * @brief A simple base class for periodic worker.
28 *
29 * @example
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 PeriodicWorker
42 : public AsyncWorkerBase
43 {
44 Q_OBJECT
45 public:
46 /// Ctor of PeriodicWorker.
47 PeriodicWorker();
48
49 /// Dtor of PeriodicWorker.
50 virtual ~PeriodicWorker();
51
52 /** Start the periodic worker.
53 * @param msec Period in mseconds.
54 */
55 void startWork(int msec);
56
57 /** Stop the periodic worker, but do not delete it. */
58 void stopWork();
59
60 public slots:
61 /** Do the work.
62 * This method need to be implemented in the subclasses, it will be called
63 * each time the timer has reached its period.
64 */
65 virtual void doWork() = 0;
66
67 private:
68 QTimer* mHeartbeat;
69 };
70}
71
72#endif // DEF_PACPUS_PERIODIC_WORKER_H
Note: See TracBrowser for help on using the repository browser.