X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=HLT%2FBASE%2FAliHLTComponentHandler.cxx;h=26f42f4a8ab8dd30e6310b8105f91922ebd6eb9e;hb=88ea49c8fde363be305beb91b20d66474ab3c174;hp=3f060e2fcc858411be7ecd5b5161f9bcd4ed0e83;hpb=2d7ff71057caa5cb41ef394864420f2934cf9c0d;p=u%2Fmrichter%2FAliRoot.git diff --git a/HLT/BASE/AliHLTComponentHandler.cxx b/HLT/BASE/AliHLTComponentHandler.cxx index 3f060e2fcc8..26f42f4a8ab 100644 --- a/HLT/BASE/AliHLTComponentHandler.cxx +++ b/HLT/BASE/AliHLTComponentHandler.cxx @@ -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); @@ -115,6 +157,7 @@ Int_t AliHLTComponentHandler::ScheduleRegister(AliHLTComponent* pSample) 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); @@ -143,6 +186,7 @@ int AliHLTComponentHandler::CreateComponent(const char* componentID, void* pEnvP Int_t AliHLTComponentHandler::FindComponentIndex(const char* componentID) { + // see header file for class documentation Int_t iResult=0; if (componentID) { vector::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::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,15 +272,7 @@ int AliHLTComponentHandler::LoadLibrary( const char* libraryPath ) if (hLib) { HLTInfo("library %s loaded", libraryPath); fLibraryList.push_back(hLib); - vector::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 @@ -244,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 { @@ -254,6 +304,7 @@ int AliHLTComponentHandler::UnloadLibrary( const char* libraryPath ) int AliHLTComponentHandler::UnloadLibraries() { + // see header file for class documentation int iResult=0; vector::iterator element=fLibraryList.begin(); while (element!=fLibraryList.end()) { @@ -268,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::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::iterator element=fStandardList.begin(); + while (element!=fStandardList.end()) { + DeregisterComponent((*element)->GetComponentID()); + delete(*element); + fStandardList.erase(element); + element=fStandardList.begin(); + } + return iResult; +}