D:/WorkDir/SugoiProjects/SugoiTracer/include/SugoiTracer/timer.h

Go to the documentation of this file.
00001 /* LICENSE_BEGIN
00002 SutoiTracer library supply support profiling functions, class, or evet simple 
00003 piece of code. It is part of the SugoiEngine project.
00004 Copyright (C) 2006 Allusse Yannick (yannick dot allusse at laposte dot net)
00005 
00006 
00007 This program is free software; you can redistribute it and/or
00008 modify it under the terms of the GNU General Public License
00009 as published by the Free Software Foundation; either version 2
00010 of the License, or (at your option) any later version.
00011 
00012 This program is distributed in the hope that it will be useful,
00013 but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with this program; if not, write to the Free Software
00019 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00020 LICENSE_END
00021 */
00022 
00023 #ifndef _SG_TRC_TIMER_H
00024 #define _SG_TRC_TIMER_H
00025 
00026 #ifdef __cplusplus
00027 
00028 #include <SugoiTracer\config.h>
00029 #include <SugoiTools\xml.h>
00030 
00031 
00032 
00033 #ifdef _WIN32
00034         #include <winsock.h>
00035 #else
00036         #include <sys/h>
00037 #endif
00038 
00039 #include <Time.h>
00040 #include <sys/timeb.h> 
00041 
00042 namespace SG_TRC{
00043 
00050 class  _SG_TRC_DLL_EXPORT CL_Virtual_Record :
00051                 public CL_XML_OBJ
00052 {
00053 public :
00054         CL_Virtual_Record(void)
00055                 :CL_XML_OBJ("vrecord")
00056                 {Clear();};             
00057 
00058         CL_Virtual_Record(const CL_Virtual_Record &_Rec2)
00059                 :CL_XML_OBJ("vrecord")
00060                 {Clear();};     
00061 
00062         CL_Virtual_Record(const long T)
00063                 :CL_XML_OBJ("vrecord")
00064                 {Clear();};
00065 
00066         virtual ~CL_Virtual_Record(void){Clear();};
00067         
00068         virtual void Clear(){};                         
00069         virtual void SetToMax(){};
00070         virtual void SetToMin(){};
00071 
00072           //arithmetic operators
00073         _SG_TRC_INLINE virtual CL_Virtual_Record&   operator  =( const long T){return *this;};                          
00074           _SG_TRC_INLINE virtual CL_Virtual_Record&   operator  =( const CL_Virtual_Record &_Rec2){return *this;};
00075           // _SG_TRC_INLINE CL_Virtual_Record&   operator  =( const ST_Timeval &_Timeval);
00076           _SG_TRC_INLINE virtual bool                           operator !=( const CL_Virtual_Record &_Rec2){return false;};
00077         //  _SG_TRC_INLINE virtual bool                         operator !=( const long T)= 0;//!< operator !=.
00078           _SG_TRC_INLINE virtual bool                           operator ==( const CL_Virtual_Record &_Rec2){return false;};
00079     //  _SG_TRC_INLINE virtual bool                             operator ==( const long T)= 0;//!< operator ==.
00080           _SG_TRC_INLINE virtual bool   operator < ( const CL_Virtual_Record &_Rec2){return false;};
00081       _SG_TRC_INLINE virtual bool   operator > ( const CL_Virtual_Record &_Rec2){return false;};
00082 
00083           _SG_TRC_INLINE virtual CL_Virtual_Record&   operator +=( const CL_Virtual_Record &_Rec2){return *this;};
00084       _SG_TRC_INLINE virtual CL_Virtual_Record&   operator -=( const CL_Virtual_Record &_Rec2){return *this;};
00085       _SG_TRC_INLINE virtual CL_Virtual_Record&   operator /=( const long T){return *this;};
00086       _SG_TRC_INLINE virtual CL_Virtual_Record&   operator *=( const long T){return *this;};
00087 
00088           _SG_TRC_INLINE virtual CL_Virtual_Record   operator  +( const CL_Virtual_Record &_Rec2){return *this;};
00089           _SG_TRC_INLINE virtual CL_Virtual_Record   operator  -( const CL_Virtual_Record &_Rec2){return *this;};
00090           _SG_TRC_INLINE virtual CL_Virtual_Record   operator  /( const long T){return *this;};
00091           _SG_TRC_INLINE virtual CL_Virtual_Record   operator  *( const long T){return *this;};
00092           //========================      
00093           
00094           _SG_TRC_INLINE virtual void Run(void){};
00095           _SG_TRC_INLINE virtual long GetValue(void){return 0;};
00096           _SG_TRC_INLINE virtual void SetValue(const long L){};
00097           _SG_TRC_INLINE virtual  std::string GetStr(bool _Approxmimate=true){return "";};
00098       _SG_TRC_INLINE virtual void Print(){};                                                    
00099           
00100 #if _SG_TLS_XML
00101 public:
00102         virtual TiXmlElement* XMLLoad(TiXmlElement* _XML_ROOT, std::string _Name =""){return NULL;};
00103         virtual TiXmlElement* XMLSave(TiXmlElement* _XML_ROOT, std::string _Name=""){return NULL;};
00104 #endif
00105 
00106 };
00107 
00108 
00109 
00110 typedef struct timeval ST_Timeval;
00126 class _SG_TRC_DLL_EXPORT CL_TimerVal : public CL_Virtual_Record
00127 {
00128 public :
00129 
00130           long    tv_sec;                       
00131       long    tv_usec;                  
00132           
00133  
00134       CL_TimerVal(void);                                                
00135           CL_TimerVal(const CL_TimerVal &Time2);        
00136           CL_TimerVal(const CL_Virtual_Record &_Rec2);
00137           CL_TimerVal(const ST_Timeval &_Timeval);
00138           CL_TimerVal(const long T);                            
00139       ~CL_TimerVal(void){};                                             
00140           void Clear();                         
00141           void SetToMax();
00142           void SetToMin();
00143 
00144           //arithmetic operators
00145           _SG_TRC_INLINE CL_TimerVal&   operator  =( const long T);                             
00146           _SG_TRC_INLINE CL_TimerVal&   operator  =( const CL_TimerVal &Time2);
00147 //        _SG_TRC_INLINE CL_TimerVal&   operator  =( const CL_Virtual_Record *Time2);//!< operator =.
00148           _SG_TRC_INLINE CL_TimerVal&   operator  =( const ST_Timeval &_Timeval);
00149           _SG_TRC_INLINE bool                           operator !=( const CL_TimerVal &Time2);
00150           //_SG_TRC_INLINE bool                         operator !=( const long T)= 0;
00151           _SG_TRC_INLINE bool                           operator ==( const CL_TimerVal &Time2);
00152           //_SG_TRC_INLINE bool                         operator ==( const long T)= 0;
00153       _SG_TRC_INLINE bool   operator < ( const CL_TimerVal &Time2);
00154       _SG_TRC_INLINE bool   operator > ( const CL_TimerVal &Time2);
00155 
00156           _SG_TRC_INLINE CL_TimerVal&   operator +=( const CL_TimerVal &Time2);
00157       _SG_TRC_INLINE CL_TimerVal&   operator -=( const CL_TimerVal &Time2);
00158       _SG_TRC_INLINE CL_TimerVal&   operator /=( const long T);
00159       _SG_TRC_INLINE CL_TimerVal&   operator *=( const long T);
00160 
00161           _SG_TRC_INLINE CL_TimerVal   operator  +( const CL_TimerVal &Time2)const;
00162           _SG_TRC_INLINE CL_TimerVal   operator  -( const CL_TimerVal &Time2)const;
00163           _SG_TRC_INLINE CL_TimerVal   operator  /( const long T)const;
00164           _SG_TRC_INLINE CL_TimerVal   operator  *( const long T)const;
00165           //========================      
00166           
00167       //_SG_TRC_INLINE void GetSysTime(void);                                   //!< Get the current system time from boot.
00168           _SG_TRC_INLINE void AddTimeUs(const unsigned int _time);
00169           _SG_TRC_INLINE void AddTimeMs(const unsigned int _time);
00170           _SG_TRC_INLINE long GetValue(void);                                   
00171           _SG_TRC_INLINE std::string GetStr(bool _Approxmimate=true)const;
00172       _SG_TRC_INLINE void Print();  
00173           _SG_TRC_INLINE void Run(CL_TimerVal * StopTime=NULL);
00174           //to put extern
00175         bool succes;            //set if the function traced was successfull
00176         int returnValue;        //store the return value.
00177           //=================
00178 
00179 #if _SG_TLS_XML
00180 public:
00181         TiXmlElement* XMLLoad(TiXmlElement* _XML_ROOT, std::string _Name ="");
00182         TiXmlElement* XMLSave(TiXmlElement* _XML_ROOT, std::string _Name="");
00183 #endif
00184 };
00185 
00186 extern "C"
00187 {
00188 #endif
00189 
00190 _SG_TLS_EXPORT int Ygettimeofday(struct timeval * tp);
00191 _SG_TLS_EXPORT void cleartimeval(struct timeval * t1);
00192 
00193 };//namespace SG_TRC
00194 #ifdef __cplusplus
00195 }//to export this few functions to 'C'
00196 #endif
00197 
00198 #endif//_SG_TRC_TIMER_H

Generated on Mon Mar 19 23:16:20 2007 for SugoiTracer by  doxygen 1.4.6-NO