ValidateRawChecksums Class Reference
[DataUtil]

A job module that checks checksums. More...

#include <ValidateRawChecksums.h>

Inheritance diagram for ValidateRawChecksums:
JobCModule

List of all members.

Public Member Functions

 ValidateRawChecksums ()
 ~ValidateRawChecksums ()
JobCResult Ana (const MomNavigator *mom)
void Config (const Registry &r)
const RegistryDefaultConfig () const

Private Member Functions

JobCResult FilterRawRecord (const RawRecord *rawrec)

Private Attributes

int fDumpLevel
int fMaxDumps
std::string fRawBlockList

Detailed Description

A job module that checks checksums.

Author:
(last to touch it)
Author
bv
Version:
Revision
1.2
Date:
Date
2005/04/15 14:50:02

Contact: rhatcher

Created on: 2003/02/06 23:22:43

Id
ValidateRawChecksums.h,v 1.2 2005/04/15 14:50:02 bv Exp

Definition at line 34 of file ValidateRawChecksums.h.


Constructor & Destructor Documentation

ValidateRawChecksums::ValidateRawChecksums (  ) 

Definition at line 19 of file ValidateRawChecksums.cxx.

00020   : fDumpLevel(1)
00021   , fMaxDumps(-1)
00022   , fRawBlockList("")
00023 {}

ValidateRawChecksums::~ValidateRawChecksums (  ) 

Definition at line 27 of file ValidateRawChecksums.cxx.

00027 {}


Member Function Documentation

JobCResult ValidateRawChecksums::Ana ( const MomNavigator mom  )  [virtual]

Implement this for read only access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 31 of file ValidateRawChecksums.cxx.

References JobCResult::Failed(), FilterRawRecord(), JobCResult::kPassed, and JobCResult::SetFailed().

00032 {
00033    JobCResult result = JobCResult::kPassed;
00034 
00035    // Get any and all raw records attached to the data record pointed 
00036    // to by "mom".  The dynamic cast from TObject is ugly but necessary
00037    TObject   *tobj   = 0;
00038    TIter reciter = const_cast<MomNavigator*>(mom)->FragmentIter();
00039    while ( (tobj = reciter() ) ) {
00040       RawRecord *rawrec = dynamic_cast<RawRecord *>(tobj);
00041       JobCResult one_res = FilterRawRecord(rawrec);
00042       if (one_res.Failed()) result.SetFailed();
00043    }
00044 
00045    return result;
00046 }

void ValidateRawChecksums::Config ( const Registry r  )  [virtual]

Return the actual configuration. If your module directly pulls its configuration from the fConfig Registry, you don't need to override this. Override if you have local config variables.

Reimplemented from JobCModule.

Definition at line 72 of file ValidateRawChecksums.cxx.

References fDumpLevel, fMaxDumps, fRawBlockList, and Registry::Get().

00073 {
00074 //======================================================================
00075 // Configure the module using the registry r
00076 //======================================================================
00077   int  tmpi;
00078   const char* tmpcs = 0;
00079 
00080   if (r.Get("DumpLevel",tmpi))        fDumpLevel    = tmpi;
00081   if (r.Get("MaxDumps", tmpi))        fMaxDumps     = tmpi;
00082   if (r.Get("RawBlockList",tmpcs))    fRawBlockList = tmpcs;
00083 
00084 }

const Registry & ValidateRawChecksums::DefaultConfig ( void   )  const [virtual]

Get the default configuration registry. This should normally be overridden. One useful idiom is to implement it like:

const Registry& MyModule::DefaultConfig() const { static Registry cfg; // never is destroyed if (cfg.Size()) return cfg; // already filled it // set defaults: cfg.Set("TheAnswer",42); cfg.Set("Units","unknown"); return cfg; }

Reimplemented from JobCModule.

Definition at line 50 of file ValidateRawChecksums.cxx.

References JobCModule::GetName(), Registry::LockValues(), Registry::Set(), and Registry::UnLockValues().

00051 {
00052 //======================================================================
00053 // The default configuration for this module
00054 //======================================================================
00055   static Registry r;
00056   
00057   std::string name = this->GetName();
00058   name += ".config.default";
00059   r.SetName(name.c_str());
00060   
00061   r.UnLockValues();
00062   r.Set("DumpLevel",        1);
00063   r.Set("MaxDumps",        -1);   // no limit
00064   r.Set("RawBlockList",     "");
00065   r.LockValues();
00066 
00067   return r;
00068 }

JobCResult ValidateRawChecksums::FilterRawRecord ( const RawRecord rawrec  )  [private]

Definition at line 88 of file ValidateRawChecksums.cxx.

References blkname, fDumpLevel, fMaxDumps, RawDataBlock::FormatToOStream(), fRawBlockList, RawRecord::GetRawBlockIter(), JobCResult::kFailed, Msg::kInfo, JobCResult::kPassed, MSG, and RawDataBlock::TestChecksum().

Referenced by Ana().

00089 {
00090 //======================================================================
00091 // For this raw record object check if all th
00092 //======================================================================
00093    JobCResult result = JobCResult::kPassed;
00094 
00095    bool checklist = (fRawBlockList != "");
00096 
00097    TIter itr = rawrec->GetRawBlockIter();
00098    RawDataBlock* rdb = 0;
00099    // the dynamic cast from TObject is ugly but necessary
00100    // Careful! the itr() advances the iterator as a side effect!
00101    while (( rdb = dynamic_cast<RawDataBlock*>(itr()))) {
00102      bool testit = true;
00103      if (checklist) {
00104        std::string blkname = rdb->GetName();
00105        if (fRawBlockList.find(blkname) == string::npos) testit = false;
00106      }
00107      if (testit) {
00108        bool mismatch = rdb->TestChecksum();
00109        if (mismatch) {
00110          result = JobCResult::kFailed; // set final result for record
00111          if ( fDumpLevel > 0 && fMaxDumps != 0 ) {
00112            MSG("Validate",Msg::kInfo)
00113              << "RawRecord contained raw block \""
00114              << rdb->GetName() 
00115              << "\" which failed checksum test." << endl;
00116            --fMaxDumps;
00117            switch (fDumpLevel) {
00118            case 3:  rdb->FormatToOStream(cout,"x"); break; 
00119            case 2:  rdb->FormatToOStream(cout,"");  break; 
00120            default:
00121              // no additional info printed
00122              break;
00123            }
00124          }
00125        }
00126      }
00127    }
00128 
00129   return result;
00130 }


Member Data Documentation

Definition at line 49 of file ValidateRawChecksums.h.

Referenced by Config(), and FilterRawRecord().

Definition at line 50 of file ValidateRawChecksums.h.

Referenced by Config(), and FilterRawRecord().

std::string ValidateRawChecksums::fRawBlockList [private]

Definition at line 51 of file ValidateRawChecksums.h.

Referenced by Config(), and FilterRawRecord().


The documentation for this class was generated from the following files:

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1