// $Id: IDbiConfigSet.cxx,v 1.1 2011/01/18 05:49:19 finch Exp $ #include "IDbi.hxx" #include "IDbiConfigSet.hxx" #include "IDbiOutRowStream.hxx" #include "IDbiInRowStream.hxx" #include #include using std::endl; #include ClassImp(COMET::IDbiConfigSet) // Definition of static data members // ********************************* // Instantiate associated Result Pointer and Writer classes. // ******************************************************** #include "IDbiResultSetHandle.tpl" template class COMET::IDbiResultSetHandle; #include "IDbiWriter.tpl" template class COMET::IDbiWriter; // Definition of all member functions (static or otherwise) // ******************************************************* // // - ordered: ctors, dtor, operators then in alphabetical order. //..................................................................... COMET::IDbiConfigSet::~IDbiConfigSet() { // // // Purpose: Destructor for ( vector::iterator itr = fParams.begin(); itr != fParams.end(); ++itr ) delete (*itr); } //..................................................................... ///\verbatim /// /// Purpose: Output configuration set to message stream. /// /// Arguments: /// s in Message stream /// cfSet in Configuration set to be output /// /// Return: Message stream /// /// Contact: N. West /// /// Specification:- /// ============= /// /// o Output configuration set to message stream. ///\endverbatim std::ostream& operator<<(std::ostream& s, const COMET::IDbiConfigSet& cfSet) { // Program Notes:- // ============= // None. s << "COMET::IDbiConfigSet: Number of parameters: " << cfSet.GetNumParams() << endl; for ( UInt_t iParam = 0; iParam < cfSet.GetNumParams(); ++iParam) { s << " " << cfSet.GetParamName(iParam) << ": " << cfSet.GetParamValue(iParam) << " (" << cfSet.GetParamType(iParam).AsString() << ")" << endl; } return s; } //..................................................................... ///\verbatim /// /// Purpose: Fill object from Result Set /// /// Arguments: /// rs in Result Set used to fill object /// vrec in Associated validity record (or 0 if filling /// COMET::IDbiValidityRec) /// /// Return: /// /// Contact: N. West //// /// Specification:- /// ============= /// /// o Fill object from current (and only) row of Result Set. ///\endverbatim void COMET::IDbiConfigSet::Fill(COMET::IDbiInRowStream& rs, const COMET::IDbiValidityRec* vrec) { // Program Notes:- // ============= // None. // Don't count leading SeqNo or ROW_COUNTER, they have already been skipped. UInt_t numParams = rs.NumCols()-2; for (UInt_t iParam = 0; iParam < numParams; ++iParam ) { Param* par = new Param; par->Name = rs.CurColName(); par->Value = rs.CurColValue(); par->Type = rs.CurColFieldType(); fParams.push_back(par); rs.IncrementCurCol(); } fAggregateNo = vrec->GetAggregateNo (); } //..................................................................... ///\verbatim /// /// Purpose: Get the name of selected parameter. /// /// Arguments: /// parNo in parNo (in range 0..GetNumParams()) /// /// Return: The name of selected parameter /// or "" if parNo out of range. /// /// Contact: N. West /// /// Specification:- /// ============= /// /// o Get the name of selected parameter or "" if parNo out of range. ///\endverbatim string COMET::IDbiConfigSet::GetParamName(UInt_t parNo) const { // Program Notes:- // ============= // None. return ( parNo <= GetNumParams() ) ? fParams[parNo]->Name : ""; } //..................................................................... COMET::IDbiFieldType COMET::IDbiConfigSet::GetParamType(UInt_t parNo) const { // // // Purpose: Get the type of selected parameter. // // Arguments: // parNo in parNo (in range 0..GetNumParams()) // // Return: The type of selected parameter // or IDbi::kUnknown if parNo out of range. // // Contact: N. West // // Specification:- // ============= // // o Get the type of selected parameter or IDbi::kUnknown if // parNo out of range. // Program Notes:- // ============= // None. return ( parNo <= GetNumParams() ) ? fParams[parNo]->Type : COMET::IDbiFieldType(IDbi::kUnknown); } //..................................................................... ///\verbatim /// Purpose: Get the value of selected parameter. /// /// Arguments: /// parNo in parNo (in range 0..GetNumParams()) /// /// Return: The value of selected parameter /// or "" if parNo out of range. /// /// Contact: N. West /// /// Specification:- /// ============= /// /// o Get the value of selected parameter or "" if parNo out of range. ///\endverbatim string COMET::IDbiConfigSet::GetParamValue(UInt_t parNo) const { // Program Notes:- // ============= // None. return ( parNo <= GetNumParams() ) ? fParams[parNo]->Value : ""; } //..................................................................... /// Purpose: Add another entry to the end of the existing row. void COMET::IDbiConfigSet::PushBack(const string& name, const string& value, const COMET::IDbiFieldType& type) { // // fParams.push_back(new Param(name,value,type)); } //..................................................................... // ///\verbatim /// Purpose: Stream object to output row stream /// /// Arguments: /// ors in Output row stream. /// vrec in =0. If filling other table rows it points /// to the associated validity record. /// /// Return: /// /// Contact: N. West /// /// Specification:- /// ============= /// /// o Stream object to output row stream. /// /// Program Notes:- /// ============= /// /// This method sneaks round the back of the COMET::IDbiRowStream interface /// and directly uses the private Store method as the data is already /// in string form. Its all in a good cause because this allows /// COMET::IDbiConfigSet to output data from any type of table. ///\endverbatim void COMET::IDbiConfigSet::Store(COMET::IDbiOutRowStream& ors, const COMET::IDbiValidityRec* /* vrec */) const { for ( vector::const_iterator itr = fParams.begin(); itr != fParams.end(); ++itr ) ors.Store((*itr)->Value.c_str()); }