#ifndef TDigitHeader_hxx_seen #define TDigitHeader_hxx_seen #include #include #include #include #include namespace COMET { class IDigitHeader; } /// A base class for header information that is saved with the digits in a /// IDigitContainer. The IDigitHeader only has validity within the /// IDigitContainer that owns it. This class is for saving header information /// required to calibrate the IDigit objects in the IDigitContainer. class COMET::IDigitHeader { public: IDigitHeader(); virtual ~IDigitHeader(); /// Create a IDigitHeader with an explicit name. explicit IDigitHeader(const std::string& name); /// Get the name of the digit header. const std::string& GetName() const {return fName;} /// Set the name of the digit header. void SetName(const std::string& name) {fName = name;} /// Get the /// Get the first digit for which this header information is valid. This /// can be used to loop over the digits corresponding to this header /// information. /// /// \code /// IDigitContainer* container = ... /// IDigitHeader* hdr = ... /// for (unsigned d = hdr->GetBeginValid(); /// d < hdr->GetEndValid(); /// ++d) { /// IDigit* digit = container->at(d); /// ... do stuff ... /// } /// \endcode unsigned int GetBeginValid() const {return fBeginValid;} /// Set the beginning of the valid range. void SetBeginValid(unsigned int i) {fBeginValid = i;} /// Get the end of the range for which this header information is valid. /// See the documentation for GetBeginValid(). unsigned int GetEndValid() const {return fEndValid;} /// Set the end of the valid range. This should be one past the last /// valid digit. void SetEndValid(unsigned int i) {fEndValid = i;} /// A default way to add a IDatum. Derived classes will usually /// provide a specialized insertion method that is optimized for /// the class, but this provides a default interface that can be /// used in most circumstances. virtual void AddDatum(COMET::IDatum* val, const char* name=NULL); /// A default way to add a IHandle. This takes over memory /// management of the handle and will throw the EBadInsertion /// exception if the insertion fails. virtual void AddDatum(COMET::IHandle handle, const char* name=NULL); template COMET::IHandle Get(const char* name=".") const { if (!fDataVector) return COMET::IHandle(NULL); return fDataVector->Get(name); } /// Print the headera information. virtual void ls(Option_t* opt = "") const; private: /// The name of the digit header. std::string fName; /// The index of the first digit for which this header information is valid. unsigned int fBeginValid; /// The index one past the last digit for which this header information is /// valid. unsigned fEndValid; COMET::IDataVector* fDataVector; ClassDef(IDigitHeader, 1); }; #endif