xoreos  0.0.5
queueman.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #ifndef GRAPHICS_QUEUEMAN_H
26 #define GRAPHICS_QUEUEMAN_H
27 
28 #include <list>
29 
30 #include "src/common/types.h"
31 #include "src/common/singleton.h"
32 #include "src/common/mutex.h"
33 
34 #include "src/graphics/types.h"
35 
36 namespace Graphics {
37 
38 class Queueable;
39 
41 class QueueManager : public Common::Singleton<QueueManager> {
42 public:
43  QueueManager();
44  ~QueueManager();
45 
46  bool isQueueEmpty(QueueType queue);
47 
48  void lockQueue(QueueType queue);
49  void unlockQueue(QueueType queue);
50 
51  const std::list<Queueable *> &getQueue(QueueType queue) const;
52 
53  void sortQueue(QueueType queue);
54  void clearQueue(QueueType queue);
55 
56  void clearAllQueues();
57 
58 private:
60  std::list<Queueable *> _queue[kQueueMAX];
61 
62  std::list<Queueable *>::iterator addToQueue(QueueType queue, Queueable &q);
63  void removeFromQueue(QueueType queue, const std::list<Queueable *>::iterator &ref);
64 
65  friend class Queueable;
66 };
67 
68 } // End of namespace Graphics
69 
71 #define QueueMan QueueManager::instance()
72 
73 #endif // GRAPHICS_QUEUEMAN_H
The graphics queue manager.
Definition: queueman.h:41
std::list< Queueable * >::iterator addToQueue(QueueType queue, Queueable &q)
Definition: queueman.cpp:70
Class and macro for implementing singletons.
For range checks.
Definition: types.h:86
std::list< Queueable * > _queue[kQueueMAX]
Definition: queueman.h:60
Basic graphics types.
void lockQueue(QueueType queue)
Definition: queueman.cpp:44
void sortQueue(QueueType queue)
Definition: queueman.cpp:62
Generic template base class for implementing the singleton design pattern.
Definition: singleton.h:61
A mutex.
Definition: mutex.h:40
Common::Mutex _queueMutex[kQueueMAX]
Definition: queueman.h:59
QueueType
Definition: types.h:71
const std::list< Queueable * > & getQueue(QueueType queue) const
Definition: queueman.cpp:58
Low-level type definitions to handle fixed width types portably.
Thread mutex classes.
void unlockQueue(QueueType queue)
Definition: queueman.cpp:48
void removeFromQueue(QueueType queue, const std::list< Queueable *>::iterator &ref)
Definition: queueman.cpp:81
void clearQueue(QueueType queue)
Definition: queueman.cpp:91
bool isQueueEmpty(QueueType queue)
Definition: queueman.cpp:52