]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTComponentHandler.cxx
- code version from TPC commissioning merged
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTComponentHandler.cxx
index 7dfeef0f02662fdf30cbb4a6543ee835d05bf51b..48310998ee8d9a3d01abcf7762de98208719539d 100644 (file)
@@ -5,7 +5,6 @@
  *                                                                        *
  * Authors: Matthias Richter <Matthias.Richter@ift.uib.no>                *
  *          Timm Steinbeck <timm@kip.uni-heidelberg.de>                   *
- *          Artur Szostak <artursz@iafrica.com>                           *
  *          for The ALICE Off-line Project.                               *
  *                                                                        *
  * Permission to use, copy, modify and distribute this software and its   *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-///////////////////////////////////////////////////////////////////////////////
-//                                                                           //
-// handler class for HLT analysis components                                 //
-//                                                                           //
-///////////////////////////////////////////////////////////////////////////////
+/** @file   AliHLTComponentHandler.cxx
+    @author Matthias Richter, Timm Steinbeck
+    @date   
+    @brief  Implementation of HLT component handler. */
 
-#if __GNUC__== 3
+#if __GNUC__>= 3
 using namespace std;
 #endif
 
-#include <errno.h>
-#include <string.h>
 #include <dlfcn.h>
-#include "AliL3StandardIncludes.h"
+#include "AliHLTStdIncludes.h"
 #include "AliHLTComponentHandler.h"
 #include "AliHLTComponent.h"
 #include "AliHLTDataTypes.h"
 #include "AliHLTSystem.h"
 
+/** ROOT macro for the implementation of ROOT specific class methods */
 ClassImp(AliHLTComponentHandler)
 
 AliHLTComponentHandler::AliHLTComponentHandler()
+  :
+  fComponentList(),
+  fScheduleList(),
+  fLibraryList(),
+  fEnvironment()
 {
+  memset(&fEnvironment, 0, sizeof(AliHLTComponentEnvironment));
 }
 
-
 AliHLTComponentHandler::~AliHLTComponentHandler()
 {
   UnloadLibraries();
 }
 
+int AliHLTComponentHandler::AnnounceVersion()
+{
+  int iResult=0;
+#ifdef PACKAGE_STRING
+  void HLTbaseCompileInfo( char*& date, char*& time);
+  char* date="";
+  char* time="";
+  HLTbaseCompileInfo(date, time);
+  if (!date) date="unknown";
+  if (!time) time="unknown";
+  HLTInfo("%s build on %s (%s)", PACKAGE_STRING, date, time);
+#else
+  HLTInfo("ALICE High Level Trigger (embedded AliRoot build)");
+#endif
+  return iResult;
+}
+
 Int_t AliHLTComponentHandler::RegisterComponent(AliHLTComponent* pSample)
 {
   Int_t iResult=0;
@@ -55,11 +74,11 @@ Int_t AliHLTComponentHandler::RegisterComponent(AliHLTComponent* pSample)
     if (FindComponent(pSample->GetComponentID())==NULL) {
       iResult=InsertComponent(pSample);
       if (iResult>=0) {
-       Logging(kHLTLogInfo, "BASE", "Component Handler", "component %s registered", pSample->GetComponentID());
+       HLTInfo("component %s registered", pSample->GetComponentID());
       }
     } else {
       // component already registered
-      Logging(kHLTLogInfo, "BASE", "Component Handler", "component %s already registered, skipped", pSample->GetComponentID());
+      HLTDebug("component %s already registered, skipped", pSample->GetComponentID());
       iResult=-EEXIST;
     }
   } else {
@@ -84,7 +103,7 @@ Int_t AliHLTComponentHandler::ScheduleRegister(AliHLTComponent* pSample)
   return iResult;
 }
 
-int AliHLTComponentHandler::CreateComponent(const Char_t* componentID, void* environ_param, int argc, const char** argv, AliHLTComponent*& component )
+int AliHLTComponentHandler::CreateComponent(const char* componentID, void* pEnv, int argc, const char** argv, AliHLTComponent*& component )
 {
   int iResult=0;
   if (componentID) {
@@ -92,14 +111,14 @@ int AliHLTComponentHandler::CreateComponent(const Char_t* componentID, void* env
     if (pSample!=NULL) {
       component=pSample->Spawn();
       if (component) {
-       Logging(kHLTLogDebug, "BASE", "Component Handler", "component \"%s\" created (%p)", componentID, component);
-       component->Init(&fEnvironment, environ_param, argc, argv);
+       HLTDebug("component \"%s\" created (%p)", componentID, component);
+       component->Init(&fEnvironment, pEnv, argc, argv);
       } else {
-       Logging(kHLTLogError, "BASE", "Component Handler", "can not spawn component \"%s\"", componentID);
+       HLTError("can not spawn component \"%s\"", componentID);
        iResult=-ENOENT;
       }
     } else {
-      Logging(kHLTLogWarning, "BASE", "Component Handler", "can not find component \"%s\"", componentID);
+      HLTWarning("can not find component \"%s\"", componentID);
       iResult=-ENOENT;
     }
   } else {
@@ -108,7 +127,7 @@ int AliHLTComponentHandler::CreateComponent(const Char_t* componentID, void* env
   return iResult;
 }
 
-Int_t AliHLTComponentHandler::FindComponentIndex(const Char_t* componentID)
+Int_t AliHLTComponentHandler::FindComponentIndex(const char* componentID)
 {
   Int_t iResult=0;
   if (componentID) {
@@ -127,7 +146,7 @@ Int_t AliHLTComponentHandler::FindComponentIndex(const Char_t* componentID)
   return iResult;
 }
 
-AliHLTComponent* AliHLTComponentHandler::FindComponent(const Char_t* componentID)
+AliHLTComponent* AliHLTComponentHandler::FindComponent(const char* componentID)
 {
   AliHLTComponent* pSample=NULL;
   Int_t index=FindComponentIndex(componentID);
@@ -152,13 +171,14 @@ void AliHLTComponentHandler::List() {
   vector<AliHLTComponent*>::iterator element=fComponentList.begin();
   int index=0;
   while (element!=fComponentList.end()) {
-    Logging(kHLTLogInfo, "BASE", "Component Handler", "%d. %s", index++, (*element++)->GetComponentID());
+    HLTInfo("%d. %s", index++, (*element++)->GetComponentID());
   }
 }
 
 void AliHLTComponentHandler::SetEnvironment(AliHLTComponentEnvironment* pEnv) {
   if (pEnv) {
     memcpy(&fEnvironment, pEnv, sizeof(AliHLTComponentEnvironment));
+    AliHLTLogging::Init(fEnvironment.fLoggingFunc);
   }
 }
 
@@ -170,7 +190,7 @@ int AliHLTComponentHandler::LoadLibrary( const char* libraryPath )
     AliHLTLibHandle hLib=dlopen(libraryPath, RTLD_NOW);
     if (hLib) {
       AliHLTComponent::UnsetGlobalComponentHandler();
-      Logging(kHLTLogDebug, "BASE", "Component Handler", "library %s loaded", libraryPath);
+      HLTInfo("library %s loaded", libraryPath);
       fLibraryList.push_back(hLib);
       vector<AliHLTComponent*>::iterator element=fScheduleList.begin();
       int iSize=fScheduleList.size();
@@ -182,8 +202,8 @@ int AliHLTComponentHandler::LoadLibrary( const char* libraryPath )
        fScheduleList.erase(element);
       }
     } else {
-      Logging(kHLTLogError, "BASE", "Component Handler", "can not load library %s", libraryPath);
-      Logging(kHLTLogError, "BASE", "Component Handler", "dlopen error: %s", dlerror());
+      HLTError("can not load library %s", libraryPath);
+      HLTError("dlopen error: %s", dlerror());
       iResult=-ELIBACC;
     }
   } else {