Debian Codegraph @

Source/Concurrent/CIntervalThread.h

raw
1 /*
2 * Copyright (C) 2013-2015, 2019 by the Konclude Developer Team.
3 *
4 * This file is part of the reasoning system Konclude.
5 * For details and support, see <http://konclude.com/>.
6 *
7 * Konclude is free software: you can redistribute it and/or modify
8 * it under the terms of version 3 of the GNU Lesser General Public
9 * License (LGPLv3) as published by the Free Software Foundation.
10 *
11 * Konclude is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU (Lesser) General Public License for more details.
15 *
16 * You should have received a copy of the GNU (Lesser) General Public
17 * License along with Konclude. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20 #ifndef KONCLUDE_CONCURRENT_CINTERVALTHREAD_H
21 #define KONCLUDE_CONCURRENT_CINTERVALTHREAD_H
22
23
24 #include <QThread>
25 #include <QSemaphore>
26 #include <QTime>
27 #include <QTimer>
28 #include <QHash>
29 #include <QMutex>
30
31 #include "CIntervalThreadData.h"
32 #include "CThread.h"
33
34 #include "Events/CTimerIntervalEvent.h"
35
36 namespace Konclude {
37
38 namespace Concurrent {
39
40
41 /*!
42 * \class CIntervalThread
43 * \author Andreas Steigmiller
44 * \version 0.1
45 * \brief
46 */
47 class CIntervalThread : public CThread {
48 // public methods
49 public:
50 //! Constructor
51 CIntervalThread(QString threadIdentifierName, CWatchDog *watchDog = 0);
52
53 //! Destructor
54 virtual ~CIntervalThread();
55
56
57 void setTimerInterval(qint64 timerID, qint64 timerIntervalMilliSecs);
58 void startTimerWithInterval(qint64 timerID, qint64 timerIntervalMilliSecs);
59 void startTimerWithIntervalLimited(qint64 timerID, qint64 timerIntervalMilliSecs, qint64 remainingCallCount);
60 void startTimer(qint64 timerID);
61 void stopTimer(qint64 timerID);
62
63
64
65 // protected methods
66 protected:
67
68 virtual bool processTimer(qint64 timerID) = 0;
69
70 bool processEvents(QEvent *event);
71 virtual bool processControlEvents(QEvent::Type type, CControlEvent *event);
72
73 virtual void threadStarted();
74 virtual void threadStopped();
75
76
77 // private methods
78 private:
79
80
81 // private variables
82 private:
83 QMutex mSyncTimerMutex;
84 QHash<qint64,CIntervalThreadData *> timers;
85 QHash<qint64,qint64> timerMapping;
86
87 };
88
89 }; // end namespace Concurrent
90
91 }; // end namespace Konclude
92
93 #endif // KONCLUDE_CONCURRENT_CINTERVALTHREAD_H