log4tango 4.0.3
TimeStamp.hh
Go to the documentation of this file.
00001 //
00002 // TimeStamp.hh
00003 //
00004 // Copyright (C) :  2000 - 2002
00005 //                                      LifeLine Networks BV (www.lifeline.nl). All rights reserved.
00006 //                                      Bastiaan Bakker. All rights reserved.   
00007 //                                      
00008 //                                      2004,2005,2006,2007,2008,2009,2010
00009 //                                      Synchrotron SOLEIL
00010 //                      L'Orme des Merisiers
00011 //                      Saint-Aubin - BP 48 - France
00012 //
00013 // This file is part of log4tango.
00014 //
00015 // Log4ango is free software: you can redistribute it and/or modify
00016 // it under the terms of the GNU Lesser General Public License as published by
00017 // the Free Software Foundation, either version 3 of the License, or
00018 // (at your option) any later version.
00019 // 
00020 // Log4tango is distributed in the hope that it will be useful,
00021 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 // GNU Lesser General Public License for more details.
00024 // 
00025 // You should have received a copy of the GNU Lesser General Public License
00026 // along with Log4Tango.  If not, see <http://www.gnu.org/licenses/>.
00027 
00028 #ifndef _LOG4TANGO_TIMESTAMP_H
00029 #define _LOG4TANGO_TIMESTAMP_H
00030 
00031 #include <log4tango/Portability.hh>
00032 
00033 namespace log4tango {
00034 
00035 //-----------------------------------------------------------------------------
00036 // Class : TimeStamp (timestamp abstraction)
00037 //-----------------------------------------------------------------------------
00038 class LOG4TANGO_EXPORT TimeStamp 
00039 {
00040 public:
00044   TimeStamp();
00045 
00049   inline TimeStamp (const TimeStamp& t) 
00050     : _seconds(t._seconds), _micro_seconds(t._micro_seconds)   
00051   {
00052     //--noop    
00053   };
00054   
00059   inline TimeStamp(unsigned int seconds, unsigned int microseconds = 0)
00060     : _seconds(seconds), _micro_seconds(microseconds)   
00061   {
00062     //--noop    
00063   };
00064   
00068   inline int get_seconds (void) const {
00069       return _seconds;
00070   };
00071 
00076   inline int get_milliseconds (void) const {
00077       return _micro_seconds / 1000;
00078   };
00079 
00085   inline int get_microseconds (void) const {
00086       return _micro_seconds;
00087   };
00088 
00093   static inline const TimeStamp& get_start_time (void) {
00094       return _start_stamp;
00095   };
00096 
00100   inline void operator= (const TimeStamp& t) {
00101     _seconds = t._seconds;
00102     _micro_seconds = t._micro_seconds;
00103   };
00104   
00105 protected:
00106   static TimeStamp _start_stamp;
00107   int _seconds;
00108   int _micro_seconds;
00109 };
00110 
00111 } // namespace log4tango
00112 
00113 #endif // _LOG4TANGO_TIMESTAMP_H
00114