#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)
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);
Int_t AliHLTComponentHandler::RegisterComponent(AliHLTComponent* pSample)
{
+ // see header file for class documentation
Int_t iResult=0;
if (pSample) {
if (FindComponent(pSample->GetComponentID())==NULL) {
int AliHLTComponentHandler::DeregisterComponent( const char* componentID )
{
+ // see header file for class documentation
int iResult=0;
if (componentID) {
} else {
Int_t AliHLTComponentHandler::ScheduleRegister(AliHLTComponent* pSample)
{
+ // see header file for class documentation
Int_t iResult=0;
if (pSample) {
fScheduleList.push_back(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);
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;
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();
AliHLTComponent* AliHLTComponentHandler::FindComponent(const char* componentID)
{
+ // see header file for class documentation
AliHLTComponent* pSample=NULL;
Int_t index=FindComponentIndex(componentID);
if (index>=0) {
Int_t AliHLTComponentHandler::InsertComponent(AliHLTComponent* pSample)
{
+ // see header file for class documentation
Int_t iResult=0;
if (pSample!=NULL) {
fComponentList.push_back(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()) {
}
}
-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);
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 {
int AliHLTComponentHandler::UnloadLibrary( const char* libraryPath )
{
+ // see header file for class documentation
int iResult=0;
if (libraryPath) {
} else {
int AliHLTComponentHandler::UnloadLibraries()
{
+ // see header file for class documentation
int iResult=0;
vector<AliHLTLibHandle>::iterator element=fLibraryList.begin();
while (element!=fLibraryList.end()) {
}
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;
+}