File indexing completed on 2023-03-17 10:53:55
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #ifndef CSCDQM_Cache_H
0021 #define CSCDQM_Cache_H
0022
0023 #include <map>
0024 #include <boost/multi_index_container.hpp>
0025 #include <boost/multi_index/member.hpp>
0026 #include <boost/multi_index/composite_key.hpp>
0027 #include <boost/multi_index/ordered_index.hpp>
0028 #include "boost/tuple/tuple.hpp"
0029
0030 #include "CSCDQM_Logger.h"
0031 #include "CSCDQM_HistoDef.h"
0032 #include "CSCDQM_MonitorObject.h"
0033 #include "CSCDQM_Utility.h"
0034
0035 namespace cscdqm {
0036
0037
0038 struct CSCHistoKeyType {
0039 HistoId id;
0040 HwId addId;
0041 const MonitorObject* mo;
0042 CSCHistoKeyType(const HistoId& id_, const HwId& addId_, const MonitorObject* mo_)
0043 : id(id_), addId(addId_), mo(mo_) {}
0044 };
0045
0046
0047 typedef boost::multi_index_container<
0048 CSCHistoKeyType,
0049 boost::multi_index::indexed_by<boost::multi_index::ordered_unique<boost::multi_index::composite_key<
0050 CSCHistoKeyType,
0051 boost::multi_index::member<CSCHistoKeyType, HistoId, &CSCHistoKeyType::id>,
0052 boost::multi_index::member<CSCHistoKeyType, HwId, &CSCHistoKeyType::addId> > > > >
0053 CSCHistoMapType;
0054
0055
0056 struct CSCKeyType {
0057 HwId crateId;
0058 HwId dmbId;
0059 CSCHistoMapType mos;
0060 CSCKeyType(const HwId& crateId_, const HwId& dmbId_) : crateId(crateId_), dmbId(dmbId_) {}
0061 };
0062
0063
0064 typedef boost::multi_index_container<
0065 CSCKeyType,
0066 boost::multi_index::indexed_by<boost::multi_index::ordered_unique<
0067 boost::multi_index::composite_key<CSCKeyType,
0068 boost::multi_index::member<CSCKeyType, HwId, &CSCKeyType::crateId>,
0069 boost::multi_index::member<CSCKeyType, HwId, &CSCKeyType::dmbId> > > > >
0070 CSCMapType;
0071
0072
0073 typedef std::map<HwId, MonitorObject**> FEDMapType;
0074
0075
0076 typedef std::map<HwId, MonitorObject**> DDUMapType;
0077
0078
0079 struct LookupKeyType {
0080 HistoDef histo;
0081 std::string path;
0082 MonitorObject* mo;
0083 LookupKeyType(const HistoDef& histo_, MonitorObject*& mo_) : histo(histo_), mo(mo_) { path = histo.getPath(); }
0084 };
0085
0086
0087 typedef boost::multi_index_container<
0088 LookupKeyType,
0089 boost::multi_index::indexed_by<
0090 boost::multi_index::ordered_unique<boost::multi_index::member<LookupKeyType, HistoDef, &LookupKeyType::histo> >,
0091 boost::multi_index::ordered_non_unique<
0092 boost::multi_index::member<LookupKeyType, std::string, &LookupKeyType::path> > > >
0093 LookupMapType;
0094
0095
0096
0097
0098
0099 class Cache {
0100 private:
0101
0102 MonitorObject* data[h::namesSize];
0103
0104
0105 FEDMapType fedData;
0106
0107 FEDMapType::const_iterator fedPointer;
0108
0109 HwId fedPointerValue;
0110
0111
0112 DDUMapType dduData;
0113
0114 DDUMapType::const_iterator dduPointer;
0115
0116 HwId dduPointerValue;
0117
0118
0119 CSCMapType cscData;
0120
0121 CSCMapType::const_iterator cscPointer;
0122
0123
0124 LookupMapType lookupData;
0125
0126 public:
0127
0128 Cache() {
0129
0130 for (unsigned int i = 0; i < h::namesSize; i++)
0131 data[i] = nullptr;
0132
0133
0134 fedPointer = fedData.end();
0135 fedPointerValue = 0;
0136
0137
0138 dduPointer = dduData.end();
0139 dduPointerValue = 0;
0140 cscPointer = cscData.end();
0141 }
0142
0143
0144 ~Cache() {
0145
0146 while (fedData.begin() != fedData.end()) {
0147 if (fedData.begin()->second) {
0148 delete[] fedData.begin()->second;
0149 }
0150 fedData.erase(fedData.begin());
0151 }
0152
0153
0154 while (dduData.begin() != dduData.end()) {
0155 if (dduData.begin()->second) {
0156 delete[] dduData.begin()->second;
0157 }
0158 dduData.erase(dduData.begin());
0159 }
0160 }
0161
0162
0163
0164 const bool get(const HistoDef& histo, MonitorObject*& mo);
0165 const bool getEMU(const HistoId& id, MonitorObject*& mo);
0166 const bool getFED(const HistoId& id, const HwId& fedId, MonitorObject*& mo);
0167 const bool getDDU(const HistoId& id, const HwId& dduId, MonitorObject*& mo);
0168 const bool getCSC(const HistoId& id, const HwId& crateId, const HwId& dmbId, const HwId& addId, MonitorObject*& mo);
0169 const bool getPar(const HistoId& id, MonitorObject*& mo);
0170 void put(const HistoDef& histo, MonitorObject* mo);
0171
0172
0173
0174 const bool nextBookedFED(unsigned int& n, unsigned int& fedId) const;
0175 const bool nextBookedDDU(unsigned int& n, unsigned int& dduId) const;
0176 const bool nextBookedCSC(unsigned int& n, unsigned int& crateId, unsigned int& dmbId) const;
0177 const bool isBookedCSC(const HwId& crateId, const HwId& dmbId) const;
0178 const bool isBookedDDU(const HwId& dduId) const;
0179 const bool isBookedFED(const HwId& fedId) const;
0180 };
0181
0182 }
0183
0184 #endif