This is Unofficial EPICS BASE Doxygen Site
timeStamp.h
Go to the documentation of this file.
1 /* timeStamp.h */
2 /*
3  * Copyright information and license terms for this software can be
4  * found in the file LICENSE that is included with the distribution
5  */
9 #ifndef TIMESTAMP_H
10 #define TIMESTAMP_H
11 
12 #include <ctime>
13 
14 #include <epicsTime.h>
15 #include <shareLib.h>
16 
17 #include <pv/pvType.h>
18 
19 
20 namespace epics { namespace pvData {
21 
26 
44 public:
49  :secondsPastEpoch(0), nanoseconds(0), userTag(0) {}
56  TimeStamp(int64 secondsPastEpoch,int32 nanoseconds = 0,int32 userTag = 0);
57  //default constructors and destructor are OK
58  //This class should not be extended
63  void normalize();
68  void fromTime_t(const time_t & time);
73  void toTime_t(time_t &time) const;
78  int64 getSecondsPastEpoch() const {return secondsPastEpoch;}
85  return secondsPastEpoch - posixEpochAtEpicsEpoch;
86  }
91  int32 getNanoseconds() const {return nanoseconds;}
96  int32 getUserTag() const {return userTag;}
101  void setUserTag(int32 userTag) {this->userTag = userTag;}
108  void put(int64 secondsPastEpoch,int32 nanoseconds = 0) {
109  this->secondsPastEpoch = secondsPastEpoch;
110  this->nanoseconds = nanoseconds;
111  normalize();
112  }
117  void put(int64 milliseconds);
121  void getCurrent();
126  double toSeconds() const ;
130  bool operator==(TimeStamp const &) const;
134  bool operator!=(TimeStamp const &) const;
138  bool operator<=(TimeStamp const &) const;
142  bool operator< (TimeStamp const &) const;
146  bool operator>=(TimeStamp const &) const;
150  bool operator> (TimeStamp const &) const;
157  static double diff(TimeStamp const & a,TimeStamp const & b);
161  TimeStamp & operator+=(int64 seconds);
165  TimeStamp & operator-=(int64 seconds);
169  TimeStamp & operator+=(double seconds);
173  TimeStamp & operator-=(double seconds);
178  int64 getMilliseconds();
179 private:
180  static int64 diffInt(TimeStamp const &left,TimeStamp const &right );
181  int64 secondsPastEpoch;
182  int32 nanoseconds;
183  int32 userTag;
184 };
185 
186 
187 }}
188 #endif /* TIMESTAMP_H */
epicsShareExtern const int32 nanoSecPerSec
Definition: timeStamp.h:24
std::tr1::shared_ptr< detail::SharedPut > put
TODO only here because of the Lockable.
Definition: ntaggregate.cpp:16
int64 getEpicsSecondsPastEpoch() const
Definition: timeStamp.h:84
Mark external symbols and entry points for shared libraries.
#define epicsShareExtern
Definition: shareLib.h:204
int32 getNanoseconds() const
Definition: timeStamp.h:91
bool operator<(shared_ptr< T > const &a, shared_ptr< U > const &b) BOOST_NOEXCEPT
Definition: shared_ptr.hpp:778
void put(int64 secondsPastEpoch, int32 nanoseconds=0)
Definition: timeStamp.h:108
epicsShareExtern const int32 microSecPerSec
Definition: timeStamp.h:23
#define epicsShareClass
Definition: shareLib.h:206
epicsShareExtern const int32 milliSecPerSec
Definition: timeStamp.h:22
int32 getUserTag() const
Definition: timeStamp.h:96
int64_t int64
Definition: pvType.h:87
bool operator==(const PVField &left, const PVField &right)
Definition: Compare.cpp:328
epicsShareExtern const int64 posixEpochAtEpicsEpoch
Definition: timeStamp.h:25
EPICS time-stamps (epicsTimeStamp), epicsTime C++ class and C functions for handling wall-clock times...
void setUserTag(int32 userTag)
Definition: timeStamp.h:101
int64 getSecondsPastEpoch() const
Definition: timeStamp.h:78
int32_t int32
Definition: pvType.h:83
Methods for manipulating timeStamp.
Definition: timeStamp.h:43