File indexing completed on 2024-04-06 12:01:29
0001 #include "CondCore/CondDB/interface/Types.h"
0002 #include "CondCore/CondDB/interface/Exception.h"
0003
0004 #include <initializer_list>
0005 #include <vector>
0006 #include <map>
0007
0008 namespace cond {
0009
0010 void Iov_t::clear() {
0011 since = time::MAX_VAL;
0012 till = time::MIN_VAL;
0013 payloadId.clear();
0014 }
0015
0016 bool Iov_t::isValid() const { return since != time::MAX_VAL && till != time::MIN_VAL && !payloadId.empty(); }
0017
0018 bool Iov_t::isValidFor(Time_t target) const { return target >= since && target <= till; }
0019
0020 void Tag_t::clear() {
0021 name.clear();
0022 payloadType.clear();
0023 timeType = invalid;
0024 synchronizationType = SYNCH_ANY;
0025 endOfValidity = time::MIN_VAL;
0026 lastValidatedTime = time::MIN_VAL;
0027 }
0028
0029 static std::pair<const char *, SynchronizationType> s_synchronizationTypeArray[] = {
0030 std::make_pair("any", SYNCH_ANY),
0031 std::make_pair("validation", SYNCH_VALIDATION),
0032 std::make_pair("offline", SYNCH_OFFLINE),
0033 std::make_pair("mc", SYNCH_MC),
0034 std::make_pair("runmc", SYNCH_RUNMC),
0035 std::make_pair("hlt", SYNCH_HLT),
0036 std::make_pair("express", SYNCH_EXPRESS),
0037 std::make_pair("prompt", SYNCH_PROMPT),
0038 std::make_pair("pcl", SYNCH_PCL)};
0039
0040 static std::pair<const char *, SynchronizationType> s_obsoleteSynchronizationTypeArray[] = {
0041 std::make_pair("Offline", SYNCH_OFFLINE),
0042 std::make_pair("HLT", SYNCH_HLT),
0043 std::make_pair("Prompt", SYNCH_PROMPT),
0044 std::make_pair("Pcl", SYNCH_PCL)};
0045 std::string synchronizationTypeNames(SynchronizationType type) { return s_synchronizationTypeArray[type].first; }
0046
0047 SynchronizationType synchronizationTypeFromName(const std::string &name) {
0048 for (auto const &i : s_synchronizationTypeArray)
0049 if (name == i.first)
0050 return i.second;
0051 for (auto const &i : s_obsoleteSynchronizationTypeArray)
0052 if (name == i.first)
0053 return i.second;
0054 throwException("SynchronizationType \"" + name + "\" is unknown.", "synchronizationTypeFromName");
0055 }
0056
0057 }