KaliVeda
Toolkit for HIC analysis
KVUniqueNameList.cpp
1 //Created by KVClassFactory on Thu Dec 3 15:49:33 2009
2 //Author: John Frankland,,,
3 
4 #include "KVUniqueNameList.h"
5 
7 
8 
9 
10 
11 
15  : fReplace(R)
16 {
17  // Default constructor
18 }
19 
20 
21 
29 
31 {
32  // Return kTRUE if 'obj' can be added to list.
33  // If fReplace==kFALSE, there must be no object in the list with
34  // same name as obj->GetName().
35  // If fReplace==kTRUE the previous object is removed from the list.
36  // If IsOwner()==kTRUE the previous object is removed AND deleted.
37  // In the latter two cases the new object can always be added (returns kTRUE)
38 
39  TObject* old_obj = FindObject(obj->GetName());
40  if (!old_obj) return kTRUE;
41  else {
42  if (fReplace) {
43  Remove(old_obj);
44  if (IsOwner()) delete old_obj;
45  return kTRUE;
46  }
47  }
48  return kFALSE;
49 }
50 
51 
bool Bool_t
constexpr Bool_t kFALSE
constexpr Bool_t kTRUE
TObject * Remove(TObject *obj) override
Remove object from list.
TObject * FindObject(const char *name) const override
Optimised list in which named objects can only be placed once.
Bool_t checkObjInList(TObject *obj)
Bool_t fReplace
if kTRUE, objects with same name are replaced
Bool_t IsOwner() const
virtual const char * GetName() const
ClassImp(TPyArg)