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

BadHardware.cxx

Go to the documentation of this file.
00001 
00002 // $Id: BadHardware.cxx,v 1.2 2005/03/03 15:41:47 tagg Exp $
00003 //
00004 // BadHardware
00005 //
00006 // Package: Dbi (Database Interface).
00007 
00008 // Begin_Html<img src="../../pedestrians.gif" align=center>
00009 // <a href="../source_warning.html">Warning for beginners</a>.<br>
00010 // Also see <a href="../../root_crib/index.html">The ROOT Crib</a> and
00011 // <a href="../index.html">The MINOS Class User Guide</a>End_Html
00012 //
00013 //rjn@hep.ucl.ac.uk
00015 #include "Morgue/BadHardware.h"
00016 #include "MessageService/MsgService.h"
00017 #include "DatabaseInterface/DbiOutRowStream.h"
00018 #include "DatabaseInterface/DbiResultSet.h"
00019 #include "DatabaseInterface/DbiValidityRec.h"
00020 #include <iostream>
00021 
00022 ClassImp(BadHardware)
00023 
00024 //   Definition of static data members
00025 //   *********************************
00026 
00027 CVSID("$Id: BadHardware.cxx,v 1.2 2005/03/03 15:41:47 tagg Exp $\n  \
00028       CVSID_DBIRESULTPTR ");
00029 
00030 //  Instantiate associated Result Pointer class.
00031 //  *******************************************
00032 
00033 #include "DatabaseInterface/DbiResultPtr.tpl"
00034 template class  DbiResultPtr<BadHardware>;
00035 
00036 #include "DatabaseInterface/DbiWriter.tpl"
00037 template class  DbiWriter<BadHardware>;
00038 
00039 // Definition of member functions (alphabetical order)
00040 // ***************************************************
00041 
00042 BadHardware::BadHardware( const string& type,
00043                           Int_t         id,
00044                           const VldTimeStamp&  start,
00045                           const VldTimeStamp&  stop,
00046                           Int_t         badness,
00047                           const string& reason ) :
00048   fThingType(HardwareType::FromString(type)),
00049   fThingId(id),
00050   fStart(start.GetSec()),
00051   fStop(stop.GetSec()),
00052   fBadness(badness),
00053   fReason(reason)
00054 { 
00055   LEA_CTOR;
00056 }
00057 
00058 BadHardware::BadHardware( HardwareComponent component,
00059                           const VldTimeStamp&  start,
00060                           const VldTimeStamp&  stop,
00061                           Int_t         badness,
00062                           const string& reason) :
00063   fThingType(component.GetType()),
00064   fThingId(component.GetId()),
00065   fStart(start.GetSec()),
00066   fStop(stop.GetSec()),
00067   fBadness(badness),
00068   fReason(reason)
00069 {
00070   LEA_CTOR;
00071 }
00072 
00073 
00074 
00075 //.....................................................................
00076 
00077 void BadHardware::Fill(DbiResultSet& rs, 
00078                               const DbiValidityRec* /* vrec */) {
00079 
00080 
00081 //
00082 //  Purpose:  Fill object from Result Set
00083 //
00084 //  Arguments: 
00085 //    rs           in    Result Set used to fill object
00086 //    vrec         in    Associated validity record (or 0 if filling
00087 //                                                    DbiValidityRec)
00088 //  Return:    
00089 //
00090 //  Contact:   N. West
00091 //
00092 //  Specification:-
00093 //  =============
00094 //
00095 //  o Fill object from current row of Result Set.
00096 
00097 //  Program Notes:-
00098 //  =============
00099 
00100 //  This method demonstrates both the "dumb" fill method (just
00101 //  load the data as it comes) and the smart method (check column
00102 //  name and load according to column order). 
00103 
00104    if ( rs.TableName() == "BADHARDWARE" ) {
00105       // Dumb method.
00106      rs >> fThingType >> fThingId >> fStart >> fStop >> fBadness >> fReason;
00107    }
00108    else {
00109       
00110       // Smart method
00111       Int_t numCol = rs.NumCols();
00112       //  The first column (SeqNo) has already been processed.
00113       for (Int_t curCol = 2; curCol <= numCol; ++curCol) {
00114          string colName = rs.CurColName();
00115          if ( colName == "TYPE" )       rs >> fThingType;
00116          else if ( colName == "ID" )    rs >> fThingId;
00117          else if ( colName == "START" )   rs >> fStart;
00118          else if ( colName == "STOP" )    rs >> fStop;
00119          else if ( colName == "BADNESS" ) rs >> fBadness;
00120          else if ( colName == "REASON" )  rs >> fReason;
00121          else {
00122             MSG("Dbi",Msg::kDebug) << "Ignoring column " << curCol 
00123                                    << "(" << colName << ")"
00124                                    << "; not part of BadHardware" 
00125                                    << endl;
00126          rs.IncrementCurCol();
00127          }
00128       }
00129    }
00130    
00131    
00132 }
00133 
00134 
00135 //.....................................................................
00136 void BadHardware::Store(DbiOutRowStream& ors,
00137                        const DbiValidityRec* /* vrec */) const {
00138    //
00139 //
00140 //  Purpose:  Stream object to output row stream
00141 //
00142 //  Arguments: 
00143 //    ors          in     Output row stream.
00144 //    vrec         in    Associated validity record (or 0 if filling
00145 //                                                    DbiValidityRec)
00146 //
00147 //  Return:    
00148 //
00149 //  Contact:   N. West
00150 //
00151 //  Specification:-
00152 //  =============
00153 //
00154 //  o  Stream object to output row stream.
00155 
00156 //  Program Notes:-
00157 //  =============
00158 
00159 //  None.
00160 
00161   ors  << fThingType << fThingId << fStart << fStop << fBadness << fReason;
00162 }
00163 
00164 //.....................................................................
00165 
00166 
00167 void BadHardware::Print(Option_t* ) const
00168 {
00169   std::cout << "BadHardware: " << GetComponent().AsString()
00170             << "  " << GetStart().AsString("s") 
00171             << " to " << GetStop().AsString("s")
00172             << "  " << GetBadness() << "  " << fReason << endl;
00173 }
00174 
00175 
00176 
00177 
00178 
00179 
00180 
00181 
00182 
00183 
00184 
00185 
00186 
00187 
00188 
00189 
00190 
00191 
00192 
00193 
00194 
00195 
00196 

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