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>
19 void ConfigurationDatabase::open(
const std::string& accessor)
throw (hcal::exception::ConfigurationDatabaseException) {
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==0 || !m_implementation->canHandleMethod(method)) {
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==0)
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!=0) m_implementation->disconnect();
52 unsigned int ConfigurationDatabase::getFirmwareChecksum(
const std::string& board,
unsigned int version)
throw (hcal::exception::ConfigurationDatabaseException) {
53 if (m_implementation==0) {
54 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,
"Database connection not open");
57 return m_implementation->getFirmwareChecksum(board,version);
60 ConfigurationDatabase::ApplicationConfig ConfigurationDatabase::getApplicationConfig(
const std::string&
tag,
const std::string&
classname,
int instance)
throw (hcal::exception::ConfigurationDatabaseException) {
61 if (m_implementation==0) {
62 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,
"Database connection not open");
64 return m_implementation->getApplicationConfig(tag,classname,instance);
69 std::string ConfigurationDatabase::getConfigurationDocument(
const std::string& tag)
throw (hcal::exception::ConfigurationDatabaseException) {
70 if (m_implementation==0) {
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)
throw (hcal::exception::ConfigurationDatabaseException) {
77 if (m_implementation==0) {
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)
throw (hcal::exception::ConfigurationDatabaseException) {
87 if (m_implementation==0) {
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)
throw (hcal::exception::ConfigurationDatabaseException) {
103 if (m_implementation==0) {
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)
throw (hcal::exception::ConfigurationDatabaseException) {
112 if (m_implementation==0) {
113 XCEPT_RAISE(hcal::exception::ConfigurationDatabaseException,
"Database connection not open");
116 m_implementation->getPatterns(tag,crate,slot,patterns);
118 if (patterns.size()==0) {
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)
128 throw (hcal::exception::ConfigurationDatabaseException) {
130 if (m_implementation==0) {
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)
140 throw (hcal::exception::ConfigurationDatabaseException) {
142 if (m_implementation==0) {
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)
150 throw (hcal::exception::ConfigurationDatabaseException) {
152 if (m_implementation==0) {
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)
160 throw (hcal::exception::ConfigurationDatabaseException) {
162 if (m_implementation==0) {
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;
if (crate>a.crate)
return false;
173 if (slot<a.slot)
return true;
if (slot>a.slot)
return false;
174 if (fpga<a.fpga)
return true;
if (fpga>a.fpga)
return false;
178 if (crate<a.crate)
return true;
if (crate>a.crate)
return false;
179 if (slot<a.slot)
return true;
if (slot>a.slot)
return false;
180 if (fpga<a.fpga)
return true;
if (fpga>a.fpga)
return false;
181 if (fiber_slb<a.fiber_slb)
return true;
if (fiber_slb>a.fiber_slb)
return false;
182 if (channel<a.channel)
return true;
if (channel>a.channel)
return false;
183 if (lut_type<a.lut_type)
return true;
if (lut_type>a.lut_type)
return false;
187 if (crate<a.crate)
return true;
if (crate>a.crate)
return false;
188 if (slot<a.slot)
return true;
if (slot>a.slot)
return false;
189 if (fpga<a.fpga)
return true;
if (fpga>a.fpga)
return false;
190 if (fiber<a.fiber)
return true;
if (fiber>a.fiber)
return false;
194 if (crate<a.crate)
return true;
if (crate>a.crate)
return false;
195 if (slot<a.slot)
return true;
if (slot>a.slot)
return false;
196 if (fpga<a.fpga)
return true;
if (fpga>a.fpga)
return false;
197 if (fiber<a.fiber)
return true;
if (fiber>a.fiber)
return false;
198 if (channel<a.channel)
return true;
if (channel>a.channel)
return false;
202 if (
rm<a.rm)
return true;
if (
rm>a.rm)
return false;
203 if (card<a.card)
return true;
if (card>a.card)
return false;
204 if (qie_or_gol<a.qie_or_gol)
return true;
if (qie_or_gol>a.qie_or_gol)
return false;
205 if (dtype<a.dtype)
return true;
if (dtype>a.dtype)
return false;
206 if (ltype<a.ltype)
return true;
if (ltype>a.ltype)
return false;
static PFTauRenderPlugin instance
bool operator<(const FedChannelConnection &, const FedChannelConnection &)