#ifndef __JGIZMO__JROOTOBJECT__ #define __JGIZMO__JROOTOBJECT__ #include #include "TObject.h" #include "TString.h" #include "JLang/JPointer.hh" /** * \author mdejong */ namespace JGIZMO {} namespace JPP { using namespace JGIZMO; } namespace JGIZMO { using JLANG::JPointer; static const char LABEL_TERMINATOR = '&'; //!< label terminator /** * Auxiliary data structure for TObject with a user defined label. */ class JRootObject : public JPointer { public: /** * Constructor. * * \param __p pointer to object */ JRootObject(TObject* __p) : JLANG::JPointer(__p) { label = get()->GetName(); } /** * Constructor. * * \param __p pointer to object * \param __label label */ JRootObject(TObject* __p, const TString& __label): JLANG::JPointer(__p) { this->label = __label; } /** * Get label. * * \return label */ TString getLabel() const { TString buffer(this->label); const Ssiz_t pos = buffer.Last(LABEL_TERMINATOR); if (pos != kNPOS) { buffer = buffer(0, pos); } return buffer; } /** * Set label. * * \param label label */ void setLabel(const TString& label) { this->label = label; } /** * Draw object. */ void Draw(const std::string& option) const { this->get()->Draw(option.c_str()); } protected: TString label; }; } #endif