Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

DbiValRecSet.cxx

Go to the documentation of this file.
00001 // $Id: DbiValRecSet.cxx,v 1.5 2006/08/08 10:51:32 west Exp $
00002 
00003 #include "DatabaseInterface/DbiDBProxy.h"
00004 #include "DatabaseInterface/DbiResultNonAgg.h"
00005 #include "DatabaseInterface/DbiResultSet.h"
00006 #include "DatabaseInterface/DbiTableProxy.h"
00007 #include "DatabaseInterface/DbiTableProxyRegistry.h"
00008 #include "DatabaseInterface/DbiValidityRec.h"
00009 #include "DatabaseInterface/DbiValRecSet.h"
00010 #include "LeakChecker/Lea.h"
00011 #include "MessageService/MsgService.h"
00012 
00013 ClassImp(DbiValRecSet)
00014 
00015 
00016 //   Definition of static data members
00017 //   *********************************
00018 
00019 CVSID("$Id: DbiValRecSet.cxx,v 1.5 2006/08/08 10:51:32 west Exp $");
00020 
00021 //    Definition of all member functions (static or otherwise)
00022 //    *******************************************************
00023 //
00024 //    -  ordered: ctors, dtor, operators then in alphabetical order.
00025 
00026 //.....................................................................
00027 
00028 DbiValRecSet::DbiValRecSet(const string& tableName,UInt_t dbNo,UInt_t seqNo) :
00029 fDbNo(dbNo),
00030 fResult(0)
00031 {
00032 //
00033 //
00034 //  Purpose:  Constructor
00035 //
00036 //  Arguments:
00037 //    tableName    in    Table Name whose DbiValidityRecs are required.
00038 //    dbNo         in    Database number in the cascade.
00039 //    seqNo        in    Just this SEQNO if >0 or all if 0 [default: 0]
00040 //
00041 //  Return:    n/a
00042 //
00043 //  Contact:   N. West
00044 //
00045 //  Specification:-
00046 //  =============
00047 //
00048 //  o  For the required table in the required database, load every
00049 //     DbiValidityRec into DbiResult.
00050 
00051 
00052 //  Program Notes:-
00053 //  =============
00054 
00055 //  None.
00056 
00057   LEA_CTOR    //Leak Checker
00058 
00059   MSG("Dbi", Msg::kVerbose) << "Creating DbiValRecSet" << endl;
00060 
00061 // Get Db proxy for the table.
00062   DbiValidityRec pet;
00063   const DbiDBProxy& proxy = DbiTableProxyRegistry::Instance()
00064                            .GetTableProxy(tableName,&pet)
00065                            .GetDBProxy(); 
00066 
00067 // Collect up all validity records.
00068   DbiResultSet* rset = proxy.QueryAllValidities(dbNo,seqNo);
00069   fResult = new DbiResultNonAgg(rset,&pet,0,kFALSE);
00070   delete rset;
00071 
00072  
00073 }
00074 
00075 
00076 //.....................................................................
00077 
00078 DbiValRecSet::~DbiValRecSet() {
00079 //
00080 //
00081 //  Purpose: Destructor
00082 //
00083 //  Arguments: 
00084 //    None.
00085 //
00086 //  Return:    n/a
00087 //
00088 //  Contact:   N. West
00089 //
00090 //  Specification:-
00091 //  =============
00092 //
00093 //  o  Destroy RowStream.
00094 
00095 
00096 //  Program Notes:-
00097 //  =============
00098 
00099 //  None.
00100 
00101   LEA_DTOR    //Leak Checker
00102 
00103   MSG("Dbi", Msg::kVerbose) << "Destroying DbiValRecSet" << endl;
00104   delete fResult;
00105 
00106 }
00107 
00108 //.....................................................................
00109 
00110 UInt_t DbiValRecSet::GetNumRows() const {
00111 //
00112 //
00113 //  Purpose:  Return the number of rows.
00114 //
00115 //  Arguments: None.
00116 //
00117 //  Return:    
00118 //
00119 //  Contact:   N. West
00120 //
00121 //  Specification:-
00122 //  =============
00123 //
00124 //  o Return the number of rows.
00125 
00126 //  Program Notes:-
00127 //  =============
00128 
00129 //  None.
00130 
00131   return fResult ? fResult->GetNumRows() : 0;
00132 }
00133 
00134 //.....................................................................
00135 
00136 const string DbiValRecSet::GetTableName() const {
00137 //
00138 //
00139 //  Purpose:  Return the table name.
00140 //
00141 //  Arguments: None.
00142 //
00143 //  Return:    
00144 //
00145 //  Contact:   N. West
00146 //
00147 //  Specification:-
00148 //  =============
00149 //
00150 //  o Return the table name.
00151 
00152 //  Program Notes:-
00153 //  =============
00154 
00155 //  None.
00156 
00157   return fResult ? fResult->TableName() : "Unknown";
00158 }
00159 
00160 //.....................................................................
00161 
00162 const DbiValidityRec* DbiValRecSet::GetTableRow(UInt_t rowNum) const {
00163 //
00164 //
00165 //  Purpose:  Return DbiValidityRec at supplied row number.
00166 //
00167 //  Arguments: 
00168 //    rowNum      in    Row number whose entry is required or 0 if none.
00169 //
00170 //  Return:    
00171 //
00172 //  Contact:   N. West
00173 //
00174 //  Specification:-
00175 //  =============
00176 //
00177 //  o Return DbiValidityRec at supplied row number.
00178 
00179 //  Program Notes:-
00180 //  =============
00181 
00182 //  None.
00183 
00184     return fResult ?
00185       dynamic_cast<const DbiValidityRec*>(fResult->GetTableRow(rowNum))
00186     : 0;
00187 }
00188 
00189 //.....................................................................
00190 
00191 const DbiValidityRec* DbiValRecSet::GetTableRowBySeqNo(UInt_t seqNo
00192                                                                ) const {
00193 //
00194 //
00195 //  Purpose:  Return DbiValidityRec having supplied SeqNo.
00196 //
00197 //  Arguments: 
00198 //    seqNo        in    Sequence number of required entry or 0 if none.
00199 //
00200 //  Return:    
00201 //
00202 //  Contact:   N. West
00203 //
00204 //  Specification:-
00205 //  =============
00206 //
00207 //  o Return DbiValidityRec at supplied row number.
00208 
00209 //  Program Notes:-
00210 //  =============
00211 
00212 //  None.
00213 
00214   UInt_t numRows = GetNumRows();
00215   if ( numRows == 0 ) return 0;
00216 
00217 // Create look-up table if not yet built.
00218 
00219   if ( fSeqNoToRec.size() == 0 ) {
00220     for ( UInt_t irow = 0; irow < numRows; ++irow) {
00221       const DbiValidityRec* vrec = GetTableRow(irow);
00222       fSeqNoToRec[vrec->GetSeqNo()] = vrec;
00223     }
00224   }
00225 
00226   map<UInt_t,const DbiValidityRec*>::const_iterator itr = fSeqNoToRec.find(seqNo);
00227   return ( itr == fSeqNoToRec.end() ) ? 0 : itr->second;
00228 
00229 }
00230 

Generated on Mon Feb 15 11:06:35 2010 for loon by  doxygen 1.3.9.1