]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTComponentHandler.cxx
Minor cleanup of code.
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTComponentHandler.cxx
index 1d2ac5fc3c5b58343f034f643e9e2039ca58f38e..c26cc14341108692bfe5c57c1fb2f63b9c24628e 100644 (file)
     @date   
     @brief  Implementation of HLT component handler. */
 
+// see header file for class documentation
+// or
+// refer to README to build package
+// or
+// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
+
 #if __GNUC__>= 3
 using namespace std;
 #endif
@@ -48,7 +54,8 @@ AliHLTComponentHandler::AliHLTComponentHandler()
   fScheduleList(),
   fLibraryList(),
   fEnvironment(),
-  fOwnedComponents()
+  fOwnedComponents(),
+  fLibraryMode(kDynamic)
 {
   // see header file for class documentation
   // or
@@ -66,7 +73,8 @@ AliHLTComponentHandler::AliHLTComponentHandler(AliHLTComponentEnvironment* pEnv)
   fScheduleList(),
   fLibraryList(),
   fEnvironment(),
-  fOwnedComponents()
+  fOwnedComponents(),
+  fLibraryMode(kDynamic)
 {
   // see header file for class documentation
   if (pEnv) {
@@ -108,9 +116,9 @@ int AliHLTComponentHandler::AnnounceVersion()
   HLTbaseCompileInfo(date, time);
   if (!date) date="unknown";
   if (!time) time="unknown";
-  HLTInfo("%s build on %s (%s)", PACKAGE_STRING, date, time);
+  HLTImportant("%s build on %s (%s)", PACKAGE_STRING, date, time);
 #else
-  HLTInfo("ALICE High Level Trigger build on %s (%s) (embedded AliRoot build)", __DATE__, __TIME__);
+  HLTImportant("ALICE High Level Trigger build on %s (%s) (embedded AliRoot build)", __DATE__, __TIME__);
 #endif
   return iResult;
 }
@@ -173,7 +181,7 @@ Int_t AliHLTComponentHandler::ScheduleRegister(AliHLTComponent* pSample)
   return iResult;
 }
 
-int AliHLTComponentHandler::CreateComponent(const char* componentID, void* pEnvParam, int argc, const char** argv, AliHLTComponent*& component )
+int AliHLTComponentHandler::CreateComponent(const char* componentID, void* pEnvParam, int argc, const char** argv, AliHLTComponent*& component, const char* cdbPath )
 {
   // see header file for class documentation
   int iResult=0;
@@ -183,6 +191,9 @@ int AliHLTComponentHandler::CreateComponent(const char* componentID, void* pEnvP
       component=pSample->Spawn();
       if (component) {
        HLTDebug("component \"%s\" created (%p)", componentID, component);
+       if (cdbPath) {
+         component->InitCDB(cdbPath, this);
+       }
        if ((iResult=component->Init(&fEnvironment, pEnvParam, argc, argv))!=0) {
          HLTError("Initialization of component \"%s\" failed with error %d", componentID, iResult);
          delete component;
@@ -207,7 +218,7 @@ Int_t AliHLTComponentHandler::FindComponentIndex(const char* componentID)
   // see header file for class documentation
   Int_t iResult=0;
   if (componentID) {
-    vector<AliHLTComponent*>::iterator element=fComponentList.begin();
+    AliHLTComponentPList::iterator element=fComponentList.begin();
     while (element!=fComponentList.end() && iResult>=0) {
       if (strcmp(componentID, (*element)->GetComponentID())==0) {
        break;
@@ -248,7 +259,7 @@ Int_t AliHLTComponentHandler::InsertComponent(AliHLTComponent* pSample)
 void AliHLTComponentHandler::List() 
 {
   // see header file for class documentation
-  vector<AliHLTComponent*>::iterator element=fComponentList.begin();
+  AliHLTComponentPList::iterator element=fComponentList.begin();
   int index=0;
   while (element!=fComponentList.end()) {
     HLTInfo("%d. %s", index++, (*element++)->GetComponentID());
@@ -308,19 +319,25 @@ int AliHLTComponentHandler::LoadLibrary( const char* libraryPath, int bActivateA
     const char* loadtype="";
 #ifdef HAVE_DLFCN_H
     // use interface to the dynamic linking loader
-    try {
+
+    // exeption does not help in Root context, the Root exeption
+    // handler always catches the exeption before. Have to find out
+    // how exeptions can be used in Root
+    /*try*/ {
       hLib.fHandle=dlopen(libraryPath, RTLD_NOW);
       loadtype="dlopen";
     }
+    /*
     catch (...) {
       // error message printed further down
       loadtype="dlopen exeption";
     }
+    */
 #else
     // use ROOT dynamic loader
     // check if the library was already loaded, as Load returns
     // 'failure' if the library was already loaded
-    try {
+    /*try*/ {
     AliHLTLibHandle* pLib=FindLibrary(libraryPath);
     if (pLib) {
        int* pRootHandle=reinterpret_cast<int*>(pLib->fHandle);
@@ -329,7 +346,7 @@ int AliHLTComponentHandler::LoadLibrary( const char* libraryPath, int bActivateA
        hLib.fHandle=pRootHandle;
     }
     
-    if (hLib.fHandle==NULL && gSystem->Load(libraryPath)==0) {
+    if (hLib.fHandle==NULL && gSystem->Load(libraryPath)>=0) {
       int* pRootHandle=new int;
       if (pRootHandle) *pRootHandle=1;
       hLib.fHandle=pRootHandle;
@@ -337,16 +354,18 @@ int AliHLTComponentHandler::LoadLibrary( const char* libraryPath, int bActivateA
     }
     loadtype="gSystem";
     }
+    /*
     catch (...) {
       // error message printed further down
       loadtype="gSystem exeption";
     }
+    */
 #endif //HAVE_DLFCN_H
     if (hLib.fHandle!=NULL) {
       // create TString object to store library path and use pointer as handle 
       hLib.fName=new TString(libraryPath);
       hLib.fMode=fLibraryMode;
-      HLTInfo("library %s loaded (%s%s)", libraryPath, hLib.fMode==kStatic?"persistent, ":"", loadtype);
+      HLTImportant("library %s loaded (%s%s)", libraryPath, hLib.fMode==kStatic?"persistent, ":"", loadtype);
       fLibraryList.insert(fLibraryList.begin(), hLib);
       typedef void (*CompileInfo)( char*& date, char*& time);
       CompileInfo fctInfo=(CompileInfo)FindSymbol(libraryPath, "CompileInfo");
@@ -356,9 +375,9 @@ int AliHLTComponentHandler::LoadLibrary( const char* libraryPath, int bActivateA
        (*fctInfo)(date, time);
        if (!date) date="unknown";
        if (!time) time="unknown";
-       HLTInfo("build on %s (%s)", date, time);
+       HLTImportant("build on %s (%s)", date, time);
       } else {
-       HLTInfo("no build info available (possible AliRoot embedded build)");
+       HLTImportant("no build info available (possible AliRoot embedded build)");
       }
 
       // static registration of components when library is loaded
@@ -418,12 +437,18 @@ int AliHLTComponentHandler::UnloadLibrary(AliHLTComponentHandler::AliHLTLibHandl
   TString* pName=reinterpret_cast<TString*>(handle.fName);
   if (handle.fMode!=kStatic) {
 #ifdef HAVE_DLFCN_H
-  try {
+  // exeption does not help in Root context, the Root exeption
+  // handler always catches the exeption before. Have to find out
+  // how exeptions can be used in Root
+
+  /*try*/ {
     dlclose(handle.fHandle);
   }
+  /*
   catch (...) {
     HLTError("exeption caught during dlclose of library %s", pName!=NULL?pName->Data():"");
   }
+  */
 #else
   int* pCount=reinterpret_cast<int*>(handle.fHandle);
   if (--(*pCount)==0) {
@@ -526,7 +551,7 @@ int AliHLTComponentHandler::RegisterScheduledComponents()
 {
   // see header file for class documentation
   int iResult=0;
-  vector<AliHLTComponent*>::iterator element=fScheduleList.begin();
+  AliHLTComponentPList::iterator element=fScheduleList.begin();
   int iLocalResult=0;
   while (element!=fScheduleList.end()) {
     iLocalResult=RegisterComponent(*element);
@@ -565,15 +590,20 @@ int AliHLTComponentHandler::DeleteOwnedComponents()
 {
   // see header file for class documentation
   int iResult=0;
-  vector<AliHLTComponent*>::iterator element=fOwnedComponents.begin();
+  AliHLTComponentPList::iterator element=fOwnedComponents.begin();
   while (element!=fOwnedComponents.end()) {
     //DeregisterComponent((*element)->GetComponentID());
-    try {
+    // exeption does not help in Root context, the Root exeption
+    // handler always catches the exeption before. Have to find out
+    // how exeptions can be used in Root
+    /*try*/ {
       delete *element;
     }
+    /*
     catch (...) {
       HLTError("delete managed sample %p", *element);
     }
+    */
     fOwnedComponents.erase(element);
     element=fOwnedComponents.begin();
   }