libGizmod/GizmodTimer.hpp

Go to the documentation of this file.
00001 
00012 /*
00013   
00014   Copyright (c) 2007, Tim Burrell
00015   Licensed under the Apache License, Version 2.0 (the "License");
00016   you may not use this file except in compliance with the License.
00017   You may obtain a copy of the License at 
00018 
00019         http://www.apache.org/licenses/LICENSE-2.0
00020 
00021   Unless required by applicable law or agreed to in writing, software
00022   distributed under the License is distributed on an "AS IS" BASIS,
00023   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00024   See the License for the specific language governing permissions and 
00025   limitations under the License. 
00026   
00027 */
00028 
00029 #ifndef __GizmodTimer_h
00030 #define __GizmodTimer_h
00031 
00032 #if HAVE_CONFIG_H
00033 #include "config.h"
00034 #endif
00035 
00036 #include "GizmodShared.hpp"
00037 #include <boost/python.hpp>
00038 
00040 // Namespace
00042 
00043 namespace Gizmod {
00044 
00046 // Typedef, enum's
00048         
00050 // Class Definition
00052 
00060 class GizmodTimer : public GizmodShared {
00061 public:
00062         // public functions
00063         void                            cancel();               
00064         void                            resetTimer();           
00065         void                            setUserData(boost::python::object UserData); 
00066         void                            setTime(float Seconds); 
00067         void                            start();                
00068         
00069         // construction / deconstruction        
00070         GizmodTimer(float Seconds, boost::python::object TimerFunction); 
00071         GizmodTimer(float Seconds, boost::python::object TimerFunction, boost::python::object UserData); 
00072         GizmodTimer(float Seconds, boost::python::object TimerFunction, int Repeats, boost::python::object UserData); 
00073         virtual ~GizmodTimer();                                 
00074 
00075 private:
00076         // private functions
00077         void                            threadProc();           
00078         
00079         // private member variables
00080         bool                            mCancel;                
00081         int                             mRepeats;               
00082         float                           mSleepTime;             
00083         boost::python::object           mTimerFunction;         
00084         int                             mTotalRepeats;          
00085         float                           mTotalSlept;            
00086         boost::python::object           mUserData;              
00087         
00091         struct GizmodTimerThreadProc {
00092                 GizmodTimerThreadProc(GizmodTimer * pGizmodTimer) : mpGizmodTimer(pGizmodTimer) {
00093                         mpGizmodTimer->mThreading = false;
00094                 };
00095                 
00097                 void operator()() {
00098                         mpGizmodTimer->mThreading = true;
00099                         mpGizmodTimer->threadProc();
00100                         mpGizmodTimer->mThreading = false;
00101                 }
00102                 
00103                 GizmodTimer *           mpGizmodTimer;
00104         };              
00105         bool                            mThreading;     
00106         GizmodTimerThreadProc           mThreadProc;    
00107 };
00108 
00110 
00111 } // Gizmod namespace
00112 
00113 #endif // __GizmodTimer_h

Generated on Wed Nov 7 10:04:16 2007 for gizmod by  doxygen 1.5.3