orca-robotics


INTRODUCTION
Overview
Download and Install
Documentation

REPOSITORY
Interfaces
Drivers
Libraries
Utilities
Software Map

DEVELOPER
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-2008 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     void reset();
00042 
00043 protected:
00044 
00045     // Overload this according to the type of time we're measuring.
00046     virtual void getTimeNow( struct timeval &now ) const=0;
00047 
00048 private: 
00049 
00050     bool   isRunning_;
00051 
00052     timeval elapsed_;
00053     timeval startTime_;
00054 
00055     // Call this only when the clock's ticking.
00056     void addTimeThisRun( timeval &accumulator ) const;
00057 };
00058 
00059 }
00060 
00061 #endif
 

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


Generated for Orca Robotics by  doxygen 1.4.5