File indexing completed on 2024-04-06 12:01:58
0001 #ifndef CondCommon_Time_h
0002 #define CondCommon_Time_h
0003 #include <utility>
0004 #include <string>
0005 #include <limits>
0006
0007
0008 #include "CondFormats/Common/interface/hash64.h"
0009
0010 namespace cond {
0011
0012
0013 typedef unsigned long long uint64_t;
0014 typedef unsigned long long Time_t;
0015 typedef std::pair<unsigned int, unsigned int> UnpackedTime;
0016
0017 typedef std::pair<Time_t, Time_t> ValidityInterval;
0018
0019 typedef enum { invalid = -1, runnumber = 0, timestamp, lumiid, hash, userid } TimeType;
0020 const unsigned int TIMETYPE_LIST_MAX = 5;
0021
0022 extern const cond::TimeType timeTypeList[TIMETYPE_LIST_MAX];
0023
0024 extern const cond::TimeType timeTypeValues[];
0025
0026 std::string const& timeTypeNames(int);
0027
0028 const Time_t TIMELIMIT(std::numeric_limits<Time_t>::max());
0029
0030 const Time_t invalidTime(0);
0031
0032 template <TimeType type>
0033 struct RealTimeType {};
0034
0035 struct TimeTypeSpecs {
0036
0037 TimeType type;
0038
0039 std::string name;
0040
0041 Time_t beginValue;
0042 Time_t endValue;
0043 Time_t invalidValue;
0044 };
0045
0046 template <>
0047 struct RealTimeType<runnumber> {
0048
0049 typedef unsigned int type;
0050 };
0051
0052 template <>
0053 struct RealTimeType<timestamp> {
0054
0055 typedef uint64_t type;
0056 };
0057
0058 template <>
0059 struct RealTimeType<lumiid> {
0060
0061 typedef uint64_t type;
0062 };
0063
0064 template <>
0065 struct RealTimeType<hash> {
0066 typedef uint64_t type;
0067 };
0068
0069 template <>
0070 struct RealTimeType<userid> {
0071 typedef uint64_t type;
0072 };
0073
0074 template <TimeType type>
0075 struct TimeTypeTraits {
0076 static const TimeTypeSpecs& specs() {
0077 static const TimeTypeSpecs local = {type,
0078 timeTypeNames(type),
0079 1,
0080 std::numeric_limits<typename RealTimeType<type>::type>::max(),
0081 cond::invalidTime};
0082 return local;
0083 }
0084 };
0085
0086 extern const TimeTypeSpecs timeTypeSpecs[];
0087
0088
0089 const TimeTypeSpecs& findSpecs(std::string const& name);
0090
0091 }
0092 #endif