KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
KVSeqCollection.h
1
3
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
42
93 RQ_OBJECT("KVSeqCollection")
94
95 enum {
96 kSignals = BIT(15), // bit flag for sending 'Modified()' signal on changes
98 kCleanup = BIT(17) // set when objects in list are in ROOT cleanup list
99 };
100
102 void init();
105
106protected:
108
109 virtual void Changed()
110 {
114
116 if (TestBit(kSignals)) Modified();
117 };
118 virtual void PrintCollectionHeader(Option_t* option) const;
120 virtual void SetCollection(const Char_t*);
121 virtual void _GetSubListWithMethod(KVSeqCollection*, TCollection*, const Char_t*, const Char_t*) const;
123
124public:
127 KVSeqCollection(const Char_t* collection_classname);
128 virtual ~KVSeqCollection();
129 virtual void Copy(TObject& obj) const;
131
132 virtual void Modified()
133 {
134 Emit("Modified()");
135 } // *SIGNAL*
136 virtual void SendModifiedSignals(Bool_t yes = kTRUE)
137 {
144 SetBit(kSignals, yes);
145 }
147 {
150 return TestBit(kSignals);
151 }
152
153 virtual TObject* At(Int_t idx) const
154 {
155 return fCollection->At(idx);
156 }
157 virtual void AddFirst(TObject* obj)
158 {
162
163 if (IsCleanup()) obj->SetBit(kMustCleanup);
164 fCollection->AddFirst(obj);
165 Changed();
166 }
167 virtual void AddLast(TObject* obj)
168 {
172
173 if (IsCleanup()) obj->SetBit(kMustCleanup);
174 fCollection->AddLast(obj);
175 Changed();
176 }
177 virtual void AddAt(TObject* obj, Int_t idx)
178 {
182
183 if (IsCleanup()) obj->SetBit(kMustCleanup);
184 fCollection->AddAt(obj, idx);
185 Changed();
186 }
187 virtual void AddAfter(const TObject* after, TObject* obj)
188 {
192
193 if (IsCleanup()) obj->SetBit(kMustCleanup);
194 fCollection->AddAfter(after, obj);
195 Changed();
196 }
197 virtual void AddBefore(const TObject* before, TObject* obj)
198 {
202
203 if (IsCleanup()) obj->SetBit(kMustCleanup);
204 fCollection->AddBefore(before, obj);
205 Changed();
206 }
207 virtual TObject* Before(const TObject* obj) const
208 {
209 return fCollection->Before(obj);
210 }
211 virtual TObject* After(const TObject* obj) const
212 {
213 return fCollection->After(obj);
214 }
215 virtual TObject* First() const
216 {
217 return fCollection->First();
218 }
219 virtual TObject* Last() const
220 {
221 return fCollection->Last();
222 }
223 virtual void Add(TObject* obj)
224 {
228
229 if (IsCleanup()) obj->SetBit(kMustCleanup);
230 fCollection->Add(obj);
231 Changed();
232 }
233 virtual void Clear(Option_t* option = "");
234 virtual void Delete(Option_t* option = "");
235 virtual TObject** GetObjectRef(const TObject* obj) const;
236 virtual TIterator* MakeIterator(Bool_t dir = kIterForward) const;
237 virtual TObject* Remove(TObject* obj);
238 virtual void RecursiveRemove(TObject* obj);
239 virtual Int_t GetSize() const
240 {
241 return fCollection ? fCollection->GetSize() : 0;
242 }
243 virtual void SetOwner(Bool_t enable = kTRUE)
244 {
247 fCollection->SetOwner(enable);
248 }
250 {
252 return fCollection->ClassName();
253 }
254 virtual void SetCleanup(Bool_t enable = kTRUE);
255 virtual Bool_t IsCleanup() const
256 {
259 return TestBit(kCleanup);
260 }
261 static void RehashCleanupList();
262
263 virtual TObject* FindObject(const char* name) const
264 {
265 return fCollection->FindObject(name);
266 }
267 template
268 <typename T>
269 T* get_object(const TString& name) const
270 {
271 return dynamic_cast<T*>(FindObject(name));
272 }
273 virtual TObject* FindObject(const TObject* obj) const
274 {
275 return fCollection->FindObject(obj);
276 }
277 virtual TObject* FindObjectByName(const Char_t* name) const
278 {
279 return fCollection->FindObject(name);
280 }
281 virtual TObject* FindObjectByType(const Char_t*) const;
282 virtual TObject* FindObjectByTitle(const Char_t*) const;
283 TObject* FindObjectByClass(const Char_t*) const;
284 TObject* FindObjectByClass(const TClass*) const;
285 virtual TObject* FindObjectByLabel(const Char_t*) const;
286 virtual TObject* FindObjectByNumber(UInt_t num) const;
287 virtual TObject* FindObjectWithNameAndType(const Char_t* name, const Char_t* type) const;
288 virtual TObject* FindObjectWithMethod(const Char_t* retvalue, const Char_t* method) const;
289 virtual TObject* FindObjectAny(const Char_t* att, const Char_t* keys, Bool_t contains_all = kFALSE, Bool_t case_sensitive = kTRUE) const;
290
291#ifdef __WITHOUT_TCOLLECTION_GETENTRIES
293 virtual Int_t GetEntries() const
294 {
295 return GetSize();
296 };
297#endif
298 virtual void Execute(const char* method, const char* params,
299 Int_t* error = 0);
300 virtual void Execute(TMethod* method, TObjArray* params,
301 Int_t* error = 0);
302 KVSeqCollection* GetSubListWithMethod(const Char_t* retvalue, const Char_t* method) const;
303
304 KVSeqCollection* GetSubListWithClass(const TClass* _class) const;
305 KVSeqCollection* GetSubListWithClass(const Char_t* class_name) const;
306
307 KVSeqCollection* GetSubListWithName(const Char_t* retvalue) const;
308 KVSeqCollection* GetSubListWithLabel(const Char_t* retvalue) const;
309 KVSeqCollection* GetSubListWithType(const Char_t* retvalue) const;
310
312 static KVSeqCollection* MakeListFromFileWithMethod(TFile* file, const Char_t* retvalue, const Char_t* method);
314 static KVSeqCollection* MakeListFromFileWithClass(TFile* file, const Char_t* class_name);
315
316 virtual Bool_t IsSortable() const
317 {
318 return fCollection->IsSortable();
319 }
320 virtual Bool_t IsSorted() const
321 {
322 return fCollection->IsSorted();
323 }
324
326 {
327 return fCollection;
328 }
329
330 ClassDef(KVSeqCollection, 3) //KaliVeda extensions to ROOT collections
331};
332
333#if ROOT_VERSION_CODE < ROOT_VERSION(5,11,2)
334
336
339
340#define R__FOR_EACH(type,proc) \
341 SetCurrentCollection(); \
342 TIter _NAME3_(nxt_,type,proc)(TCollection::GetCurrentCollection()); \
343 type *_NAME3_(obj_,type,proc); \
344 while ((_NAME3_(obj_,type,proc) = (type*) _NAME3_(nxt_,type,proc)())) \
345 _NAME3_(obj_,type,proc)->proc
346
347#endif
348
349#endif
int Int_t
unsigned int UInt_t
#define RQ_OBJECT(sender_class)
bool Bool_t
char Char_t
const char Option_t
#define ClassDef(name, id)
#define BIT(n)
char name[80]
KaliVeda extensions to ROOT collection classes.
virtual TObject * FindObject(const char *name) const
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 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.
static TSeqCollection * fgCleanups
regroup all lists which are to be cleaned up
virtual void AddLast(TObject *obj)
virtual void SendModifiedSignals(Bool_t yes=kTRUE)
virtual KVSeqCollection * NewCollectionLikeThisOne() const
virtual Bool_t IsCleanup() const
TSeqCollection * GetCollection() const
virtual void SetCollection(const Char_t *)
KVSeqCollection * GetSubListWithClass(const TClass *_class) const
TSeqCollection * fCollection
Pointer to embedded ROOT collection.
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 * FindObjectAny(const Char_t *att, const Char_t *keys, Bool_t contains_all=kFALSE, Bool_t case_sensitive=kTRUE) const
virtual TObject * Last() const
TObject * FindObjectByClass(const Char_t *) const
Return (first) object in embedded list with given class.
virtual void AddBefore(const TObject *before, TObject *obj)
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 * First() 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 TObject * FindObjectByName(const Char_t *name) const
virtual TObject * At(Int_t idx) const
virtual TObject * After(const TObject *obj) const
virtual void SetCleanup(Bool_t enable=kTRUE)
static KVSeqCollection * MakeListFromFileWithClass(TFile *file, const TClass *_class)
virtual TObject * FindObjectByNumber(UInt_t num) 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 TObject * FindObject(const TObject *obj) const
virtual void Add(TObject *obj)
virtual Bool_t IsSorted() const
virtual TObject * Before(const TObject *obj) const
T * get_object(const TString &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 Int_t GetEntries() const
virtual void SetOwner(Bool_t enable=kTRUE)
TObject * FindObject(const char *name) const override
Bool_t IsSortable() const override
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 TObject * After(const TObject *obj) const=0
virtual void AddLast(TObject *obj)=0
virtual void AddBefore(const TObject *before, TObject *obj)=0
virtual TObject * Before(const TObject *obj) const=0
virtual void AddAt(TObject *obj, Int_t idx)=0
virtual TObject * Last() const=0
virtual void AddAfter(const TObject *after, TObject *obj)=0
virtual Bool_t IsSorted() const
virtual void Changed()
virtual TObject * First() const=0
virtual TObject * At(Int_t idx) const=0
virtual void AddFirst(TObject *obj)=0
void Add(TObject *obj) override
long long Long64_t
double T(double x)