Diana Software
QTObject.hh
Go to the documentation of this file.
1 #ifndef _Q_TOBJECT_HH_
2 #define _Q_TOBJECT_HH_
3 
33 #include "QObject.hh"
34 #include <TH1.h>
35 
37 
38 template<class T> class QTObject : public Diana::QObject {
39 
40  public:
43  if(TH1* histo = dynamic_cast<TH1*>(&fObject)) {
44  histo->AddDirectory(0);
45  }
46 
47  };
48 
50  QTObject(const T& other) {
51  if(TH1* histo = dynamic_cast<TH1*>(&fObject)) {
52  histo->AddDirectory(0);
53  }
54  fObject = other;
55  this->Validate();
56  }
57 
59  virtual ~QTObject() {};
61  void Clear() { fObject.Clear(); }
62 
63  const QTObject<T>& operator=(const T& other) {
64  fObject = other;
65  this->Validate();
66  return *this;
67  }
69  bool Fill(Diana::QObject* obj) const
70  {
71  QTObject<T>* bt = dynamic_cast<QTObject<T>* >(obj);
72  if(bt) {
73  *bt = *this;
74  }
75  return bt != NULL;
76  }
77 
79  QObject* Duplicate() const {
80  QTObject<T> * obj = new QTObject<T>;
81  return obj;
82  }
83 
85  virtual void Dump(std::ostream& o) const
86  {
87  o<<"Dump not implemented for QTObject";
88  }
89 
91  virtual QError WriteOnStream(std::ostream& o) const
92  {
94  err.SetDescription(__FILE__,__LINE__,"WriteOnStream not implementable for QTObject");
95  return err;
96  }
98  virtual QError ReadFromStream(std::istream& o)
99  {
101  err.SetDescription(__FILE__,__LINE__,"ReadFromStream not implementable for QTObject");
102  return err;
103  }
104 
106  void Draw(Option_t* option="") { fObject.Draw(option); } // *MENU*
107 
108 
111 
112  private:
113 
115 
116 };
117 
119 
120 #endif
err
Definition: CheckOF.C:114
TH1D histo("histo","My histogram", 10,-5, 5)
#define Q_END_NAMESPACE
Definition: QDiana.hh:22
#define Q_BEGIN_NAMESPACE
Definition: QDiana.hh:20
@ QERR_NOT_IMPLEMENTED
Definition: QError.hh:109
error class with error type and description
Definition: QError.hh:115
base class for objects handled by QEvent and QGlobalDataManager.
Definition: QObject.hh:76
QObject with TObject member.
Definition: QTObject.hh:38
T fObject
TObject member.
Definition: QTObject.hh:110
QTObject(const T &other)
copy ctor
Definition: QTObject.hh:50
virtual QError ReadFromStream(std::istream &o)
fill content from stream (intended for storage in text files)
Definition: QTObject.hh:98
virtual QError WriteOnStream(std::ostream &o) const
print content to stream (intended for storage in text files)
Definition: QTObject.hh:91
void Clear()
clear members
Definition: QTObject.hh:61
virtual ~QTObject()
dtor
Definition: QTObject.hh:59
bool Fill(Diana::QObject *obj) const
fill object of same type (like operator=)
Definition: QTObject.hh:69
QObject * Duplicate() const
create object of same type
Definition: QTObject.hh:79
QTObject()
ctor
Definition: QTObject.hh:42
void Draw(Option_t *option="")
Draw root.
Definition: QTObject.hh:106
ClassDef(QTObject, 1)
virtual void Dump(std::ostream &o) const
print content to stream (intended for screen print or log files)
Definition: QTObject.hh:85
const QTObject< T > & operator=(const T &other)
Definition: QTObject.hh:63