INTRODUCTION
Overview
Download and Install
Quick Start
Documentation
Publications

NONFRAMEWORK CODE
Driver Interfaces
Drivers
Libraries
Utilities

FRAMEWORK CODE
Interfaces
Components
Libraries
Utilities

Full Software Listings

DEVELOPER
Tutorials
Examples
Dev Guide
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         

stopwatch.h

00001 /*
00002  * Orca-Robotics Project: Components for robotics 
00003  *               http://orca-robotics.sf.net/
00004  * Copyright (c) 2004-2009 Alex Brooks, Alexei Makarenko, Tobias Kaupp
00005  *
00006  * This distribution is licensed to you under the terms described in
00007  * the LICENSE file included in this distribution.
00008  *
00009  */
00010 #ifndef HYDROUTIL_STOPWATCH_H
00011 #define HYDROUTIL_STOPWATCH_H
00012 
00013 #include <sys/time.h>
00014 
00015 namespace hydroutil {
00016 
00029 class Stopwatch
00030 {
00031 
00032 public: 
00033 
00034     virtual ~Stopwatch() {};
00035 
00036     void start();
00037     void stop();
00038     void startWithoutReset();
00039     
00040     double elapsedSeconds() const;
00041     double elapsedMs() const { return elapsedSeconds()*1000.0; }
00042     void reset();
00043 
00044 protected:
00045 
00046     // Overload this according to the type of time we're measuring.
00047     virtual void getTimeNow( struct timeval &now ) const=0;
00048 
00049 private: 
00050 
00051     bool   isRunning_;
00052 
00053     timeval elapsed_;
00054     timeval startTime_;
00055 
00056     // Call this only when the clock's ticking.
00057     void addTimeThisRun( timeval &accumulator ) const;
00058 };
00059 
00060 }
00061 
00062 #endif
 

Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)


Generated for Orca Robotics by  doxygen 1.4.5