KaliVeda  1.13/01
Heavy-Ion Analysis Toolkit
KVSeqCollection.h
Go to the documentation of this file.
1 
4 #ifndef __KVSEQCOLLECTION_H
5 #define __KVSEQCOLLECTION_H
6 
7 #include "TSeqCollection.h"
8 #include <RQ_OBJECT.h>
9 #include "TFile.h"
10 #include "KVConfig.h"
11 
41 
92  RQ_OBJECT("KVSeqCollection")
93 
94  enum {
95  kSignals = BIT(15), // bit flag for sending 'Modified()' signal on changes
97  kCleanup = BIT(17) // set when objects in list are in ROOT cleanup list
98  };
99 
101  void init();
102  static Int_t fgCounter;
104 
105 protected:
107 
108  virtual void Changed()
109  {
113 
115  if (TestBit(kSignals)) Modified();
116  };
117  virtual void PrintCollectionHeader(Option_t* option) const;
118  virtual KVSeqCollection* NewCollectionLikeThisOne() const;
119  virtual void SetCollection(const Char_t*);
120  virtual void _GetSubListWithMethod(KVSeqCollection*, TCollection*, const Char_t*, const Char_t*) const;
122 
123 public:
124  KVSeqCollection();
126  KVSeqCollection(const Char_t* collection_classname);
127  virtual ~KVSeqCollection();
128  virtual void Copy(TObject& obj) const;
130 
131  virtual void Modified()
132  {
133  Emit("Modified()");
134  } // *SIGNAL*
135  virtual void SendModifiedSignals(Bool_t yes = kTRUE)
136  {
143  SetBit(kSignals, yes);
144  }
146  {
149  return TestBit(kSignals);
150  }
151 
152  virtual TObject* At(Int_t idx) const
153  {
154  return fCollection->At(idx);
155  }
156  virtual void AddFirst(TObject* obj)
157  {
161 
162  if (IsCleanup()) obj->SetBit(kMustCleanup);
163  fCollection->AddFirst(obj);
164  Changed();
165  }
166  virtual void AddLast(TObject* obj)
167  {
171 
172  if (IsCleanup()) obj->SetBit(kMustCleanup);
173  fCollection->AddLast(obj);
174  Changed();
175  }
176  virtual void AddAt(TObject* obj, Int_t idx)
177  {
181 
182  if (IsCleanup()) obj->SetBit(kMustCleanup);
183  fCollection->AddAt(obj, idx);
184  Changed();
185  }
186  virtual void AddAfter(const TObject* after, TObject* obj)
187  {
191 
192  if (IsCleanup()) obj->SetBit(kMustCleanup);
193  fCollection->AddAfter(after, obj);
194  Changed();
195  }
196  virtual void AddBefore(const TObject* before, TObject* obj)
197  {
201 
202  if (IsCleanup()) obj->SetBit(kMustCleanup);
203  fCollection->AddBefore(before, obj);
204  Changed();
205  }
206  virtual TObject* Before(const TObject* obj) const
207  {
208  return fCollection->Before(obj);
209  }
210  virtual TObject* After(const TObject* obj) const
211  {
212  return fCollection->After(obj);
213  }
214  virtual TObject* First() const
215  {
216  return fCollection->First();
217  }
218  virtual TObject* Last() const
219  {
220  return fCollection->Last();
221  }
222  virtual void Add(TObject* obj)
223  {
227 
228  if (IsCleanup()) obj->SetBit(kMustCleanup);
229  fCollection->Add(obj);
230  Changed();
231  }
232  virtual void Clear(Option_t* option = "");
233  virtual void Delete(Option_t* option = "");
234  virtual TObject** GetObjectRef(const TObject* obj) const;
235  virtual TIterator* MakeIterator(Bool_t dir = kIterForward) const;
236  virtual TObject* Remove(TObject* obj);
237  virtual void RecursiveRemove(TObject* obj);
238  virtual Int_t GetSize() const
239  {
240  return fCollection ? fCollection->GetSize() : 0;
241  }
242  virtual void SetOwner(Bool_t enable = kTRUE)
243  {
245  TSeqCollection::SetOwner(enable);
246  fCollection->SetOwner(enable);
247  }
249  {
251  return fCollection->ClassName();
252  }
253  virtual void SetCleanup(Bool_t enable = kTRUE);
254  virtual Bool_t IsCleanup() const
255  {
258  return TestBit(kCleanup);
259  }
260  static void RehashCleanupList();
261 
262  virtual TObject* FindObject(const char* name) const
263  {
264  return fCollection->FindObject(name);
265  }
266  template
267  <typename T>
268  T* get_object(const TString& name) const
269  {
270  return dynamic_cast<T*>(FindObject(name));
271  }
272  virtual TObject* FindObject(const TObject* obj) const
273  {
274  return fCollection->FindObject(obj);
275  }
276  virtual TObject* FindObjectByName(const Char_t* name) const
277  {
278  return fCollection->FindObject(name);
279  }
280  virtual TObject* FindObjectByType(const Char_t*) const;
281  virtual TObject* FindObjectByTitle(const Char_t*) const;
282  TObject* FindObjectByClass(const Char_t*) const;
283  TObject* FindObjectByClass(const TClass*) const;
284  virtual TObject* FindObjectByLabel(const Char_t*) const;
285  virtual TObject* FindObjectByNumber(UInt_t num) const;
286  virtual TObject* FindObjectWithNameAndType(const Char_t* name, const Char_t* type) const;
287  virtual TObject* FindObjectWithMethod(const Char_t* retvalue, const Char_t* method) const;
288  virtual TObject* FindObjectAny(const Char_t* att, const Char_t* keys, Bool_t contains_all = kFALSE, Bool_t case_sensitive = kTRUE) const;
289 
290 #ifdef __WITHOUT_TCOLLECTION_GETENTRIES
292  virtual Int_t GetEntries() const
293  {
294  return GetSize();
295  };
296 #endif
297  virtual void Execute(const char* method, const char* params,
298  Int_t* error = 0);
299  virtual void Execute(TMethod* method, TObjArray* params,
300  Int_t* error = 0);
301  KVSeqCollection* GetSubListWithMethod(const Char_t* retvalue, const Char_t* method) const;
302 
303  KVSeqCollection* GetSubListWithClass(const TClass* _class) const;
304  KVSeqCollection* GetSubListWithClass(const Char_t* class_name) const;
305 
306  KVSeqCollection* GetSubListWithName(const Char_t* retvalue) const;
307  KVSeqCollection* GetSubListWithLabel(const Char_t* retvalue) const;
308  KVSeqCollection* GetSubListWithType(const Char_t* retvalue) const;
309 
311  static KVSeqCollection* MakeListFromFileWithMethod(TFile* file, const Char_t* retvalue, const Char_t* method);
312  static KVSeqCollection* MakeListFromFileWithClass(TFile* file, const TClass* _class);
313  static KVSeqCollection* MakeListFromFileWithClass(TFile* file, const Char_t* class_name);
314 
315  virtual Bool_t IsSortable() const
316  {
317  return fCollection->IsSortable();
318  }
319  virtual Bool_t IsSorted() const
320  {
321  return fCollection->IsSorted();
322  }
323 
325  {
326  return fCollection;
327  }
328 
329  ClassDef(KVSeqCollection, 3) //KaliVeda extensions to ROOT collections
330 };
331 
332 #if ROOT_VERSION_CODE < ROOT_VERSION(5,11,2)
333 
335 
338 
339 #define R__FOR_EACH(type,proc) \
340  SetCurrentCollection(); \
341  TIter _NAME3_(nxt_,type,proc)(TCollection::GetCurrentCollection()); \
342  type *_NAME3_(obj_,type,proc); \
343  while ((_NAME3_(obj_,type,proc) = (type*) _NAME3_(nxt_,type,proc)())) \
344  _NAME3_(obj_,type,proc)->proc
345 
346 #endif
347 
348 #endif
int Int_t
unsigned int UInt_t
#define RQ_OBJECT(sender_class)
char Char_t
bool Bool_t
const char Option_t
#define ClassDef(name, id)
#define BIT(n)
KaliVeda extensions to ROOT collection classes.
virtual TObject * FindObjectByLabel(const Char_t *) const
static Long64_t fSCCounter
counter used to give unique names to all lists
virtual void Modified()
const Char_t * CollectionClassName() const
virtual ~KVSeqCollection()
virtual void Copy(TObject &obj) const
KVSeqCollection * GetSubListWithName(const Char_t *retvalue) const
KVSeqCollection * GetSubListWithMethod(const Char_t *retvalue, const Char_t *method) const
KVSeqCollection & operator=(const KVSeqCollection &)
virtual TObject ** GetObjectRef(const TObject *obj) const
Return reference to object.
virtual TObject * Before(const TObject *obj) const
static TSeqCollection * fgCleanups
regroup all lists which are to be cleaned up
virtual void AddLast(TObject *obj)
T * get_object(const TString &name) const
virtual TObject * After(const TObject *obj) const
virtual void SendModifiedSignals(Bool_t yes=kTRUE)
virtual KVSeqCollection * NewCollectionLikeThisOne() const
virtual Bool_t IsCleanup() const
virtual void SetCollection(const Char_t *)
KVSeqCollection * GetSubListWithClass(const TClass *_class) const
TSeqCollection * fCollection
Pointer to embedded ROOT collection.
virtual TObject * Last() const
virtual void SetOwner(Bool_t enable=kTRUE)
virtual Bool_t IsSortable() const
virtual void Clear(Option_t *option="")
virtual Int_t GetSize() const
virtual TObject * At(Int_t idx) const
virtual TObject * FindObjectAny(const Char_t *att, const Char_t *keys, Bool_t contains_all=kFALSE, Bool_t case_sensitive=kTRUE) const
TObject * FindObjectByClass(const Char_t *) const
Return (first) object in embedded list with given class.
virtual void AddBefore(const TObject *before, TObject *obj)
virtual TObject * First() const
KVSeqCollection * GetSubListWithType(const Char_t *retvalue) const
virtual void AddAfter(const TObject *after, TObject *obj)
virtual void _GetSubListWithMethod(KVSeqCollection *, TCollection *, const Char_t *, const Char_t *) const
virtual void Execute(const char *method, const char *params, Int_t *error=0)
KVSeqCollection()
Default constructor.
virtual Bool_t IsSendingModifiedSignals() const
static void RehashCleanupList()
virtual void Changed()
virtual TObject * FindObject(const TObject *obj) const
static Int_t fgCounter
counts instances
virtual void PrintCollectionHeader(Option_t *option) const
Overrides TCollection::PrintCollectionHeader to show the class name of the embedded list.
virtual void SetCleanup(Bool_t enable=kTRUE)
static KVSeqCollection * MakeListFromFileWithClass(TFile *file, const TClass *_class)
virtual TObject * FindObjectByNumber(UInt_t num) const
TSeqCollection * GetCollection() const
virtual TObject * FindObjectWithMethod(const Char_t *retvalue, const Char_t *method) const
static KVSeqCollection * MakeListFromFile(TFile *file)
virtual TObject * FindObjectByType(const Char_t *) const
virtual TObject * FindObjectByTitle(const Char_t *) const
Will return object with given title (value of TObject::GetTitle() method).
virtual void Add(TObject *obj)
virtual Bool_t IsSorted() const
virtual TObject * FindObjectByName(const Char_t *name) const
virtual TObject * FindObjectWithNameAndType(const Char_t *name, const Char_t *type) const
virtual void AddAt(TObject *obj, Int_t idx)
virtual TIterator * MakeIterator(Bool_t dir=kIterForward) const
Make and return iterator for the list.
KVSeqCollection * GetSubListWithLabel(const Char_t *retvalue) const
virtual void AddFirst(TObject *obj)
virtual TObject * Remove(TObject *obj)
Remove object from list.
virtual void Delete(Option_t *option="")
static KVSeqCollection * MakeListFromFileWithMethod(TFile *file, const Char_t *retvalue, const Char_t *method)
@ kCleanup
in ROOT v6 BIT(16) is used by TCollection - without changing the class version
void _GetSubListWithClass(KVSeqCollection *, TCollection *, const TClass *) const
virtual void RecursiveRemove(TObject *obj)
virtual TObject * FindObject(const char *name) const
virtual TObject * FindObject(const char *name) const
Bool_t IsSortable() const
virtual Int_t GetEntries() const
virtual void SetOwner(Bool_t enable=kTRUE)
virtual Int_t GetSize() const
void SetBit(UInt_t f)
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual const char * ClassName() const
virtual void AddLast(TObject *obj)=0
virtual void AddBefore(const TObject *before, TObject *obj)=0
virtual TObject * Last() const=0
virtual TObject * At(Int_t idx) const=0
virtual void AddAt(TObject *obj, Int_t idx)=0
virtual TObject * After(const TObject *obj) const=0
virtual void AddAfter(const TObject *after, TObject *obj)=0
virtual TObject * First() const=0
virtual Bool_t IsSorted() const
virtual void Changed()
virtual void Add(TObject *obj)
virtual TObject * Before(const TObject *obj) const=0
virtual void AddFirst(TObject *obj)=0
long long Long64_t
double T(double x)