00001 #ifndef TIMER_H 00002 #define TIMER_H 00003 00004 #include <string> 00005 #include <boost/shared_ptr.hpp> 00006 #include <sys/time.h> 00007 #include "mimasconfig.h" 00008 #include "object.h" 00009 00010 namespace mimas { 00011 00013 class timer 00014 { 00015 public: 00018 timer(void) { reset(); } 00021 void reset(void) { 00022 #ifdef HAVE_GETTIMEOFDAY 00023 gettimeofday( &time, NULL ); 00024 #else 00025 assert( false ); 00026 #endif 00027 } 00033 double elapsed(std::string unit ="s") const; 00034 protected: 00036 struct timeval time; 00037 }; 00038 00040 typedef boost::shared_ptr< timer > timer_ptr; 00041 00042 }; 00043 00044 00045 #endif