GG
EventPump.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /* GG is a GUI for SDL and OpenGL.
3  Copyright (C) 2003-2008 T. Zachary Laine
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public License
7  as published by the Free Software Foundation; either version 2.1
8  of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free
17  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18  02111-1307 USA
19 
20  If you do not wish to comply with the terms of the LGPL please
21  contact the author as other terms are available for a fee.
22 
23  Zach Laine
24  whatwasthataddress@gmail.com */
25 
31 #ifndef _GG_EventPump_h_
32 #define _GG_EventPump_h_
33 
34 #include <GG/GUI.h>
35 
36 
37 namespace GG {
38 
43 struct GG_API EventPumpState
44 {
45  EventPumpState();
46 
47  unsigned int last_FPS_time;
48  unsigned int last_frame_time;
49  unsigned int most_recent_time;
50  std::size_t frames;
51 };
52 
58 class GG_API EventPumpBase
59 {
60 protected:
71  void LoopBody(GUI* gui, EventPumpState& state, bool do_non_rendering, bool do_rendering);
72 
74  static EventPumpState& State();
75 };
76 
120 class GG_API EventPump : public EventPumpBase
121 {
122 public:
123  virtual ~EventPump() {}
124 
127  virtual void operator()();
128 };
129 
134 class GG_API ModalEventPump : public EventPump
135 {
136 public:
137  ModalEventPump(const bool& done);
138  virtual void operator()();
139 
140 protected:
142  bool Done() const;
143 
144 private:
145  const bool& m_done;
146 };
147 
148 } // namespace GG
149 
150 #endif