go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
elxTimer.h
Go to the documentation of this file.
00001 /*======================================================================
00002 
00003   This file is part of the elastix software.
00004 
00005   Copyright (c) University Medical Center Utrecht. All rights reserved.
00006   See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for
00007   details.
00008 
00009      This software is distributed WITHOUT ANY WARRANTY; without even
00010      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00011      PURPOSE. See the above copyright notices for more information.
00012 
00013 ======================================================================*/
00014 #ifndef __elxTimer_H_
00015 #define __elxTimer_H_
00016 
00017 #include "itkObject.h"
00018 #include "itkObjectFactory.h"
00019 #include <ctime>
00020 #include <sstream>
00021 
00044 namespace tmr
00045 {
00046 using namespace itk;
00047 
00067 class Timer : public Object
00068 {
00069 public:
00071   typedef Timer                       Self;
00072   typedef Object                      Superclass;
00073   typedef SmartPointer<Self>          Pointer;
00074   typedef SmartPointer<const Self>    ConstPointer;
00075 
00077   itkNewMacro( Self );
00078 
00080   itkTypeMacro( Timer, Object );
00081 
00083   typedef std::vector<std::size_t>         TimeDHMSType;
00084 
00086   void StartTimer( void );
00087   int StopTimer( void );
00088   int ElapsedClockAndTime( void );
00089 
00093   const std::string & PrintStartTime( void );
00094   const std::string & PrintStopTime( void );
00095   const std::string & PrintElapsedTimeDHMS( void );
00096   const std::string & PrintElapsedTimeSec( void );
00097   const std::string & PrintElapsedClock( void );
00098   const std::string & PrintElapsedClockSec( void );
00099 
00101   itkGetConstMacro( StartTime, time_t );
00102   itkGetConstMacro( StopTime, time_t );
00103   itkGetConstMacro( ElapsedTime, double );
00104   //  itkGetConstMacro( ElapsedTimeDHMS, TimeDHMSType );
00105   itkGetConstMacro( ElapsedTimeSec, std::size_t );
00106   itkGetConstMacro( ElapsedClock, double );
00107   itkGetConstMacro( ElapsedClockSec, double );
00108 
00109 protected:
00110 
00111   Timer();
00112   virtual ~Timer(){};
00113 
00115   time_t        m_StartTime;
00116   clock_t       m_StartClock;
00117   time_t        m_StopTime;
00118   clock_t       m_StopClock;
00119   double        m_ElapsedTime;
00120   clock_t       m_ElapsedClock;
00121   TimeDHMSType  m_ElapsedTimeDHMS;
00122   std::size_t   m_ElapsedTimeSec;
00123   double        m_ElapsedClockSec;
00124 
00126 #if defined( __GNUC__ ) && !defined( __APPLE__ )
00127 #define ELX_USE_CLOCK_GETTIME
00128   struct timespec m_StartClockMonotonic;
00129   struct timespec m_StopClockMonotonic;
00130 #endif
00131 
00133   std::string m_StartTimeString;
00134   std::string m_StopTimeString;
00135   std::string m_ElapsedTimeDHMSString;
00136   std::string m_ElapsedTimeSecString;
00137   std::string m_ElapsedClockString;
00138   std::string m_ElapsedClockSecString;
00139 
00140 private:
00141 
00142   Timer( const Self& );           // purposely not implemented
00143   void operator=( const Self& );  // purposely not implemented
00144 
00145 }; // end class Timer
00146 
00147 
00148 } // end namespace tmr
00149 
00150 
00151 #endif // end #ifndef __elxTimer_H_


Generated on 24-05-2012 for elastix by doxygen 1.7.6.1 elastix logo