news download themes documentation links










Timer.hh

00001 // Timer.hh for FbTk - Fluxbox Toolkit
00002 // Copyright (c) 2002-2003 Henrik Kinnunen (fluxgen at users.sourceforge.net)
00003 //
00004 // Timer.hh for Blackbox - An X11 Window Manager
00005 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes at tcac.net)
00006 //
00007 // Permission is hereby granted, free of charge, to any person obtaining a
00008 // copy of this software and associated documentation files (the "Software"),
00009 // to deal in the Software without restriction, including without limitation
00010 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
00011 // and/or sell copies of the Software, and to permit persons to whom the 
00012 // Software is furnished to do so, subject to the following conditions:
00013 //
00014 // The above copyright notice and this permission notice shall be included in 
00015 // all copies or substantial portions of the Software. 
00016 //
00017 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
00018 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
00019 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
00020 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
00021 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
00022 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
00023 // DEALINGS IN THE SOFTWARE.
00024     
00025 #ifndef  FBTK_TIMER_HH
00026 #define  FBTK_TIMER_HH
00027 
00028 #include "RefCount.hh"
00029 
00030 #include <ctime> 
00031 #include <list>
00032 
00033 #ifdef HAVE_CONFIG_H
00034 #include "config.h"
00035 #endif //HAVE_CONFIG_H
00036 
00037 #ifdef HAVE_INTTYPES_H
00038 #include <inttypes.h>
00039 #include <sys/types.h>
00040 #endif // HAVE_INTTYPES_H
00041 
00042 #include <sys/select.h>
00043 #include <sys/time.h>
00044 #include <sys/types.h>
00045 #include <unistd.h>
00046 
00047 namespace FbTk {
00048 
00049 class Command;
00050 
00054 class Timer {
00055 public:
00056     Timer();
00057     explicit Timer(RefCount<Command> &handler);
00058     virtual ~Timer();
00059 
00060     inline void fireOnce(bool once) { m_once = once; }
00062     void setTimeout(time_t val);
00064     void setTimeout(timeval val);
00065     void setCommand(RefCount<Command> &cmd);
00067     void start();
00069     void stop();
00071     static void updateTimers(int file_descriptor);
00072 
00073     inline int isTiming() const { return m_timing; } 
00074     inline int doOnce() const { return m_once; }
00075     
00076     inline const timeval &getTimeout() const { return m_timeout; }
00077     inline const timeval &getStartTime() const { return m_start; }
00078 
00079 protected:
00081     void fireTimeout();
00082 
00083 private:
00085     static void addTimer(Timer *timer);
00087     static void removeTimer(Timer *timer);
00088     
00089     typedef std::list<Timer *> TimerList;
00090     static TimerList m_timerlist; 
00091     
00092     RefCount<Command> m_handler; 
00093     
00094     bool m_timing; 
00095     bool m_once;  
00096 
00097     timeval m_start;    
00098     timeval m_timeout; 
00099 
00100 };
00101 
00102 } // end namespace FbTk
00103 
00104 #endif // FBTK_TIMER_HH
00105 

Fluxbox CVS-Jan-2003




      



Got comments about the page? Send them to webmaster.
If you have general Fluxbox related questions ask them on our irc channel or mailing lists.

Show Source








Designed by aLEczapKA