]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/BASE/AliHLTComponentHandler.cxx
obsolete method removed from AliHLTLogging
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTComponentHandler.cxx
index a2786b0e090ddfd8df444d5ca2c8f9199e40bcc3..26f42f4a8ab8dd30e6310b8105f91922ebd6eb9e 100644 (file)
@@ -37,6 +37,12 @@ using namespace std;
 #include "AliHLTDataTypes.h"
 #include "AliHLTSystem.h"
 
+// the standard components
+// #include "AliHLTFilePublisher.h"
+#include "AliHLTFileWriter.h"
+// #include "AliHLTRootFilePublisherComponent.h"
+// #include "AliHLTRootFileWriterComponent.h"
+
 /** ROOT macro for the implementation of ROOT specific class methods */
 ClassImp(AliHLTComponentHandler)
 
@@ -45,18 +51,51 @@ AliHLTComponentHandler::AliHLTComponentHandler()
   fComponentList(),
   fScheduleList(),
   fLibraryList(),
-  fEnvironment()
+  fEnvironment(),
+  fStandardList()
 {
+  // see header file for class documentation
+  // or
+  // refer to README to build package
+  // or
+  // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
   memset(&fEnvironment, 0, sizeof(AliHLTComponentEnvironment));
+  AddStandardComponents();
+}
+
+AliHLTComponentHandler::AliHLTComponentHandler(AliHLTComponentEnvironment* pEnv)
+  :
+  fComponentList(),
+  fScheduleList(),
+  fLibraryList(),
+  fEnvironment(),
+  fStandardList()
+{
+  // see header file for class documentation
+  if (pEnv) {
+    memcpy(&fEnvironment, pEnv, sizeof(AliHLTComponentEnvironment));
+    if (pEnv->fLoggingFunc) {
+      // the AliHLTLogging::Init method also sets the stream output
+      // and notification handler to AliLog. This should only be done
+      // if the logging environment contains a logging function
+      // for redirection
+      AliHLTLogging::Init(pEnv->fLoggingFunc);
+    }
+  }  else
+    memset(&fEnvironment, 0, sizeof(AliHLTComponentEnvironment));
+  AddStandardComponents();
 }
 
 AliHLTComponentHandler::~AliHLTComponentHandler()
 {
+  // see header file for class documentation
   UnloadLibraries();
+  DeleteStandardComponents();
 }
 
 int AliHLTComponentHandler::AnnounceVersion()
 {
+  // see header file for class documentation
   int iResult=0;
 #ifdef PACKAGE_STRING
   void HLTbaseCompileInfo( char*& date, char*& time);
@@ -74,6 +113,7 @@ int AliHLTComponentHandler::AnnounceVersion()
 
 Int_t AliHLTComponentHandler::RegisterComponent(AliHLTComponent* pSample)
 {
+  // see header file for class documentation
   Int_t iResult=0;
   if (pSample) {
     if (FindComponent(pSample->GetComponentID())==NULL) {
@@ -94,6 +134,7 @@ Int_t AliHLTComponentHandler::RegisterComponent(AliHLTComponent* pSample)
 
 int AliHLTComponentHandler::DeregisterComponent( const char* componentID )
 {
+  // see header file for class documentation
   int iResult=0;
   if (componentID) {
   } else {
@@ -104,6 +145,7 @@ int AliHLTComponentHandler::DeregisterComponent( const char* componentID )
 
 Int_t AliHLTComponentHandler::ScheduleRegister(AliHLTComponent* pSample)
 {
+  // see header file for class documentation
   Int_t iResult=0;
   if (pSample) {
     fScheduleList.push_back(pSample);
@@ -113,8 +155,9 @@ Int_t AliHLTComponentHandler::ScheduleRegister(AliHLTComponent* pSample)
   return iResult;
 }
 
-int AliHLTComponentHandler::CreateComponent(const char* componentID, void* pEnv, int argc, const char** argv, AliHLTComponent*& component )
+int AliHLTComponentHandler::CreateComponent(const char* componentID, void* pEnvParam, int argc, const char** argv, AliHLTComponent*& component )
 {
+  // see header file for class documentation
   int iResult=0;
   if (componentID) {
     AliHLTComponent* pSample=FindComponent(componentID);
@@ -122,7 +165,7 @@ int AliHLTComponentHandler::CreateComponent(const char* componentID, void* pEnv,
       component=pSample->Spawn();
       if (component) {
        HLTDebug("component \"%s\" created (%p)", componentID, component);
-       if ((iResult=component->Init(&fEnvironment, pEnv, argc, argv))!=0) {
+       if ((iResult=component->Init(&fEnvironment, pEnvParam, argc, argv))!=0) {
          HLTError("Initialization of component \"%s\" failed with error %d", componentID, iResult);
          delete component;
          component=NULL;
@@ -143,6 +186,7 @@ int AliHLTComponentHandler::CreateComponent(const char* componentID, void* pEnv,
 
 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();
@@ -162,6 +206,7 @@ Int_t AliHLTComponentHandler::FindComponentIndex(const char* componentID)
 
 AliHLTComponent* AliHLTComponentHandler::FindComponent(const char* componentID)
 {
+  // see header file for class documentation
   AliHLTComponent* pSample=NULL;
   Int_t index=FindComponentIndex(componentID);
   if (index>=0) {
@@ -172,6 +217,7 @@ AliHLTComponent* AliHLTComponentHandler::FindComponent(const char* componentID)
 
 Int_t AliHLTComponentHandler::InsertComponent(AliHLTComponent* pSample)
 {
+  // see header file for class documentation
   Int_t iResult=0;
   if (pSample!=NULL) {
     fComponentList.push_back(pSample);
@@ -181,7 +227,9 @@ Int_t AliHLTComponentHandler::InsertComponent(AliHLTComponent* pSample)
   return iResult;
 }
 
-void AliHLTComponentHandler::List() {
+void AliHLTComponentHandler::List() 
+{
+  // see header file for class documentation
   vector<AliHLTComponent*>::iterator element=fComponentList.begin();
   int index=0;
   while (element!=fComponentList.end()) {
@@ -189,15 +237,24 @@ void AliHLTComponentHandler::List() {
   }
 }
 
-void AliHLTComponentHandler::SetEnvironment(AliHLTComponentEnvironment* pEnv) {
+void AliHLTComponentHandler::SetEnvironment(AliHLTComponentEnvironment* pEnv) 
+{
+  // see header file for class documentation
   if (pEnv) {
     memcpy(&fEnvironment, pEnv, sizeof(AliHLTComponentEnvironment));
-    AliHLTLogging::Init(fEnvironment.fLoggingFunc);
+    if (fEnvironment.fLoggingFunc) {
+      // the AliHLTLogging::Init method also sets the stream output
+      // and notification handler to AliLog. This should only be done
+      // if the logging environment contains a logging function
+      // for redirection
+      AliHLTLogging::Init(fEnvironment.fLoggingFunc);
+    }
   }
 }
 
 int AliHLTComponentHandler::LoadLibrary( const char* libraryPath )
 {
+  // see header file for class documentation
   int iResult=0;
   if (libraryPath) {
     AliHLTComponent::SetGlobalComponentHandler(this);
@@ -215,21 +272,17 @@ int AliHLTComponentHandler::LoadLibrary( const char* libraryPath )
     if (hLib) {
       HLTInfo("library %s loaded", libraryPath);
       fLibraryList.push_back(hLib);
-      vector<AliHLTComponent*>::iterator element=fScheduleList.begin();
-      int iSize=fScheduleList.size();
-      int iLocalResult=0;
-      while (iSize-- > 0) {
-       element=fScheduleList.begin();
-       iLocalResult=RegisterComponent(*element);
-       if (iResult==0) iResult=iLocalResult;
-       fScheduleList.erase(element);
-      }
+      iResult=RegisterScheduledComponents();
     } else {
       HLTError("can not load library %s", libraryPath);
 #ifdef HAVE_DLFCN_H
       HLTError("dlopen error: %s", dlerror());
 #endif //HAVE_DLFCN_H
+#ifdef __APPLE__
+      iResult=-EFTYPE;
+#else
       iResult=-ELIBACC;
+#endif
     }
     AliHLTComponent::UnsetGlobalComponentHandler();
   } else {
@@ -240,6 +293,7 @@ int AliHLTComponentHandler::LoadLibrary( const char* libraryPath )
 
 int AliHLTComponentHandler::UnloadLibrary( const char* libraryPath )
 {
+  // see header file for class documentation
   int iResult=0;
   if (libraryPath) {
   } else {
@@ -250,6 +304,7 @@ int AliHLTComponentHandler::UnloadLibrary( const char* libraryPath )
 
 int AliHLTComponentHandler::UnloadLibraries()
 {
+  // see header file for class documentation
   int iResult=0;
   vector<AliHLTLibHandle>::iterator element=fLibraryList.begin();
   while (element!=fLibraryList.end()) {
@@ -264,3 +319,46 @@ int AliHLTComponentHandler::UnloadLibraries()
   }
   return iResult;
 }
+
+int AliHLTComponentHandler::AddStandardComponents()
+{
+  // see header file for class documentation
+  int iResult=0;
+  AliHLTComponent::SetGlobalComponentHandler(this);
+//   fStandardList.push_back(new AliHLTFilePublisher);
+  fStandardList.push_back(new AliHLTFileWriter);
+//   fStandardList.push_back(new AliHLTRootFilePublisherComponent);
+//   fStandardList.push_back(new AliHLTRootFileWriterComponent);
+  AliHLTComponent::UnsetGlobalComponentHandler();
+  iResult=RegisterScheduledComponents();
+  return iResult;
+}
+
+int AliHLTComponentHandler::RegisterScheduledComponents()
+{
+  // see header file for class documentation
+  int iResult=0;
+  vector<AliHLTComponent*>::iterator element=fScheduleList.begin();
+  int iLocalResult=0;
+  while (element!=fScheduleList.end()) {
+    iLocalResult=RegisterComponent(*element);
+    if (iResult==0) iResult=iLocalResult;
+    fScheduleList.erase(element);
+    element=fScheduleList.begin();
+  }
+  return iResult;
+}
+
+int AliHLTComponentHandler::DeleteStandardComponents()
+{
+  // see header file for class documentation
+  int iResult=0;
+  vector<AliHLTComponent*>::iterator element=fStandardList.begin();
+  while (element!=fStandardList.end()) {
+    DeregisterComponent((*element)->GetComponentID());
+    delete(*element);
+    fStandardList.erase(element);
+    element=fStandardList.begin();
+  }
+  return iResult;
+}