KaliVeda  1.12/06
Heavy-Ion Analysis Toolkit
KVUniqueNameList.cpp
Go to the documentation of this file.
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 
24 
26 {
27  // Destructor
28 }
29 
30 
31 
39 
41 {
42  // Return kTRUE if 'obj' can be added to list.
43  // If fReplace==kFALSE, there must be no object in the list with
44  // same name as obj->GetName().
45  // If fReplace==kTRUE the previous object is removed from the list.
46  // If IsOwner()==kTRUE the previous object is removed AND deleted.
47  // In the latter two cases the new object can always be added (returns kTRUE)
48 
49  TObject* old_obj = FindObject(obj->GetName());
50  if (!old_obj) return kTRUE;
51  else {
52  if (fReplace) {
53  Remove(old_obj);
54  if (IsOwner()) delete old_obj;
55  return kTRUE;
56  }
57  }
58  return kFALSE;
59 }
60 
61 
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
const Bool_t kFALSE
bool Bool_t
const Bool_t kTRUE
virtual TObject * Remove(TObject *obj)
Remove object from list.
virtual TObject * FindObject(const char *name) const
Optimised list in which named objects can only be placed once.
Bool_t checkObjInList(TObject *obj)
virtual ~KVUniqueNameList()
Destructor.
Bool_t fReplace
if kTRUE, objects with same name are replaced
Bool_t IsOwner() const
virtual const char * GetName() const