15 base_class(name, pSvcLocator),
18 declareProperty(
"TextFileName",
m_textFileName,
"Text file name for overriding database.");
19 declareProperty(
"PrintParameters",
m_printParameters =
true,
"Print parameters read in from text file.");
20 declareProperty(
"PrintNotUsed",
m_printNotUsed =
true,
"Print parameters not used.");
21 declareProperty(
"Sections",
m_sections,
"Sections considered for logging. Empty list means all.");
32 msg(MSG::INFO) <<
"GeometryDBSvc Initialized" <<
endmsg;
39 msg(MSG::INFO) <<
"Parameters from text file:" <<
endmsg;
43 bool printedUnnamed =
false;
44 for (std::vector<std::string>::const_iterator iter =
m_sections.begin(); iter !=
m_sections.end(); ++iter) {
45 msg(MSG::INFO) <<
"Parameters from text file from section: " << *iter <<
endmsg;
52 msg(MSG::INFO) <<
" Section not present. Parameters from text file from unnamed section already printed above." <<
endmsg;
54 msg(MSG::INFO) <<
" Section not present. Parameters from text file from unnamed section will be printed." <<
endmsg;
56 printedUnnamed =
true;
62 return StatusCode::SUCCESS;
73 msg(MSG::INFO) <<
"The following parameters were not used:" <<
endmsg;
77 bool printedUnnamed =
false;
78 for (std::vector<std::string>::const_iterator iter =
m_sections.begin(); iter !=
m_sections.end(); ++iter) {
79 msg(MSG::INFO) <<
"The following parameters were not used from section: " << *iter <<
endmsg;
86 msg(MSG::INFO) <<
" Section not present. Parameters from text file from unnamed section already printed above." <<
endmsg;
88 msg(MSG::INFO) <<
" Section not present. Parameters from text file from unnamed section will be printed." <<
endmsg;
90 printedUnnamed =
true;
96 return StatusCode::SUCCESS;
103 if (!filename.empty()) {
104 msg(MSG::INFO) <<
"Parameters overriden from text file: " << filename <<
endmsg;
105 msg(MSG::WARNING) <<
"Overriding from a text file is NOT recommended for production use." <<
endmsg;
109 msg(MSG::ERROR) <<
"Problem reading text file: " << filename <<
endmsg;
119 std::ostringstream ostr;
120 if (!recordSetName.empty()) {
121 ostr << recordSetName <<
"#" <<
index <<
":" << name;
133 std::string recordSetName = recordSet->
nodeName();
135 if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) <<
"TEXTFILE: Parameter " <<
parameterKey(recordSetName,name,
index) <<
" from text file: " << tmpPar <<
endmsg;
140 tmpPar = (*recordSet)[
index]->getDouble(name);
141 if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) <<
"Parameter " <<
parameterKey(recordSetName,name,
index) <<
" from database: " << tmpPar <<
endmsg;
152 if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) <<
"TEXTFILE: Parameter " <<
parameterKey(recordSetName,name,
index) <<
" from text file: " << tmpPar <<
endmsg;
163 if (!recordSet.get())
return getInt(
"",name,
index);
165 std::string recordSetName = recordSet->
nodeName();
167 if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) <<
"TEXTFILE: Parameter " <<
parameterKey(recordSetName,name,
index) <<
" from text file: " << tmpPar <<
endmsg;
172 tmpPar = (*recordSet)[
index]->getInt(name);
173 if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) <<
"Parameter " <<
parameterKey(recordSetName,name,
index) <<
" from database: " << tmpPar <<
endmsg;
184 if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) <<
"TEXTFILE: Parameter " <<
parameterKey(recordSetName,name,
index) <<
" from text file: " << tmpPar <<
endmsg;
197 std::string recordSetName = recordSet->
nodeName();
199 if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) <<
"TEXTFILE: Parameter " <<
parameterKey(recordSetName,name,
index) <<
" from text file: " << tmpPar <<
endmsg;
204 tmpPar = (*recordSet)[
index]->getString(name);
205 if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) <<
"Parameter " <<
parameterKey(recordSetName,name,
index) <<
" from database: " << tmpPar <<
endmsg;
216 if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) <<
"TEXTFILE: Parameter " <<
parameterKey(recordSetName,name,
index) <<
" from text file: " << tmpPar <<
endmsg;
229 if (recordSetName.empty() &&
index) {
230 msg(MSG::WARNING) <<
"Non zero index for parameter with empry record set. Index will be ignored: " <<
index <<
endmsg;
236 if (!
result && !recordSetName.empty()) {
237 if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) <<
"Not found. Looking for default entry with #ALL" <<
endmsg;
238 std::ostringstream keyalt;
239 keyalt << recordSetName <<
"#ALL:" << name;
253 std::istringstream istr(
result);
271 std::istringstream istr(
result);
285 std::string recordSetName = recordSet->
nodeName();
292 std::string recordSetName = recordSet->
nodeName();
294 if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) <<
"Parameter " <<
parameterKey(recordSetName,name,
index) <<
" found in text file. " <<
endmsg;
302 catch(std::runtime_error& ex) {
303 if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) <<
"Exception caught: " << ex.what() <<
endmsg;
308 if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) <<
"Parameter " <<
parameterKey(recordSetName,name,
index) <<
" found in database. " <<
endmsg;
310 if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) <<
"Parameter " <<
parameterKey(recordSetName,name,
index) <<
" not found. " <<
endmsg;
327 unsigned int tmpParUnsigned = 0;
328 std::string recordSetName = recordSet->
nodeName();
332 msg(MSG::ERROR) <<
"Table " << recordSetName <<
" size from text file is negative: " << tmpPar <<
endmsg;
335 if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) <<
"TEXTFILE: Table " << recordSetName <<
" size from text file: " << tmpPar <<
endmsg;
337 tmpParUnsigned =
static_cast<unsigned int>(tmpPar);
340 tmpParUnsigned = recordSet->
size();
341 if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) <<
"Table " << recordSetName <<
" size from database: " << tmpParUnsigned <<
endmsg;
343 return tmpParUnsigned;
350 unsigned int tmpParUnsigned = 0;
354 msg(MSG::ERROR) <<
"Table " << recordSetName <<
" size from text file is negative: " << tmpPar <<
endmsg;
357 if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) <<
"TEXTFILE: Table " << recordSetName <<
" size from text file: " << tmpPar <<
endmsg;
359 tmpParUnsigned =
static_cast<unsigned int>(tmpPar);
361 msg(MSG::ERROR) <<
"getTableSize: Table " << recordSetName <<
" does not exist in text file." <<
endmsg;
363 return tmpParUnsigned;
370 if (msgLvl(MSG::VERBOSE))
msg(MSG::VERBOSE) <<
"Looking for TableSize for " << recordSetName <<
endmsg;
374 std::ostringstream key;
375 key <<
"TableSize:" << recordSetName;
378 std::istringstream istr(
result);
381 msg(MSG::ERROR) <<
"Error retrieving parameter TableSize:" << recordSetName <<
" as an int: " <<
result <<
endmsg;
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition of the abstract IRDBRecord interface.
Definition of the abstract IRDBRecordset interface.
virtual StatusCode initialize()
Service init.
virtual bool testField(IRDBRecordset_ptr recordSet, const std::string &name, int index=0) const
virtual StatusCode finalize()
Service finalize.
GeometryDBSvc(const std::string &name, ISvcLocator *sl)
void setParameterFileName(const std::string &filename)
TextFileDBReader * m_textParameters
virtual void printNotUsed(const std::string §ion="") const
Print paramaters from text file which are not used. If section is supplied only consider the paramete...
virtual bool testFieldTxt(IRDBRecordset_ptr recordSet, const std::string &name, int index=0) const
virtual double getDouble(IRDBRecordset_ptr recordSet, const std::string &name, int index=0) const
std::string m_textFileName
bool getTableSizeFromTextFile(const std::string &recordSetName, int &var) const
std::vector< std::string > m_sections
bool getValue(const std::string &recordSetName, const std::string &name, int index, std::string &var) const
virtual int getInt(IRDBRecordset_ptr recordSet, const std::string &name, int index=0) const
virtual std::string getString(IRDBRecordset_ptr recordSet, const std::string &name, int index=0) const
std::string parameterKey(const std::string &recordSetName, const std::string &name, int index) const
virtual unsigned int getTableSize(IRDBRecordset_ptr recordSet) const
virtual void printParameters(const std::string §ion="") const
Print paramaters read in from text file. If section is supplied only consider the parameters in that ...
virtual std::string nodeName() const =0
virtual unsigned int size() const =0
Class to read in a text file and allow easy retrieval of parameters.