New functionality added in AliCDBManager: the activated default and specific
authoracolla <acolla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 24 Oct 2007 10:07:06 +0000 (10:07 +0000)
committeracolla <acolla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 24 Oct 2007 10:07:06 +0000 (10:07 +0000)
storages and the retrieved objects' Ids are saved in a TMap and a TList
respectively. The storage map and the list of retrieved Ids can be got with:

const TMap* GetStorageMap() const {return fStorageMap;}
const TList* GetRetrievedIds() const {return fIds;}

in AliCDBId: added Print function

STEER/AliCDBId.cxx
STEER/AliCDBId.h
STEER/AliCDBManager.cxx
STEER/AliCDBManager.h

index a5053da..10e0510 100644 (file)
@@ -22,6 +22,7 @@
 /////////////////////////////////////////////////////////////////////
 
 #include "AliCDBId.h"
+#include <Riostream.h>
 
 ClassImp(AliCDBId)
 
@@ -121,3 +122,11 @@ TString AliCDBId::ToString() const {
        if(GetSubVersion() >= 0) result += Form("_s%d", GetSubVersion());
        return result;
 }
+
+//_____________________________________________________________________________
+void AliCDBId::Print(Option_t* /*option*/) const {
+// Prints ToString()
+
+       cout << ToString().Data() << endl;
+
+}
index 54ae14a..549bd52 100644 (file)
@@ -75,6 +75,7 @@ public:
        virtual Bool_t IsEqual(const TObject *obj) const;
 
        TString ToString() const;
+       void Print(Option_t* option="") const;
 
 private:
 
index e0fd144..51d38d8 100644 (file)
@@ -82,24 +82,31 @@ void AliCDBManager::Destroy() {
 //_____________________________________________________________________________
 AliCDBManager::AliCDBManager():
   TObject(),
-  fCondParam(0),
-  fRefParam(0),
   fFactories(),
   fActiveStorages(),
   fSpecificStorages(),
+  fEntryCache(),
+  fIds(0),
+  fStorageMap(0),
+  fShortLived(0),
   fDefaultStorage(NULL),
   fRemoteStorage(NULL),
   fDrainStorage(NULL),
-  fEntryCache(),
-  fCache(kTRUE),
+  fCondParam(0),
+  fRefParam(0),
   fRun(-1),
-  fShortLived(0)
+  fCache(kTRUE)
 {
 // default constuctor
        fFactories.SetOwner(1);
        fActiveStorages.SetOwner(1);
        fSpecificStorages.SetOwner(1);
        fEntryCache.SetOwner(1);
+
+       fStorageMap = new TMap();
+       fStorageMap->SetOwner(1);
+       fIds = new TList();
+       fIds->SetOwner(1);
 }
 
 //_____________________________________________________________________________
@@ -111,6 +118,8 @@ AliCDBManager::~AliCDBManager() {
        fDrainStorage = 0x0;
        fDefaultStorage = 0x0;
        fRemoteStorage = 0x0;
+       delete fStorageMap; fStorageMap = 0;
+       delete fIds; fIds = 0;
        delete fCondParam;
        delete fRefParam;
        delete fShortLived; fShortLived = 0x0;
@@ -135,7 +144,7 @@ void AliCDBManager::RegisterFactory(AliCDBStorageFactory* factory) {
 
 //_____________________________________________________________________________
 Bool_t AliCDBManager::HasStorage(const char* dbString) const {
-// check if dbString is a URI valid for one of the registered factories 
+// check if dbString is a URI valid for one of the registered factories
 
        TIter iter(&fFactories);
 
@@ -286,6 +295,11 @@ void AliCDBManager::SetDefaultStorage(const char* dbString) {
                AliWarning("Existing default storage replaced: clearing cache!");
                ClearCache();
        }
+
+       if (fStorageMap->Contains("default")) {
+               delete fStorageMap->Remove(fStorageMap->GetValue("default"));
+       }
+       fStorageMap->Add(new TObjString("default"), new TObjString(fDefaultStorage->GetURI()));
 }
 
 //_____________________________________________________________________________
@@ -300,6 +314,11 @@ void AliCDBManager::SetDefaultStorage(const AliCDBParam* param) {
                AliWarning("Existing default storage replaced: clearing cache!");
                ClearCache();
        }
+
+       if (fStorageMap->Contains("default")) {
+               delete fStorageMap->Remove(fStorageMap->GetValue("default"));
+       }
+       fStorageMap->Add(new TObjString("default"), new TObjString(fDefaultStorage->GetURI()));
 }
 
 //_____________________________________________________________________________
@@ -314,6 +333,11 @@ void AliCDBManager::SetDefaultStorage(AliCDBStorage* storage) {
                AliWarning("Existing default storage replaced: clearing cache!");
                ClearCache();
        }
+
+       if (fStorageMap->Contains("default")) {
+               delete fStorageMap->Remove(fStorageMap->GetValue("default"));
+       }
+       fStorageMap->Add(new TObjString("default"), new TObjString(fDefaultStorage->GetURI()));
 }
 //_____________________________________________________________________________
 void AliCDBManager::SetRemoteStorage(const char* dbString) {
@@ -381,6 +405,12 @@ void AliCDBManager::SetSpecificStorage(const char* calibType, AliCDBParam* param
        GetStorage(param);
 
        fSpecificStorages.Add(objCalibType, param->CloneParam());
+
+       if(fStorageMap->Contains(objCalibType)){
+               delete fStorageMap->Remove(objCalibType);
+       }
+       fStorageMap->Add(objCalibType->Clone(), new TObjString(param->GetURI()));
+
 }
 
 //_____________________________________________________________________________
@@ -513,6 +543,11 @@ AliCDBEntry* AliCDBManager::Get(const AliCDBId& query) {
                CacheEntry(query.GetPath(), entry);
        }
 
+       if(entry && !fIds->Contains(&entry->GetId())){
+               fIds->Add(entry->GetId().Clone());
+       }
+
+
        return entry;
 
 }
@@ -711,15 +746,19 @@ TList* AliCDBManager::GetAll(const AliCDBId& query) {
        }
 
        // caching entries
-       if(fCache && (query.GetFirstRun() == fRun)){
+       TIter iter(result);
+       AliCDBEntry* entry=0;
+       while((entry = dynamic_cast<AliCDBEntry*> (iter.Next()))){
 
-               TIter iter(result);
-               AliCDBEntry* entry=0;
-               while((entry = dynamic_cast<AliCDBEntry*> (iter.Next()))){
+               if(!fIds->Contains(&entry->GetId())){
+                       fIds->Add(entry->GetId().Clone());
+               }
+               if(fCache && (query.GetFirstRun() == fRun)){
                        CacheEntry(entry->GetId().GetPath(), entry);
                }
        }
 
+
        return result;
 }
 
index a5f72a0..418b239 100644 (file)
@@ -42,6 +42,9 @@ class AliCDBManager: public TObject {
 
        TList* GetActiveStorages();
 
+       const TMap* GetStorageMap() const {return fStorageMap;}
+       const TList* GetRetrievedIds() const {return fIds;}
+
        void SetDefaultStorage(const char* dbString);
        void SetDefaultStorage(const AliCDBParam* param);
        void SetDefaultStorage(AliCDBStorage *storage);
@@ -122,8 +125,6 @@ class AliCDBManager: public TObject {
 
        static TString fgkCondUri;      // URI of the Conditions data base folder
        static TString fgkRefUri;       // URI of the Reference data base folder
-       AliCDBParam* fCondParam;        // Conditions data storage parameters
-       AliCDBParam* fRefParam;         // Reference data storage parameters
 
        AliCDBManager();
        AliCDBManager(const AliCDBManager & source);
@@ -146,17 +147,22 @@ class AliCDBManager: public TObject {
        TList fFactories;               //! list of registered storage factories
        TMap fActiveStorages;           //! list of active storages
        TMap fSpecificStorages;         //! list of detector-specific storages
+       TMap fEntryCache;               //! cache of the retrieved objects
+
+       TList* fIds;            //! List of the retrieved object Id's (to be streamed to file)
+       TMap* fStorageMap;      //! list of storages (to be streamed to file)
+       TList* fShortLived;     //! List of short lived objects
 
        AliCDBStorage *fDefaultStorage; //! pointer to default storage
        AliCDBStorage *fRemoteStorage;  //! pointer to remote storage
        AliCDBStorage *fDrainStorage;   //! pointer to drain storage
 
-       TMap fEntryCache;       //! cache of the retrieved objects
+       AliCDBParam* fCondParam;        // Conditions data storage parameters
+       AliCDBParam* fRefParam;         // Reference data storage parameters
 
+       Int_t fRun;                     //! The run number
        Bool_t fCache;                  //! The cache flag
-       Int_t fRun;                     //! The run number
 
-       TList* fShortLived;     //! List of short lived objects
 
        ClassDef(AliCDBManager, 0);
 };