/** * \class COMET::IVldContext * * \ingroup Validity * * \brief A tag for identifying the required "context" when interfacing with the DBI. * * * * \author (last to touch it) $Author: finch $ * * \version $Revision: 1.1 $ * * \date $Date: 2011/01/18 05:49:20 $ * * Contact: R. Hatcher * * Created on: 2000.05.03 * */ #ifndef VLDCONTEXT_H #define VLDCONTEXT_H #include "TObject.h" #include "DbiDetector.hxx" #include "DbiSimFlag.hxx" #include "IVldTimeStamp.hxx" #include "ICOMETContext.hxx" // make the IVldContext cout'able #include namespace COMET { class IVldContext; class IVldContext : public TObject { public: IVldContext(); // necessary for streamer io IVldContext(const COMET::ICOMETContext& context); IVldContext(const COMET::DbiDetector::Detector_t &detector, const COMET::DbiSimFlag::SimFlag_t mcflag, const COMET::IVldTimeStamp &time); virtual ~IVldContext(); /// Return a formatted string of the contents of this object /// User should copy result because it points to a /// statically allocated string. const char* AsString(Option_t *option = "") const; COMET::DbiDetector::Detector_t GetDetector() const { return fDetector;} COMET::DbiSimFlag::SimFlag_t GetSimFlag() const { return fSimFlag;} COMET::IVldTimeStamp GetTimeStamp() const { return fTimeStamp;} /// Return true if this was initialized by default ctor /// we can only test detector type and simflag Bool_t IsNull() const; /// Return opposite of IsNull() Bool_t IsValid() const { return !IsNull(); } void Print(Option_t *option = "") const; friend Bool_t operator< (const IVldContext &lhs, const IVldContext &rhs); friend Bool_t operator==(const IVldContext &lhs, const IVldContext &rhs); friend Bool_t operator!=(const IVldContext &lhs, const IVldContext &rhs); friend Bool_t operator<=(const IVldContext &lhs, const IVldContext &rhs); friend Bool_t operator> (const IVldContext &lhs, const IVldContext &rhs); friend Bool_t operator>=(const IVldContext &lhs, const IVldContext &rhs); protected: // IVldContext(const TObject &object); // hide these // IVldContext(const IVldContext &tf); // IVldContext& operator=(const TObject &rhs); // IVldContext& operator=(const IVldContext &tf); COMET::DbiDetector::Detector_t fDetector; COMET::DbiSimFlag::SimFlag_t fSimFlag; COMET::IVldTimeStamp fTimeStamp; private: ClassDef(COMET::IVldContext,2) // COMET::IVldTimeStamp+Detector+SimFlag }; }; std::ostream& operator<<(std::ostream& os, const COMET::IVldContext& vldts); #ifndef __CINT__ //============================================================================= // Implementation details -- inlines need to be hidden from CINT //============================================================================= inline Bool_t COMET::operator< (const COMET::IVldContext &lhs, const COMET::IVldContext &rhs) { // sorting is a little tricky with three fields // this sorts first by time then detector then simflag // *WARNING* be very careful if you change this if ( lhs.fTimeStamp < rhs.fTimeStamp ) return true; if ( lhs.fTimeStamp == rhs.fTimeStamp ) { if ( lhs.fDetector < rhs.fDetector ) return true; if ( lhs.fDetector == rhs.fDetector ) { if (lhs.fSimFlag < rhs.fSimFlag ) return true; } } return false; } inline Bool_t COMET::operator==(const COMET::IVldContext &lhs, const COMET::IVldContext &rhs) { // equal if all components match return lhs.fDetector == rhs.fDetector && lhs.fSimFlag == rhs.fSimFlag && lhs.fTimeStamp == rhs.fTimeStamp; } inline Bool_t COMET::operator!=(const COMET::IVldContext &lhs, const COMET::IVldContext &rhs) { // not equal if any component doesn't match return lhs.fDetector != rhs.fDetector || lhs.fSimFlag != rhs.fSimFlag || lhs.fTimeStamp != rhs.fTimeStamp; } inline Bool_t COMET::operator<=(const COMET::IVldContext &lhs, const COMET::IVldContext &rhs) { return (lhs(const COMET::IVldContext &lhs, const COMET::IVldContext &rhs) { return !(lhs=(const COMET::IVldContext &lhs, const COMET::IVldContext &rhs) { return !(lhs