Gazebo

Time.hh

00001 /*
00002  *  Gazebo - Outdoor Multi-Robot Simulator
00003  *  Copyright (C) 2003  
00004  *     Nate Koenig & Andrew Howard
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 /* Desc: External interfaces for Gazebo
00022  * Author: Nate Koenig
00023  * Date: 03 Apr 2007
00024  * SVN: $Id: Time.hh 156 2007-11-26 20:26:57Z natepak $
00025  */
00026 #ifndef TIME_HH
00027 #define TIME_HH
00028 
00029 #include <time.h>
00030 #include <iostream>
00031 
00032 namespace gazebo
00033 {
00037 
00038 
00041 class Time
00042 {
00044   public: Time();
00045 
00048   public: Time( const Time &time );
00049 
00052   public: Time( const struct timeval &tv );
00053 
00057   public: Time( int sec,  int usec );
00058 
00061   public: Time( double time );
00062 
00064   public: virtual ~Time();
00065 
00067   public: static Time GetWallTime();
00068 
00070   public: void SetToWallTime();
00071 
00075   public: void Set( int sec, int usec );
00076 
00079   public: void Set(double seconds);
00080 
00083   public: double Double() const;
00084 
00086   public: const Time &operator=( const struct timeval &tv );
00087 
00089   public: const Time &operator=( const Time &time );
00090 
00092   public: Time operator +( const struct timeval &tv ) const;
00093 
00095   public: const Time &operator +=( const struct timeval &tv );
00096 
00098   public: Time operator +( const Time &time ) const;
00099 
00101   public: const Time &operator +=( const Time &time );
00102 
00104   public: Time operator -( const struct timeval &tv ) const;
00105 
00107   public: const Time &operator -=( const struct timeval &tv );
00108 
00110   public: Time operator -( const Time &time ) const;
00111 
00113   public: const Time &operator -=( const Time &time );
00114 
00116   public: Time operator *( const struct timeval &tv ) const;
00117 
00119   public: const Time &operator *=( const struct timeval &tv );
00120 
00122   public: Time operator *( const Time &time ) const;
00123 
00125   public: const Time &operator *=( const Time &time );
00126 
00128   public: Time operator /( const struct timeval &tv ) const;
00129 
00131   public: const Time &operator /=( const struct timeval &tv );
00132 
00134   public: Time operator /( const Time &time ) const;
00135 
00137   public: const Time &operator /=( const Time &time );
00138 
00140   public: bool operator==( const struct timeval &tv ) const;
00142   public: bool operator==( const Time &time ) const;
00144   public: bool operator==( double time ) const;
00146   public: bool operator!=( const struct timeval &tv ) const;
00148   public: bool operator!=( const Time &time ) const;
00150   public: bool operator!=( double time ) const;
00152   public: bool operator<( const struct timeval &tv ) const;
00154   public: bool operator<( const Time &time ) const;
00156   public: bool operator<( double time ) const;
00158   public: bool operator<=( const struct timeval &tv ) const;
00160   public: bool operator<=( const Time &time ) const;
00162   public: bool operator<=( double time ) const;
00164   public: bool operator>( const struct timeval &tv ) const;
00166   public: bool operator>( const Time &time ) const;
00168   public: bool operator>( double time ) const;
00170   public: bool operator>=( const struct timeval &tv ) const;
00172   public: bool operator>=( const Time &time ) const;
00174   public: bool operator>=( double time ) const;
00175 
00177   public: friend std::ostream &operator<<(std::ostream &out, const Time &time);
00178 
00180   public: int sec;
00181 
00183   public: int usec;
00184 
00186   private: void Correct();
00187 };
00189 
00190 }
00191 #endif
00192 

Last updated Aug 04 2007