rad  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EventQueue.h
Go to the documentation of this file.
1 /*
2  * scampl4cpp/engine
3  *
4  * Copyright by European Southern Observatory, 2012
5  * All rights reserved
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library 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 GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20  * 02111-1307 USA.
21  */
22 
23 /*
24  * $Id: EventQueue.h 1139 2016-07-20 14:57:28Z landolfa $
25  */
26 
27 #ifndef SCXML4CPP_EVENTQUEUE_H
28 #define SCXML4CPP_EVENTQUEUE_H
29 
30 #ifndef __cplusplus
31 #error This is a C++ include file and cannot be used from plain C
32 #endif
33 
34 #include <queue>
35 #include <mutex>
36 
37 #ifndef SCXML4CPP_EVENT_H
38 #include "scxml4cpp/Event.h"
39 #endif
40 
41 namespace scxml4cpp {
42 
43 class EventQueue
44 {
45  public:
46  EventQueue();
47  virtual ~EventQueue();
48 
49  void add(Event* e);
50  Event* remove();
51  bool isEmpty() const;
52  int size() const;
53  void clear();
54 
55  private:
56  std::queue<Event*> mEvents;
57  std::mutex mMutex;
58 
59  EventQueue(const EventQueue&);
60  EventQueue& operator= (const EventQueue&);
61 
62 };
63 
64 } // namespace scxml4cpp
65 
66 #endif // SCXML4CPP_EVENTQUEUE_H
67 
68 
69 
EventQueue()
Definition: EventQueue.cpp:33
virtual ~EventQueue()
Definition: EventQueue.cpp:38
int size() const
Definition: EventQueue.cpp:76
bool isEmpty() const
Definition: EventQueue.cpp:70
void clear()
Definition: EventQueue.cpp:82
void add(Event *e)
Definition: EventQueue.cpp:43