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                            start();                
00067         
00068         // construction / deconstruction        
00069         GizmodTimer(float Seconds, boost::python::object TimerFunction); 
00070         GizmodTimer(float Seconds, boost::python::object TimerFunction, boost::python::object UserData); 
00071         virtual ~GizmodTimer();                                 
00072 
00073 private:
00074         // private functions
00075         void                            threadProc();           
00076         
00077         // private member variables
00078         bool                            mCancel;                
00079         float                           mSleepTime;             
00080         boost::python::object           mTimerFunction;         
00081         float                           mTotalSlept;            
00082         boost::python::object           mUserData;              
00083         
00087         struct GizmodTimerThreadProc {
00088                 GizmodTimerThreadProc(GizmodTimer * pGizmodTimer) : mpGizmodTimer(pGizmodTimer) {
00089                         mpGizmodTimer->mThreading = false;
00090                 };
00091                 
00093                 void operator()() {
00094                         mpGizmodTimer->mThreading = true;
00095                         mpGizmodTimer->threadProc();
00096                         mpGizmodTimer->mThreading = false;
00097                 }
00098                 
00099                 GizmodTimer *           mpGizmodTimer;
00100         };              
00101         bool                            mThreading;     
00102         GizmodTimerThreadProc           mThreadProc;    
00103 };
00104 
00106 
00107 } // Gizmod namespace
00108 
00109 #endif // __GizmodTimer_h

Generated on Wed Jun 27 12:41:53 2007 for gizmod by  doxygen 1.4.7