//______________________________________________________________________________
AliOADBContainer::AliOADBContainer() :
TNamed(),
- fArray(new TObjArray(100)),
- fDefaultList(new TList()),
+ fArray(0),
+ fDefaultList(0),
fLowerLimits(),
fUpperLimits(),
fEntries(0)
// Default constructor
}
-AliOADBContainer::AliOADBContainer(char* name) :
+AliOADBContainer::AliOADBContainer(const char* name) :
TNamed(name, "OADBContainer"),
fArray(new TObjArray(100)),
fDefaultList(new TList()),
Int_t index = HasOverlap(lower, upper);
if (index != -1) {
- AliFatal(Form("Ambiguos validity range (%5d) !\n", index));
+ AliFatal(Form("Ambiguos validity range (%5d, %5.5d-%5.5d) !\n", index,lower,upper));
return;
}
//
void AliOADBContainer::UpdateObject(Int_t idx, TObject* obj, Int_t lower, Int_t upper)
{
//
- // Append a new object to the list
-
+ // Update an existing object, at a given position
+
// Check that index is inside range
if (idx < 0 || idx >= fEntries)
{
return;
}
//
+ // Remove the old object and reset the range
+ // TObject* obj2 =
+ fArray->RemoveAt(idx);
+ // don't delete it: if you are updating it may be pointing to the same location of obj...
+ // delete obj2;
+ fLowerLimits[idx] = -1;
+ fUpperLimits[idx] = -1;
// Check that there is no overlap with existing run ranges
Int_t index = HasOverlap(lower, upper);
if (index != -1) {
- AliFatal(Form("Ambiguos validity range (%5d) !\n", index));
+ AliFatal(Form("Ambiguos validity range (%5d, %5.5d-%5.5d) !\n", index,lower,upper));
return;
}
//
- // Add object
+ // Add object at the same position
+ //printf("idx %d obj %llx\n", idx, obj);
fLowerLimits[idx] = lower;
fUpperLimits[idx] = upper;
fArray->AddAt(obj, idx);
+
}
{
//
// Find the index for a given run
+
Int_t found = 0;
Int_t index = -1;
for (Int_t i = 0; i < fEntries; i++)
return index;
}
-TObject* AliOADBContainer::GetObject(Int_t run, char* def) const
+TObject* AliOADBContainer::GetObject(Int_t run, const char* def) const
{
// Return object for given run or default if not found
TObject* obj = 0;
return (fArray->At(run));
}
-void AliOADBContainer::WriteToFile(char* fname) const
+void AliOADBContainer::WriteToFile(const char* fname) const
{
//
// Write object to file
- TFile* f = new TFile(fname, "recreate");
+ TFile* f = new TFile(fname, "update");
Write();
+ f->Purge();
f->Close();
}
-Int_t AliOADBContainer::InitFromFile(char* fname, char* key)
+Int_t AliOADBContainer::InitFromFile(const char* fname, const char* key)
{
//
// Initialize object from file
AliError("Object not found in file \n");
return 1;
}
-
+
+ SetName(cont->GetName());
+ SetTitle(cont->GetTitle());
+
fEntries = cont->GetNumberOfEntries();
fLowerLimits.Set(fEntries);
fUpperLimits.Set(fEntries);
fUpperLimits[i] = cont->UpperLimit(i);
fArray->AddAt(cont->GetObjectByIndex(i), i);
}
-
+ if (!fDefaultList) fDefaultList = new TList();
TIter next(cont->GetDefaultList());
TObject* obj;
while((obj = next())) fDefaultList->Add(obj);
{
//
// List Objects
+ printf("Entries %d\n", fEntries);
+
for (Int_t i = 0; i < fEntries; i++) {
printf("Lower %5d Upper %5d \n", fLowerLimits[i], fUpperLimits[i]);
(fArray->At(i))->Dump();
}
-Int_t AliOADBContainer::HasOverlap(Int_t lower, Int_t upper)
+Int_t AliOADBContainer::HasOverlap(Int_t lower, Int_t upper) const
{
//
// Checks for overlpapping validity regions