00001 /* 00002 * Copyright © 2008 Dennis Kasprzyk 00003 * 00004 * Permission to use, copy, modify, distribute, and sell this software 00005 * and its documentation for any purpose is hereby granted without 00006 * fee, provided that the above copyright notice appear in all copies 00007 * and that both that copyright notice and this permission notice 00008 * appear in supporting documentation, and that the name of 00009 * Dennis Kasprzyk not be used in advertising or publicity pertaining to 00010 * distribution of the software without specific, written prior permission. 00011 * Dennis Kasprzyk makes no representations about the suitability of this 00012 * software for any purpose. It is provided "as is" without express or 00013 * implied warranty. 00014 * 00015 * DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 00016 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN 00017 * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR 00018 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 00019 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 00020 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 00021 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 00022 * 00023 * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org> 00024 */ 00025 00026 #ifndef _TIMER_H 00027 #define _TIMER_H 00028 00029 #include <boost/function.hpp> 00030 00034 class CompTimer { 00035 00036 public: 00037 00038 typedef boost::function<bool ()> CallBack; 00039 00043 CompTimer (); 00044 00049 ~CompTimer (); 00050 00054 bool active (); 00055 unsigned int minTime (); 00056 unsigned int maxTime (); 00057 unsigned int minLeft (); 00058 unsigned int maxLeft (); 00059 00063 void setTimes (unsigned int min, unsigned int max = 0); 00064 00069 void setCallback (CallBack callback); 00070 00075 void start (); 00076 00081 void start (unsigned int min, unsigned int max = 0); 00082 00087 void start (CallBack callback, 00088 unsigned int min, unsigned int max = 0); 00089 00094 void stop (); 00095 00096 friend class CompScreen; 00097 friend class PrivateScreen; 00098 00099 private: 00100 bool mActive; 00101 unsigned int mMinTime; 00102 unsigned int mMaxTime; 00103 int mMinLeft; 00104 int mMaxLeft; 00105 CallBack mCallBack; 00106 }; 00107 00108 #endif