CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/DataFormats/Provenance/src/Timestamp.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     EDProduct
00004 // Module:      Timestamp
00005 // 
00006 // Description: <one line class summary>
00007 //
00008 // Implementation:
00009 //     <Notes on implementation>
00010 //
00011 // Author:      Chris Jones
00012 // Created:     Thu Mar 24 16:27:03 EST 2005
00013 //
00014 
00015 // system include files
00016 
00017 // user include files
00018 #include "DataFormats/Provenance/interface/Timestamp.h"
00019 
00020 namespace edm {
00021 //
00022 // constants, enums and typedefs
00023 //
00024 
00025 //
00026 // static data member definitions
00027 //
00028 static const TimeValue_t kLowMask(0xFFFFFFFF);
00029    
00030 //
00031 // constructors and destructor
00032 //
00033 Timestamp::Timestamp(TimeValue_t iValue) : 
00034    timeLow_(static_cast<unsigned int>(kLowMask & iValue)),
00035    timeHigh_(static_cast<unsigned int>(iValue >> 32))
00036 {
00037 }
00038 
00039 Timestamp::Timestamp() : timeLow_(invalidTimestamp().timeLow_),
00040 timeHigh_(invalidTimestamp().timeHigh_)
00041 {
00042 }
00043 // Timestamp::Timestamp(const Timestamp& rhs)
00044 // {
00045 //    // do actual copying here;
00046 // }
00047 
00048 Timestamp::~Timestamp()
00049 {
00050 }
00051 
00052 //
00053 // assignment operators
00054 //
00055 // const Timestamp& Timestamp::operator=(const Timestamp& rhs)
00056 // {
00057 //   //An exception safe implementation is
00058 //   Timestamp temp(rhs);
00059 //   swap(rhs);
00060 //
00061 //   return *this;
00062 // }
00063 
00064 //
00065 // member functions
00066 //
00067 
00068 //
00069 // const member functions
00070 //
00071 TimeValue_t 
00072 Timestamp::value() const {
00073    TimeValue_t returnValue = timeHigh_;
00074    returnValue = returnValue << 32;
00075    returnValue += timeLow_;
00076    return returnValue;
00077 }
00078 
00079 //
00080 // static member functions
00081 //
00082 const Timestamp&
00083 Timestamp::invalidTimestamp() {
00084    static Timestamp s_invalid(0);
00085    return s_invalid;
00086 }
00087 const Timestamp&
00088 Timestamp::endOfTime() {
00089    //calculate 2^N -1 where N is number of bits in TimeValue_t
00090    // by doing 2^(N-1) - 1 + 2^(N-1)
00091    const TimeValue_t temp = TimeValue_t(1) << (sizeof(TimeValue_t)/sizeof(char) * 8 - 1);
00092    static Timestamp s_endOfTime((temp -1) + temp);
00093    return s_endOfTime;
00094 }
00095 const Timestamp&
00096 Timestamp::beginOfTime() {
00097    static Timestamp s_beginOfTime(1);
00098    return s_beginOfTime;
00099 }
00100 
00101 }