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

JobCResult.h

Go to the documentation of this file.
00001 
00002 // $Id: JobCResult.h,v 1.3 2003/02/12 02:16:40 kasahara Exp $
00003 //
00004 // A class for encapsulating the result of running a job module on a
00005 // given data record
00006 //
00007 // messier@huhepl.harvard.edu
00009 #ifndef JOBCRESULT_H
00010 #define JOBCRESULT_H
00011 #ifndef IOSFWD
00012 #include <iosfwd>
00013 #define IOSFWD
00014 #endif
00015 
00016 class JobCResult
00017 {
00018   friend std::ostream& operator<<(std::ostream& os, const JobCResult& r);
00019 public:
00020   //====================================================================
00021   // Define the set of possible results of running a job module
00022   
00023   // Use these flags if something has gone wrong while processing the event
00024   typedef enum EErrorFlag {
00025     kAOK     =0, // No problem -- everything is fine
00026     kWarning =1, // Something might be wrong. Keep running (by default).
00027     kError   =2, // Hey! That's not supposed to happen. Stop run.
00028     kFatal   =3  // My world is upside down!. Dump core.
00029   } Error_t;
00030 
00031   // Use these flags to communicate pass/fail decisions made on the event
00032   typedef enum EDecisionFlag {
00033     kPassed,  // Record passes selection cuts
00034     kFailed   // Record fails selection cuts
00035   } Decision_t;
00036 
00037   // Use these when the I/O status changes
00038   typedef enum EIoFlag {
00039     kBeginFile,        // Start of new file
00040     kEndFile,          // End of file
00041     kBeginRun,         // Start of new run
00042     kEndRun,           // End of run
00043     kBeginOfInputStream, // Begin of input streams
00044     kEndOfInputStream,   // End of input streams
00045     kNonPhysicsRecord  // The record represents non-physics data
00046   } IoFlag_t;
00047   //====================================================================
00048 
00049 public:
00050   JobCResult(JobCResult::Error_t    result=kAOK);
00051   JobCResult(JobCResult::Decision_t result);
00052   JobCResult(JobCResult::IoFlag_t   result);
00053   
00054   JobCResult& operator=(JobCResult::Error_t    result);
00055   JobCResult& operator=(JobCResult::Decision_t result);
00056   JobCResult& operator=(JobCResult::IoFlag_t   result);
00057   JobCResult& operator|=(const JobCResult& rhs);
00058 
00059   // Are flags set?
00060   bool HaveError()    const;
00061   bool HaveDecision() const;
00062   bool HaveIoFlag()   const;
00063   
00064   // Which flags are set?
00065   JobCResult::Error_t ErrorLevel()       const;
00066   bool                Passed()           const;
00067   bool                Failed()           const;
00068   bool                BeginFile()        const;
00069   bool                EndFile()          const;
00070   bool                BeginRun()         const;
00071   bool                EndRun()           const;
00072   bool                BeginOfInputStream() const;
00073   bool                EndOfInputStream() const;
00074   bool                NonPhysicsRecord() const;
00075   
00076   // Set flags in the result
00077   JobCResult& SetAOK();
00078   JobCResult& SetWarning();
00079   JobCResult& SetError();
00080   JobCResult& SetFatal();
00081   JobCResult& SetFailed();
00082   JobCResult& SetPassed();
00083   JobCResult& ClearPassFail();
00084   JobCResult& SetBeginFile();
00085   JobCResult& SetEndFile();
00086   JobCResult& SetBeginRun();
00087   JobCResult& SetEndRun();
00088   JobCResult& SetBeginOfInputStream();
00089   JobCResult& SetEndOfInputStream();
00090   JobCResult& SetNonPhysicsRecord();
00091   
00092 private:
00093   // Define the bit fields for the different flags
00094   static const int kErrorMask           = 0x000F;
00095   static const int kAOKFlg              = 0x0000;
00096   static const int kWarningFlg          = 0x0001;
00097   static const int kErrorFlg            = 0x0002;
00098   static const int kFatalFlg            = 0x0004;
00099   
00100   static const int kDecisionMask        = 0x00F0;
00101   static const int kPassFlg             = 0x0010;
00102   static const int kFailFlg             = 0x0020;
00103   
00104   static const int kIoMask              = 0xFF00;
00105   static const int kBeginFileFlg        = 0x0100;
00106   static const int kEndFileFlg          = 0x0200;
00107   static const int kBeginRunFlg         = 0x0400;
00108   static const int kEndRunFlg           = 0x0800;
00109   static const int kEndOfInputStreamFlg = 0x1000;
00110   static const int kNonPhysicsRecordFlg = 0x2000;
00111   static const int kBeginOfInputStreamFlg = 0x4000;
00112   
00113   int fResult; // The result of processing a data record
00114 };
00115 
00116 #endif // JOBCRESULT_H
00117 
00118 

Generated on Fri Mar 28 15:33:28 2008 for loon by  doxygen 1.3.9.1