Timer.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 /* GG is a GUI for SDL and OpenGL.
00003    Copyright (C) 2003 T. Zachary Laine
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public License
00007    as published by the Free Software Foundation; either version 2.1
00008    of the License, or (at your option) any later version.
00009    
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014     
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with this library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA
00019 
00020    If you do not wish to comply with the terms of the LGPL please
00021    contact the author as other terms are available for a fee.
00022     
00023    Zach Laine
00024    whatwasthataddress@hotmail.com */
00025 
00029 #ifndef _GG_Timer_h_
00030 #define _GG_Timer_h_
00031 
00032 #include <GG/Base.h>
00033 
00034 #include <set>
00035 
00036 
00037 namespace GG {
00038 
00039 class Wnd;
00040 
00045 class GG_API Timer
00046 {
00047 public: 
00049 
00051     explicit Timer(int interval, int start_time = 0);
00052 
00053     ~Timer(); 
00054 
00055  
00057     bool Connected() const;             
00058     int Interval() const;               
00059     bool Running() const;               
00060     bool ShouldFire(int ticks) const;   
00061     const std::set<Wnd*>& Wnds() const; 
00062 
00063  
00065     void Reset(int start_time = 0); 
00066     void SetInterval(int interval); 
00067     void Connect(Wnd* wnd);         
00068     void Disconnect(Wnd* wnd);      
00069     void Start();                   
00070     void Stop();                    
00071 
00072 
00073 private:
00074     Timer();
00075     Timer(const Timer&); // disabled
00076 
00077     std::set<Wnd*> m_wnds;
00078     int            m_interval;
00079     bool           m_running;
00080     int            m_last_fire;
00081 
00082     friend class boost::serialization::access;
00083     template <class Archive>
00084     void serialize(Archive& ar, const unsigned int version);
00085 };
00086 
00087 } // namespace GG
00088 
00089 // template implementations
00090 template <class Archive>
00091 void GG::Timer::serialize(Archive& ar, const unsigned int version)
00092 {
00093     ar  & BOOST_SERIALIZATION_NVP(m_wnds)
00094         & BOOST_SERIALIZATION_NVP(m_interval)
00095         & BOOST_SERIALIZATION_NVP(m_last_fire)
00096         & BOOST_SERIALIZATION_NVP(m_running);
00097 }
00098 
00099 #endif

Generated on Wed Mar 26 14:35:42 2008 for GG by  doxygen 1.5.2