CMS 3D CMS Logo

Time.h
Go to the documentation of this file.
1 #ifndef CondCommon_Time_h
2 #define CondCommon_Time_h
3 #include<utility>
4 #include <string>
5 #include <limits>
6 // #include <boost/cstdint.hpp>
7 
9 
10 
11 namespace cond{
12 
13 
14  // typedef uint64_t Time_t;
15  typedef unsigned long long uint64_t; // avoid typedef to long on 64 bit
16  typedef unsigned long long Time_t;
17  typedef std::pair<unsigned int, unsigned int> UnpackedTime;
18 
19  typedef std::pair<Time_t, Time_t> ValidityInterval;
20 
21  typedef enum { invalid=-1, runnumber=0, timestamp, lumiid, hash, userid } TimeType;
22  const unsigned int TIMETYPE_LIST_MAX=5;
23 
25 
26  extern const cond::TimeType timeTypeValues[];
27 
28  std::string const & timeTypeNames(int);
29 
31 
32  const Time_t invalidTime(0);
33 
34  template<TimeType type>
35  struct RealTimeType {
36  };
37 
38 
39  struct TimeTypeSpecs {
40  // the enum
41  TimeType type;
42  // the name
44  // begin, end, and invalid
45  Time_t beginValue;
46  Time_t endValue;
47  Time_t invalidValue;
48 
49  };
50 
51 
52  template<> struct RealTimeType<runnumber> {
53  // 0, run number
54  typedef unsigned int type;
55  };
56 
57  template<> struct RealTimeType<timestamp> {
58  // sec, nanosec
59  typedef uint64_t type;
60  };
61 
62 
63  template<> struct RealTimeType<lumiid> {
64  // run, lumi-seg
65  typedef uint64_t type;
66  };
67 
68  template<> struct RealTimeType<hash> {
69  typedef uint64_t type;
70  };
71 
72  template<> struct RealTimeType<userid> {
73  typedef uint64_t type;
74  };
75 
76 
77  template<TimeType type>
78  struct TimeTypeTraits {
79  static const TimeTypeSpecs & specs() {
80  static const TimeTypeSpecs local = {
81  type,
83  1,
86  };
87  return local;
88  }
89  };
90 
91  extern const TimeTypeSpecs timeTypeSpecs[];
92 
93  // find spec by name
94  const TimeTypeSpecs & findSpecs(std::string const & name);
95 
96 
97 }
98 #endif
99 
const TimeTypeSpecs timeTypeSpecs[]
Definition: Time.cc:22
type
Definition: HCALResponse.h:21
const cond::TimeType timeTypeList[TIMETYPE_LIST_MAX]
Definition: Time.cc:9
Time_t beginValue
Definition: Time.h:45
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:19
TimeType
Definition: Time.h:21
const unsigned int TIMETYPE_LIST_MAX
Definition: Time.h:22
std::string const & timeTypeNames(int)
Definition: Time.cc:15
unsigned long long Time_t
Definition: Time.h:16
TimeType type
Definition: Time.h:41
const Time_t invalidTime(0)
const cond::TimeType timeTypeValues[]
Definition: Time.cc:12
unsigned long long uint64_t
Definition: Time.h:15
Time_t invalidValue
Definition: Time.h:47
const Time_t TIMELIMIT(std::numeric_limits< Time_t >::max())
std::string name
Definition: Time.h:43
static const TimeTypeSpecs & specs()
Definition: Time.h:79
std::pair< unsigned int, unsigned int > UnpackedTime
Definition: Time.h:17
Definition: plugin.cc:24
const TimeTypeSpecs & findSpecs(std::string const &name)
Definition: Time.cc:33
Time_t endValue
Definition: Time.h:46