log4tango  5.0.1
TimeStamp.hh
Go to the documentation of this file.
1 //
2 // TimeStamp.hh
3 //
4 // Copyright (C) : 2000 - 2002
5 // LifeLine Networks BV (www.lifeline.nl). All rights reserved.
6 // Bastiaan Bakker. All rights reserved.
7 //
8 // 2004,2005,2006,2007,2008,2009,2010,2011,2012
9 // Synchrotron SOLEIL
10 // L'Orme des Merisiers
11 // Saint-Aubin - BP 48 - France
12 //
13 // This file is part of log4tango.
14 //
15 // Log4ango is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU Lesser General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 // Log4tango is distributed in the hope that it will be useful,
21 // but WITHOUT ANY WARRANTY; without even the implied warranty of
22 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 // GNU Lesser General Public License for more details.
24 //
25 // You should have received a copy of the GNU Lesser General Public License
26 // along with Log4Tango. If not, see <http://www.gnu.org/licenses/>.
27 
28 #ifndef _LOG4TANGO_TIMESTAMP_H
29 #define _LOG4TANGO_TIMESTAMP_H
30 
31 #include <log4tango/Portability.hh>
32 
33 namespace log4tango {
34 
35 //-----------------------------------------------------------------------------
36 // Class : TimeStamp (timestamp abstraction)
37 //-----------------------------------------------------------------------------
39 {
40 public:
44  TimeStamp();
45 
49  inline TimeStamp (const TimeStamp& t)
50  : _seconds(t._seconds), _micro_seconds(t._micro_seconds)
51  {
52  //--noop
53  };
54 
59  inline TimeStamp(unsigned int seconds, unsigned int microseconds = 0)
60  : _seconds(seconds), _micro_seconds(microseconds)
61  {
62  //--noop
63  };
64 
68  inline int get_seconds (void) const {
69  return _seconds;
70  };
71 
76  inline int get_milliseconds (void) const {
77  return _micro_seconds / 1000;
78  };
79 
85  inline int get_microseconds (void) const {
86  return _micro_seconds;
87  };
88 
93  static inline const TimeStamp& get_start_time (void) {
94  return _start_stamp;
95  };
96 
100  inline void operator= (const TimeStamp& t) {
101  _seconds = t._seconds;
102  _micro_seconds = t._micro_seconds;
103  };
104 
105 protected:
106  static TimeStamp _start_stamp;
107  int _seconds;
109 };
110 
111 } // namespace log4tango
112 
113 #endif // _LOG4TANGO_TIMESTAMP_H
114 
log4tango::TimeStamp::get_microseconds
int get_microseconds(void) const
Returns the subsecond part of the TimeStamp in microseconds.
Definition: TimeStamp.hh:85
Portability.hh
log4tango::TimeStamp
Definition: TimeStamp.hh:38
log4tango::TimeStamp::_seconds
int _seconds
Definition: TimeStamp.hh:107
log4tango::TimeStamp::TimeStamp
TimeStamp(unsigned int seconds, unsigned int microseconds=0)
Constructs a TimeStamp representing the given offset since the epoch ( 00:00:00 1970/1/1 UTC).
Definition: TimeStamp.hh:59
log4tango::TimeStamp::get_start_time
static const TimeStamp & get_start_time(void)
Returns a TimeStamp representing the time at which the application started.
Definition: TimeStamp.hh:93
log4tango::TimeStamp::TimeStamp
TimeStamp(const TimeStamp &t)
Copy Constructor.
Definition: TimeStamp.hh:49
log4tango::TimeStamp::get_milliseconds
int get_milliseconds(void) const
Returns the 'subseconds' part of the TimeStamp in milliseconds, get_milliseconds() == get_microsecond...
Definition: TimeStamp.hh:76
log4tango
Definition: Appender.hh:40
LOG4TANGO_EXPORT
#define LOG4TANGO_EXPORT
Definition: Export.hh:38
log4tango::TimeStamp::get_seconds
int get_seconds(void) const
Returns the 'seconds' part of the TimeStamp.
Definition: TimeStamp.hh:68
log4tango::TimeStamp::_micro_seconds
int _micro_seconds
Definition: TimeStamp.hh:108