CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/CondFormats/Common/interface/Time.h

Go to the documentation of this file.
00001 #ifndef CondCommon_Time_h
00002 #define CondCommon_Time_h 
00003 #include<utility>
00004 #include <string>
00005 #include <limits>
00006 // #include <boost/cstdint.hpp>
00007 
00008 #include "CondFormats/Common/interface/hash64.h"
00009 
00010 
00011 namespace cond{
00012   
00013   
00014   // typedef uint64_t  Time_t;
00015   typedef unsigned long long uint64_t; // avoid typedef to long on 64 bit
00016   typedef unsigned long long Time_t;
00017   typedef std::pair<unsigned int, unsigned int> UnpackedTime;
00018   
00019   typedef std::pair<Time_t, Time_t> ValidityInterval;
00020   
00021   typedef enum { runnumber=0, timestamp, lumiid, hash, userid } TimeType;
00022   const unsigned int TIMETYPE_LIST_MAX=5;
00023   
00024   extern const cond::TimeType timeTypeList[TIMETYPE_LIST_MAX];
00025   
00026   extern const cond::TimeType timeTypeValues[];
00027 
00028   std::string const & timeTypeNames(int);
00029   
00030   const Time_t TIMELIMIT(std::numeric_limits<Time_t>::max());
00031   
00032   const Time_t invalidTime(0);
00033 
00034   template<TimeType type>
00035   struct RealTimeType {
00036   };
00037   
00038   
00039   struct TimeTypeSpecs {
00040     // the enum
00041     TimeType type;
00042     // the name
00043     std::string name;
00044     // begin, end, and invalid 
00045     Time_t beginValue;
00046     Time_t endValue;
00047     Time_t invalidValue;
00048     
00049   }; 
00050   
00051   
00052   template<> struct RealTimeType<runnumber> {
00053     // 0, run number
00054     typedef unsigned int type; 
00055   };
00056   
00057   template<> struct RealTimeType<timestamp> {
00058     // sec, nanosec
00059     typedef uint64_t  type; 
00060   };
00061   
00062   
00063   template<> struct RealTimeType<lumiid> {
00064     // run, lumi-seg
00065     typedef uint64_t  type; 
00066   };
00067   
00068   template<> struct RealTimeType<hash> {
00069     typedef uint64_t  type; 
00070   };
00071 
00072   template<> struct RealTimeType<userid> {
00073     typedef uint64_t  type; 
00074   };
00075   
00076   
00077   template<TimeType type>
00078   struct TimeTypeTraits {
00079     static  const TimeTypeSpecs & specs() {
00080       static const TimeTypeSpecs local = { 
00081         type,
00082         timeTypeNames(type),
00083         1,
00084         std::numeric_limits<typename RealTimeType<type>::type>::max(),
00085         cond::invalidTime
00086       };
00087       return local;
00088     }
00089   };
00090   
00091   extern const TimeTypeSpecs timeTypeSpecs[];
00092   
00093   // find spec by name
00094   const TimeTypeSpecs & findSpecs(std::string const & name);
00095   
00096 
00097 }
00098 #endif
00099