Diana Software
QObject.hh
Go to the documentation of this file.
1 
31 #ifndef __QOBJECT_HH_
32 #define __QOBJECT_HH_
33 
34 #include "QDiana.hh"
35 #include <TObject.h>
36 #include "QError.hh"
37 #include <iostream>
38 
39 #ifdef __clang__
40 #pragma clang diagnostic ignored "-Woverloaded-virtual"
41 #endif
42 
47 #define QObjectDef(clazz,id) \
48  public:\
49  virtual bool Fill(Diana::QObject* evData) const; \
50  virtual Diana::QObject* Duplicate() const; \
51  ClassDef(clazz,id);
52 
53 
58 #define QObjectImp(clazz) \
59  using Diana::QObject;\
60  ClassImp(clazz)\
61  bool clazz::Fill(QObject* evData) const {\
62  clazz * evDatac = dynamic_cast<clazz*>(evData);\
63  if(evDatac) {\
64  *evDatac = *this; \
65  }\
66  return evDatac != NULL; \
67  }\
68  QObject* clazz::Duplicate() const {\
69  clazz * obj = new clazz;\
70  return obj;\
71  }
72 
73 
75 
76 class QObject : public TObject {
77  public:
78  /* still to be migrated
79  enum Type {
80  LCMeasConfigMap = 3,
81  GuiSession = 5,
82  CurveCrawler = 7,
83  };
84  */
86  enum {
88  kIsValid = BIT(15),
90  kWrite = BIT(0), //
92  kIsRequired = BIT(1),
94  kIsJustAdded = BIT(2),
95  };
96 
97 
98  static QObject* New(const char* object);
100  QObject();
102  virtual ~QObject() {};
103 
105  QObject& operator=(const QObject& rhs);
106 
108  void Validate() {SetBit(kIsValid,true); }
109 
111  void InValidate() { SetBit(kIsValid,false); }
112 
114  bool IsValid() const { return TestBit(kIsValid); }
115 
117  void SetWrite ( bool write = true ) { QObjectSetBit(kWrite,write); }
118 
120  bool GetWrite() const { return QObjectTestBit(kWrite); }
121 
123  bool IsRequired() const { return QObjectTestBit(kIsRequired); }
124 
126  void SetIsRequired(bool required = true) {QObjectSetBit(kIsRequired,required); }
127 
129  bool IsJustAdded() const { return QObjectTestBit(kIsJustAdded); }
130 
132  void SetIsJustAdded(bool added = true) {QObjectSetBit(kIsJustAdded,added); }
133 
135  virtual void Clear() = 0;
136 
138  void Reset() { InValidate(); Clear(); }
139 
140 
147  virtual bool Fill(QObject* evData) const = 0 ;
148 
150  void FullyFill(QObject* evData) const;
151 
157  virtual QObject* Duplicate() const = 0;
158 
160  virtual void Dump(std::ostream& o) const;
161 
163  virtual void Print() const { Dump(std::cout); } // *MENU*
164 
166  virtual QError WriteOnStream(std::ostream& o) const;
168  virtual QError ReadFromStream(std::istream& o) ;
169 
171  void CopyBits(QObject* obj) const;
172 
173  virtual void Draw(Option_t* option = "") {} ;
174 
175  private:
177  void QObjectSetBit(int bit, bool value);
179  bool QObjectTestBit(int bit) const;
182 
184 };
185 
186 
188 
189 std::ostream& operator<<(std::ostream&s,const Diana::QObject&t);
190 #endif
#define Q_END_NAMESPACE
Definition: QDiana.hh:22
#define Q_BEGIN_NAMESPACE
Definition: QDiana.hh:20
Q_END_NAMESPACE std::ostream & operator<<(std::ostream &s, const Diana::QObject &t)
Definition: QObject.cc:100
error class with error type and description
Definition: QError.hh:115
base class for objects handled by QEvent and QGlobalDataManager.
Definition: QObject.hh:76
virtual void Print() const
print content on screen
Definition: QObject.hh:163
void Validate()
make object valid
Definition: QObject.hh:108
void InValidate()
make object non valid
Definition: QObject.hh:111
virtual QError WriteOnStream(std::ostream &o) const
print content to stream (intended for storage in text files)
Definition: QObject.cc:62
void SetWrite(bool write=true)
write or not this object
Definition: QObject.hh:117
virtual void Clear()=0
reset members to default values
int fTemporaryBits
temporary bits are used for runtime diana settings
Definition: QObject.hh:181
virtual void Dump(std::ostream &o) const
print content to stream (intended for screen print or log files)
Definition: QObject.cc:53
bool IsValid() const
check wheter object is valid
Definition: QObject.hh:114
virtual void Draw(Option_t *option="")
Definition: QObject.hh:173
void SetIsJustAdded(bool added=true)
set that this object has been just added
Definition: QObject.hh:132
void CopyBits(QObject *obj) const
copy validity and temporary bits to another QObject
Definition: QObject.cc:84
bool GetWrite() const
check wheter write or not this object
Definition: QObject.hh:120
void QObjectSetBit(int bit, bool value)
set temporary bit
Definition: QObject.cc:75
bool QObjectTestBit(int bit) const
test temporary bit
Definition: QObject.cc:92
@ kWrite
write this object onto output files, this and the bits below should go in the handle?...
Definition: QObject.hh:90
@ kIsJustAdded
this object has been just added to the event
Definition: QObject.hh:94
@ kIsRequired
this object has been requested by somebody
Definition: QObject.hh:92
@ kIsValid
object has been assigned a value
Definition: QObject.hh:88
QObject & operator=(const QObject &rhs)
operator=
Definition: QObject.cc:32
bool IsRequired() const
check wheter this object is required by some module
Definition: QObject.hh:123
virtual QError ReadFromStream(std::istream &o)
fill content from stream (intended for storage in text files)
Definition: QObject.cc:68
void Reset()
set object to non valid and calls Clear()
Definition: QObject.hh:138
void SetIsRequired(bool required=true)
set that this object is required
Definition: QObject.hh:126
virtual bool Fill(QObject *evData) const =0
calls operator= of inheriting classes. Validity flag and bits are not copied. This function is automa...
virtual QObject * Duplicate() const =0
create object of same type, this function is automatically declared/implemented in derived classes by...
virtual ~QObject()
destructor
Definition: QObject.hh:102
bool IsJustAdded() const
check wheter this object has been just added by some module
Definition: QObject.hh:129
static QObject * New(const char *object)
Definition: QObject.cc:14
void FullyFill(QObject *evData) const
calls Fill(QObject*) if this QObject IsValid(). Copies Validity flag and bits
Definition: QObject.cc:39
ClassDef(QObject, 4)
QObject()
default constructor
Definition: QObject.cc:23