TVldContext.hxx

Go to the documentation of this file.
00001 /**
00002  * \class TVldContext
00003  *
00004  * \ingroup Validity
00005  *
00006  * \brief A tag for identifying the required "context" when interfacing with the DBI.
00007  *
00008  * 
00009  *
00010  * \author (last to touch it) $Author: finch $
00011  *
00012  * \version $Revision: 1.1 $
00013  *
00014  * \date $Date: 2011/01/18 05:49:20 $
00015  *
00016  * Contact: R. Hatcher
00017  *
00018  * Created on: 2000.05.03
00019  *
00020  */
00021 
00022 #ifndef VLDCONTEXT_H
00023 #define VLDCONTEXT_H
00024 
00025 #include "TObject.h"
00026 #include "DbiDetector.hxx"
00027 #include "DbiSimFlag.hxx"
00028 #include "TVldTimeStamp.hxx"
00029 
00030 #include "TSK_DBI_Context.hxx"
00031 
00032 // make the TVldContext cout'able
00033 #include <iosfwd>
00034 
00035 
00036 class TVldContext;
00037 
00038 class TVldContext : public TObject {
00039 
00040  public:
00041 
00042    TVldContext();                        // necessary for streamer io
00043    TVldContext(const TSK_DBI_Context& context);
00044    TVldContext(const DbiDetector::Detector_t &detector,
00045               const DbiSimFlag::SimFlag_t mcflag,
00046               const TVldTimeStamp &time);
00047    virtual ~TVldContext();
00048 
00049    /// Return a formatted string of the contents of this object
00050    /// User should copy result because it points to a 
00051    /// statically allocated string.
00052    const char* AsString(Option_t *option = "") const;
00053 
00054    DbiDetector::Detector_t     GetDetector()  const { return fDetector;}
00055    DbiSimFlag::SimFlag_t       GetSimFlag()   const { return fSimFlag;}
00056    TVldTimeStamp             GetTimeStamp() const { return fTimeStamp;}
00057 
00058    /// Return true if this was initialized by default ctor
00059    /// we can only test detector type and simflag
00060    Bool_t                   IsNull() const;
00061    /// Return opposite of IsNull()
00062    Bool_t                   IsValid() const { return !IsNull(); }
00063 
00064    void                     Print(Option_t *option = "") const;
00065 
00066    friend Bool_t operator< (const TVldContext &lhs, const TVldContext &rhs);
00067    friend Bool_t operator==(const TVldContext &lhs, const TVldContext &rhs);
00068    friend Bool_t operator!=(const TVldContext &lhs, const TVldContext &rhs);
00069    friend Bool_t operator<=(const TVldContext &lhs, const TVldContext &rhs);
00070    friend Bool_t operator> (const TVldContext &lhs, const TVldContext &rhs);
00071    friend Bool_t operator>=(const TVldContext &lhs, const TVldContext &rhs);
00072 
00073  protected:
00074    //   TVldContext(const TObject &object);           // hide these
00075    //   TVldContext(const TVldContext &tf);
00076    //   TVldContext& operator=(const TObject &rhs);
00077    //   TVldContext& operator=(const TVldContext &tf);
00078 
00079    DbiDetector::Detector_t       fDetector;
00080    DbiSimFlag::SimFlag_t         fSimFlag;
00081    TVldTimeStamp               fTimeStamp;
00082 
00083  private:
00084 
00085    ClassDef(TVldContext,2)  // TVldTimeStamp+Detector+SimFlag
00086 
00087 };
00088 
00089 std::ostream& operator<<(std::ostream& os, const TVldContext& vldts);
00090 
00091 #ifndef __CINT__
00092 //=============================================================================
00093 // Implementation details -- inlines need to be hidden from CINT
00094 //=============================================================================
00095 inline Bool_t operator< (const TVldContext &lhs, const TVldContext &rhs)
00096 { 
00097    // sorting is a little tricky with three fields
00098    // this sorts first by time then detector then simflag
00099    // *WARNING* be very careful if you change this
00100    if ( lhs.fTimeStamp  < rhs.fTimeStamp ) return true;
00101    if ( lhs.fTimeStamp == rhs.fTimeStamp ) {
00102       if ( lhs.fDetector  < rhs.fDetector ) return true;
00103       if ( lhs.fDetector == rhs.fDetector ) {
00104          if (lhs.fSimFlag  < rhs.fSimFlag ) return true;
00105       }
00106    }
00107    return false;
00108 }
00109 
00110 inline Bool_t operator==(const TVldContext &lhs, const TVldContext &rhs)
00111 { 
00112    // equal if all components match
00113    return 
00114      lhs.fDetector  == rhs.fDetector &&
00115      lhs.fSimFlag   == rhs.fSimFlag  &&
00116      lhs.fTimeStamp == rhs.fTimeStamp;
00117 }
00118 
00119 inline Bool_t operator!=(const TVldContext &lhs, const TVldContext &rhs)
00120 { 
00121    // not equal if any component doesn't match
00122    return 
00123      lhs.fDetector  != rhs.fDetector ||
00124      lhs.fSimFlag   != rhs.fSimFlag  ||
00125      lhs.fTimeStamp != rhs.fTimeStamp;
00126 }
00127 
00128 inline Bool_t operator<=(const TVldContext &lhs, const TVldContext &rhs)
00129 {
00130   return (lhs<rhs) || (lhs==rhs);
00131 }
00132 
00133 inline Bool_t operator>(const TVldContext &lhs, const TVldContext &rhs)
00134 {
00135   return !(lhs<rhs) && !(lhs==rhs);
00136 }
00137 
00138 inline Bool_t operator>=(const TVldContext &lhs, const TVldContext &rhs)
00139 {
00140   return !(lhs<rhs);
00141 }
00142 
00143 inline TVldContext::TVldContext() 
00144   :  fDetector(DbiDetector::kUnknown), 
00145      fSimFlag(DbiSimFlag::kUnknown), 
00146      fTimeStamp() {
00147    // Default constructor (unknown detector, simflag, timestamp=now)
00148 }
00149 
00150 inline TVldContext::~TVldContext() { ; }
00151 
00152 #endif /* __CINT__ */
00153 #endif // VLDCONTEXT_H

Generated on 11 Aug 2013 for SKDatabase by  doxygen 1.6.1