GG: Timer.h Source File

GG

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

Timer.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
29 #ifndef _GG_Timer_h_
30 #define _GG_Timer_h_
31
32 #include <GG/Base.h>
33
34 #include <set>
35
36
37 namespace GG {
38
39 class Wnd;
40
47 class GG_API Timer
48 {
49 public:
51 typedef boost::signal<void (unsigned int, Timer*)> FiredSignalType;
52
53
55
57 explicit Timer(unsigned int interval, unsigned int start_time = 0);
58
59 ~Timer();
60
61
63 unsigned int Interval() const;
64 bool Running() const;
65
66
68 void Reset(unsigned int start_time = 0);
69 void SetInterval(unsigned int interval);
70 void Connect(Wnd* wnd);
71 void Disconnect(Wnd* wnd);
72 void Start();
73 void Stop();
74 void Update(unsigned int ticks);
75
76
77 mutable FiredSignalType FiredSignal;
78
79 private:
80 typedef std::map<Wnd*, boost::signals::connection> ConnectionMap;
81
82 Timer();
83 Timer(const Timer&); // disabled
84
85 ConnectionMap m_wnd_connections;
86 unsigned int m_interval;
87 bool m_running;
88 unsigned int m_last_fire;
89 };
90
91 } // namespace GG
92
93 #endif