test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCDQM_Cache.h
Go to the documentation of this file.
1 /*
2  * =====================================================================================
3  *
4  * Filename: CSCDQM_Cache.h
5  *
6  * Description: Efficiently manages lists of MonitorObject's for internal
7  * MO cache.
8  *
9  * Version: 1.0
10  * Created: 11/27/2008 10:05:00 AM
11  * Revision: none
12  * Compiler: gcc
13  *
14  * Author: Valdas Rapsevicius (VR), valdas.rapsevicius@cern.ch
15  * Company: CERN, CH
16  *
17  * =====================================================================================
18  */
19 
20 #ifndef CSCDQM_Cache_H
21 #define CSCDQM_Cache_H
22 
23 #include <map>
24 #include <boost/multi_index_container.hpp>
25 #include <boost/multi_index/member.hpp>
26 #include <boost/multi_index/composite_key.hpp>
27 #include <boost/multi_index/ordered_index.hpp>
28 #include "boost/tuple/tuple.hpp"
29 
30 #include <boost/shared_ptr.hpp>
31 
32 #include "CSCDQM_Logger.h"
33 #include "CSCDQM_HistoDef.h"
34 #include "CSCDQM_MonitorObject.h"
35 #include "CSCDQM_Utility.h"
36 
37 namespace cscdqm {
38 
40  struct CSCHistoKeyType {
43  const MonitorObject* mo;
44  CSCHistoKeyType(const HistoId& id_, const HwId& addId_, const MonitorObject* mo_) : id(id_), addId(addId_), mo(mo_) { }
45  };
46 
48  typedef boost::multi_index_container<
49  CSCHistoKeyType,
50  boost::multi_index::indexed_by<
51  boost::multi_index::ordered_unique<
52  boost::multi_index::composite_key<
53  CSCHistoKeyType,
54  boost::multi_index::member<CSCHistoKeyType, HistoId, &CSCHistoKeyType::id>,
55  boost::multi_index::member<CSCHistoKeyType, HwId, &CSCHistoKeyType::addId>
56  >
57  >
58  >
60 
62  struct CSCKeyType {
66  CSCKeyType(const HwId& crateId_, const HwId& dmbId_) : crateId(crateId_), dmbId(dmbId_) { }
67  };
68 
70  typedef boost::multi_index_container<
71  CSCKeyType,
72  boost::multi_index::indexed_by<
73  boost::multi_index::ordered_unique<
74  boost::multi_index::composite_key<
75  CSCKeyType,
76  boost::multi_index::member<CSCKeyType, HwId, &CSCKeyType::crateId>,
77  boost::multi_index::member<CSCKeyType, HwId, &CSCKeyType::dmbId>
78  >
79  >
80  >
82 
84  typedef std::map<HwId, MonitorObject**> FEDMapType;
85 
87  typedef std::map<HwId, MonitorObject**> DDUMapType;
88 
90  struct LookupKeyType {
94  LookupKeyType(const HistoDef& histo_, MonitorObject*& mo_) : histo(histo_), mo(mo_) {
95  path = histo.getPath();
96  }
97  };
98 
100  typedef boost::multi_index_container<
101  LookupKeyType,
102  boost::multi_index::indexed_by<
103  boost::multi_index::ordered_unique<boost::multi_index::member<LookupKeyType, HistoDef, &LookupKeyType::histo> >,
104  boost::multi_index::ordered_non_unique<boost::multi_index::member<LookupKeyType, std::string, &LookupKeyType::path> >
105  >
107 
112  class Cache {
113 
114  private:
115 
118 
122  FEDMapType::const_iterator fedPointer;
125 
126 
130  DDUMapType::const_iterator dduPointer;
133 
137  CSCMapType::const_iterator cscPointer;
138 
141 
142  public:
143 
145  Cache() {
146 
148  for (unsigned int i = 0; i < h::namesSize; i++) data[i] = 0;
149 
151  fedPointer = fedData.end();
152  fedPointerValue = 0;
153 
155  dduPointer = dduData.end();
156  dduPointerValue = 0;
157  cscPointer = cscData.end();
158  }
159 
161  ~Cache() {
163  while (fedData.begin() != fedData.end()) {
164  if (fedData.begin()->second) {
165  delete [] fedData.begin()->second;
166  }
167  fedData.erase(fedData.begin());
168  }
169 
171  while (dduData.begin() != dduData.end()) {
172  if (dduData.begin()->second) {
173  delete [] dduData.begin()->second;
174  }
175  dduData.erase(dduData.begin());
176  }
177  }
178 
181  const bool get(const HistoDef& histo, MonitorObject*& mo);
182  const bool getEMU(const HistoId& id, MonitorObject*& mo);
183  const bool getFED(const HistoId& id, const HwId& fedId, MonitorObject*& mo);
184  const bool getDDU(const HistoId& id, const HwId& dduId, MonitorObject*& mo);
185  const bool getCSC(const HistoId& id, const HwId& crateId, const HwId& dmbId, const HwId& addId, MonitorObject*& mo);
186  const bool getPar(const HistoId& id, MonitorObject*& mo);
187  void put(const HistoDef& histo, MonitorObject* mo);
188 
191  const bool nextBookedFED(unsigned int& n, unsigned int& fedId) const;
192  const bool nextBookedDDU(unsigned int& n, unsigned int& dduId) const;
193  const bool nextBookedCSC(unsigned int& n, unsigned int& crateId, unsigned int& dmbId) const;
194  const bool isBookedCSC(const HwId& crateId, const HwId& dmbId) const;
195  const bool isBookedDDU(const HwId& dduId) const;
196  const bool isBookedFED(const HwId& fedId) const;
197 
198  };
199 
200 }
201 
202 #endif
const bool getFED(const HistoId &id, const HwId &fedId, MonitorObject *&mo)
Get FED MO on Histogram Id and FED Id.
Definition: CSCDQM_Cache.cc:71
int i
Definition: DBlmapReader.cc:9
unsigned int HwId
const bool isBookedDDU(const HwId &dduId) const
Check if DDU was booked on given identifier.
DDUMapType dduData
Definition: CSCDQM_Cache.h:128
const bool getEMU(const HistoId &id, MonitorObject *&mo)
Get EMU MO on Histogram Id.
Definition: CSCDQM_Cache.cc:56
LookupKeyType(const HistoDef &histo_, MonitorObject *&mo_)
Definition: CSCDQM_Cache.h:94
CSCHistoKeyType(const HistoId &id_, const HwId &addId_, const MonitorObject *mo_)
Definition: CSCDQM_Cache.h:44
const bool nextBookedCSC(unsigned int &n, unsigned int &crateId, unsigned int &dmbId) const
Iterator to get booked CSC identifiers on enumerator.
Monitoring Object interface used to cover Root object and provide common interface to EventProcessor ...
Abstract Base Histogram Definition.
CSCKeyType(const HwId &crateId_, const HwId &dmbId_)
Definition: CSCDQM_Cache.h:66
MonitorObject * data[h::namesSize]
Definition: CSCDQM_Cache.h:117
const bool nextBookedDDU(unsigned int &n, unsigned int &dduId) const
Iterator to get booked DDU identifier on enumerator.
std::map< HwId, MonitorObject ** > DDUMapType
Definition: CSCDQM_Cache.h:87
static const unsigned int namesSize
unsigned int HistoId
const bool getPar(const HistoId &id, MonitorObject *&mo)
Get Parameter MO on Histogram Id.
const bool nextBookedFED(unsigned int &n, unsigned int &fedId) const
Iterator to get booked FED identifier on enumerator.
HwId dduPointerValue
Definition: CSCDQM_Cache.h:132
MonitorObject * mo
Definition: CSCDQM_Cache.h:93
MonitorObject cache - list objects and routines to manage cache.
Definition: CSCDQM_Cache.h:112
DDUMapType::const_iterator dduPointer
Definition: CSCDQM_Cache.h:130
CSCMapType::const_iterator cscPointer
Definition: CSCDQM_Cache.h:137
MO Lookup List object definition.
Definition: CSCDQM_Cache.h:90
Chamber List object definition.
Definition: CSCDQM_Cache.h:62
FEDMapType::const_iterator fedPointer
Definition: CSCDQM_Cache.h:122
virtual const std::string getPath() const
Get path part of the histogram (used only for DDUs and CSCs)
FEDMapType fedData
Definition: CSCDQM_Cache.h:120
boost::multi_index_container< CSCHistoKeyType, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::composite_key< CSCHistoKeyType, boost::multi_index::member< CSCHistoKeyType, HistoId,&CSCHistoKeyType::id >, boost::multi_index::member< CSCHistoKeyType, HwId,&CSCHistoKeyType::addId > > > > > CSCHistoMapType
Definition: CSCDQM_Cache.h:59
const bool getDDU(const HistoId &id, const HwId &dduId, MonitorObject *&mo)
Get DDU MO on Histogram Id and DDU Id.
void put(const HistoDef &histo, MonitorObject *mo)
Put Monitoring Object into cache.
Chamber MO List object definition.
Definition: CSCDQM_Cache.h:40
const bool isBookedCSC(const HwId &crateId, const HwId &dmbId) const
Check if CSC was booked on given identifiers.
CSCMapType cscData
Definition: CSCDQM_Cache.h:135
std::map< HwId, MonitorObject ** > FEDMapType
Definition: CSCDQM_Cache.h:84
boost::multi_index_container< LookupKeyType, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::member< LookupKeyType, HistoDef,&LookupKeyType::histo > >, boost::multi_index::ordered_non_unique< boost::multi_index::member< LookupKeyType, std::string,&LookupKeyType::path > > > > LookupMapType
Definition: CSCDQM_Cache.h:106
const bool getCSC(const HistoId &id, const HwId &crateId, const HwId &dmbId, const HwId &addId, MonitorObject *&mo)
Get CSC MO on Histogram Id and CSC Crate and DMB Ids.
const MonitorObject * mo
Definition: CSCDQM_Cache.h:43
const bool isBookedFED(const HwId &fedId) const
Check if FED was booked on given identifier.
boost::multi_index_container< CSCKeyType, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::composite_key< CSCKeyType, boost::multi_index::member< CSCKeyType, HwId,&CSCKeyType::crateId >, boost::multi_index::member< CSCKeyType, HwId,&CSCKeyType::dmbId > > > > > CSCMapType
Definition: CSCDQM_Cache.h:81
CSCHistoMapType mos
Definition: CSCDQM_Cache.h:65
LookupMapType lookupData
Definition: CSCDQM_Cache.h:140
HwId fedPointerValue
Definition: CSCDQM_Cache.h:124