1 #include "CaloOnlineTools/HcalOnlineDb/interface/ConfigurationDatabaseImpl.hh" 2 #include "CaloOnlineTools/HcalOnlineDb/interface/ConfigurationDatabase.hh" 3 #include "CaloOnlineTools/HcalOnlineDb/interface/ConfigurationItemNotFoundException.hh" 4 #include "CaloOnlineTools/HcalOnlineDb/interface/PluginManager.hh" 8 #include <toolbox/string.h> 16 m_implementation=
nullptr;
20 if (m_implementationOptions.empty()) {
21 std::vector<hcal::AbstractPluginFactory*> facts;
22 hcal::PluginManager::getFactories(
"hcal::ConfigurationDatabaseImpl",facts);
23 for (std::vector<hcal::AbstractPluginFactory*>::iterator j=facts.begin(); j!=facts.end(); j++)
24 m_implementationOptions.push_back(dynamic_cast<hcal::ConfigurationDatabaseImpl*>((*j)->newInstance()));
27 std::map<std::string,std::string> params;
29 ConfigurationDatabaseImpl::parseAccessor(accessor,method,host,port,user,db,params);
31 if (m_implementation==
nullptr || !m_implementation->canHandleMethod(method)) {
32 m_implementation=
nullptr;
33 std::vector<ConfigurationDatabaseImpl*>::iterator j;
34 for (j=m_implementationOptions.begin(); j!=m_implementationOptions.end(); j++)
35 if ((*j)->canHandleMethod(method)) {
41 if (m_implementation==
nullptr)
42 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,
toolbox::toString(
"Unable to open database using '%s'",accessor.c_str()));
43 m_implementation->setLogger(m_logger);
44 m_implementation->connect(accessor);
48 void ConfigurationDatabase::close() {
49 if (m_implementation!=
nullptr) m_implementation->disconnect();
53 if (m_implementation==
nullptr) {
54 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,
"Database connection not open");
57 return m_implementation->getFirmwareChecksum(board,version);
61 if (m_implementation==
nullptr) {
62 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,
"Database connection not open");
64 return m_implementation->getApplicationConfig(tag,classname,instance);
70 if (m_implementation==
nullptr) {
71 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,
"Database connection not open");
73 return m_implementation->getConfigurationDocument(tag);
76 void ConfigurationDatabase::getFirmwareMCS(
const std::string& board,
unsigned int version, std::vector<std::string>& mcsLines)
noexcept(
false) {
77 if (m_implementation==
nullptr) {
78 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,
"Database connection not open");
81 m_implementation->getFirmwareMCS(board, version, mcsLines);
85 void ConfigurationDatabase::getLUTs(
const std::string& tag,
int crate,
int slot, std::map<LUTId, LUT >& LUTs)
noexcept(
false) {
87 if (m_implementation==
nullptr) {
88 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,
"Database connection not open");
91 std::map<unsigned int, std::string>
results;
93 m_implementation->getLUTs(tag, crate, slot, LUTs);
96 XCEPT_RAISE(hcal::exception::ConfigurationItemNotFoundException,
toolbox::toString(
"Not enough found (%d)",LUTs.size()));
100 void ConfigurationDatabase::getLUTChecksums(
const std::string& tag, std::map<LUTId, MD5Fingerprint>& checksums)
noexcept(
false) {
103 if (m_implementation==
nullptr) {
104 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,
"Database connection not open");
107 m_implementation->getLUTChecksums(tag, checksums);
110 void ConfigurationDatabase::getPatterns(
const std::string& tag,
int crate,
int slot, std::map<PatternId, HTRPattern>& patterns)
noexcept(
false) {
112 if (m_implementation==
nullptr) {
113 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,
"Database connection not open");
116 m_implementation->getPatterns(tag,crate,slot,patterns);
118 if (patterns.empty()) {
119 XCEPT_RAISE(hcal::exception::ConfigurationItemNotFoundException,
toolbox::toString(
"Not found '$s',%d,%d",tag.c_str(),crate,slot));
124 void ConfigurationDatabase::getRBXdata(
const std::string& tag,
127 std::map<RBXdatumId, RBXdatum>& RBXdata)
130 if (m_implementation==
nullptr) {
131 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,
"Database connection not open");
134 m_implementation->getRBXdata(tag,rbx,dtype,RBXdata);
137 void ConfigurationDatabase::getRBXpatterns(
const std::string& tag,
139 std::map<RBXdatumId, RBXpattern>& patterns)
142 if (m_implementation==
nullptr) {
143 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,
"Database connection not open");
146 m_implementation->getRBXpatterns(tag,rbx,patterns);
149 void ConfigurationDatabase::getZSThresholds(
const std::string& tag,
int crate,
int slot, std::map<ZSChannelId, int>&
thresholds)
152 if (m_implementation==
nullptr) {
153 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,
"Database connection not open");
156 m_implementation->getZSThresholds(tag,crate,slot,thresholds);
159 void ConfigurationDatabase::getHLXMasks(
const std::string& tag,
int crate,
int slot, std::map<FPGAId, HLXMasks>&
m)
162 if (m_implementation==
nullptr) {
163 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,
"Database connection not open");
166 m_implementation->getHLXMasks(tag,crate,slot,m);
172 if (crate<a.crate)
return true;
173 if (crate>a.crate)
return false;
174 if (slot<a.slot)
return true;
175 if (slot>a.slot)
return false;
176 if (fpga<a.fpga)
return true;
177 if (fpga>a.fpga)
return false;
181 if (crate<a.crate)
return true;
182 if (crate>a.crate)
return false;
183 if (slot<a.slot)
return true;
184 if (slot>a.slot)
return false;
185 if (fpga<a.fpga)
return true;
186 if (fpga>a.fpga)
return false;
187 if (fiber_slb<a.fiber_slb)
return true;
188 if (fiber_slb>a.fiber_slb)
return false;
189 if (channel<a.channel)
return true;
190 if (channel>a.channel)
return false;
191 if (lut_type<a.lut_type)
return true;
192 if (lut_type>a.lut_type)
return false;
196 if (crate<a.crate)
return true;
197 if (crate>a.crate)
return false;
198 if (slot<a.slot)
return true;
199 if (slot>a.slot)
return false;
200 if (fpga<a.fpga)
return true;
201 if (fpga>a.fpga)
return false;
202 if (fiber<a.fiber)
return true;
203 if (fiber>a.fiber)
return false;
207 if (crate<a.crate)
return true;
208 if (crate>a.crate)
return false;
209 if (slot<a.slot)
return true;
210 if (slot>a.slot)
return false;
211 if (fpga<a.fpga)
return true;
212 if (fpga>a.fpga)
return false;
213 if (fiber<a.fiber)
return true;
214 if (fiber>a.fiber)
return false;
215 if (channel<a.channel)
return true;
216 if (channel>a.channel)
return false;
220 if (
rm<a.rm)
return true;
221 if (
rm>a.rm)
return false;
222 if (card<a.card)
return true;
223 if (card>a.card)
return false;
224 if (qie_or_gol<a.qie_or_gol)
return true;
225 if (qie_or_gol>a.qie_or_gol)
return false;
226 if (dtype<a.dtype)
return true;
227 if (dtype>a.dtype)
return false;
228 if (ltype<a.ltype)
return true;
229 if (ltype>a.ltype)
return false;
static PFTauRenderPlugin instance
bool operator<(const FedChannelConnection &, const FedChannelConnection &)