time_stamp.h

Go to the documentation of this file.
00001 #ifndef TIME_STAMP_CLASS
00002 #define TIME_STAMP_CLASS
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : time_stamp                                                        *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 1995-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
00016 \*****************************************************************************/
00017 
00018 #include "mechanisms_dll.h"
00019 
00020 // forward.
00021 class rollover_record;
00022 
00024 
00032 class MECHANISMS_CLASS_STYLE time_stamp
00033 {
00034 public:
00035   typedef double time_representation;
00037 
00038   time_stamp();
00040 
00041   time_stamp(time_representation offset);
00043 
00046   void reset();
00048   void reset(time_representation offset);
00050 
00051   time_representation value() const { return _stamp; }
00053 
00054   enum stamp_display_style { STAMP_RELATIVE, STAMP_ABSOLUTE };
00055 
00056   istring text_form(stamp_display_style style = STAMP_RELATIVE) const;
00058 
00062   // standard operators: keep in mind that time is represented by an ever
00063   // increasing number.  so, if a value A is less than a value B, that means
00064   // that A is older than B, since it occurred at an earlier time.
00065   inline bool operator < (const time_stamp &that) const
00066           { return _stamp < that._stamp; }
00067   inline bool operator > (const time_stamp &that) const
00068           { return _stamp > that._stamp; }
00069   inline bool operator <= (const time_stamp &that) const
00070           { return _stamp <= that._stamp; }
00071   inline bool operator >= (const time_stamp &that) const
00072           { return _stamp >= that._stamp; }
00073   inline bool operator != (const time_stamp &that) const
00074           { return _stamp != that._stamp; }
00075   inline bool operator == (const time_stamp &that) const
00076           { return _stamp == that._stamp; }
00077 
00078 private:
00079   time_representation _stamp;  
00080 
00081   void fill_in_time();  
00082 
00083   static time_representation get_time_now();
00085 
00086   static rollover_record &rollover_rover();
00087 };
00088 
00089 #endif
00090 

Generated on Fri Nov 21 04:29:50 2008 for HOOPLE Libraries by  doxygen 1.5.1