--- /dev/null
+// $Id$
+
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * 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 *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+///////////////////////////////////////////////////////////////////////////////
+// //
+// base class for HLT components //
+// //
+///////////////////////////////////////////////////////////////////////////////
+
+#if __GNUC__== 3
+using namespace std;
+#endif
+
+#include "AliHLTComponent.h"
+#include "AliHLTComponentHandler.h"
+#include <string.h>
+#include "AliHLTSystem.h"
+
+ClassImp(AliHLTComponent)
+
+AliHLTComponentHandler* AliHLTComponent::fpComponentHandler=NULL;
+
+AliHLTComponent::AliHLTComponent()
+{
+ memset(&fEnvironment, 0, sizeof(AliHLTComponentEnvironment));
+ if (fpComponentHandler)
+ fpComponentHandler->ScheduleRegister(this);
+}
+
+AliHLTComponent::~AliHLTComponent()
+{
+}
+
+int AliHLTComponent::Init( AliHLTComponentEnvironment* environ, void* environ_param, int argc, const char** argv )
+{
+ int iResult=0;
+ if (environ) {
+ memcpy(&fEnvironment, environ, sizeof(AliHLTComponentEnvironment));
+ fEnvironment.fParam=environ_param;
+ }
+ iResult=DoInit(argc, argv);
+ return iResult;
+}
+
+int AliHLTComponent::Deinit()
+{
+ int iResult=0;
+ iResult=DoDeinit();
+ return iResult;
+}
+
+int AliHLTComponent::Logging( AliHLTComponent_LogSeverity severity, const char* origin, const char* keyword, const char* format, ... ) {
+ if (fEnvironment.fLoggingFunc) {
+ va_list args;
+ va_start(args, format);
+ return (*fEnvironment.fLoggingFunc)(fEnvironment.fParam, severity, origin, keyword, AliHLTSystem::BuildLogString(format, args ));
+ }
+ return -ENOSYS;
+}
--- /dev/null
+// @(#) $Id$
+
+#ifndef ALIHLTCOMPONENT_H
+#define ALIHLTCOMPONENT_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+/* AliHLTComponent
+ base class for HLT components
+ */
+
+#include <errno.h>
+#include "AliHLTDataTypes.h"
+#include "TObject.h"
+
+class AliHLTComponentHandler;
+
+class AliHLTComponent {
+ public:
+ AliHLTComponent();
+ virtual ~AliHLTComponent();
+
+ enum TComponentType { kUnknown=0, kSource=1, kProcessor=2, kSink=3 };
+ virtual int Init( AliHLTComponentEnvironment* environ, void* environ_param, int argc, const char** argv );
+ virtual int Deinit();
+ virtual int ProcessEvent( AliHLTComponent_EventData evtData, AliHLTComponent_BlockData* blocks,
+ AliHLTComponent_TriggerData trigData, AliHLTUInt8_t* outputPtr,
+ AliHLTUInt32_t* size, AliHLTUInt32_t* outputBlockCnt,
+ AliHLTComponent_BlockData** outputBlocks,
+ AliHLTComponent_EventDoneData** edd ) = 0;
+
+ // Information member functions for registration.
+ virtual TComponentType GetComponentType() = 0; // Source, sink, or processor
+ virtual const char* GetComponentID() = 0;
+ virtual void GetInputDataTypes( vector<AliHLTComponent_DataType>& ) = 0;
+ virtual AliHLTComponent_DataType GetOutputDataType() = 0;
+
+ // Spawn function, return new class instance
+ virtual AliHLTComponent* Spawn() = 0;
+
+ static int SetGlobalComponentHandler(AliHLTComponentHandler* pCH, int bOverwrite=0) {
+ int iResult=0;
+ if (fpComponentHandler==NULL || bOverwrite!=0)
+ fpComponentHandler=pCH;
+ else
+ iResult=-EPERM;
+ return iResult;
+ }
+ static int UnsetGlobalComponentHandler() {
+ return SetGlobalComponentHandler(NULL,1);
+ }
+ protected:
+
+ virtual int DoInit( int argc, const char** argv ){
+ return 0;
+ }
+
+ virtual int DoDeinit(){
+ return 0;
+ }
+
+ void* AllocMemory( unsigned long size ) {
+ if (fEnvironment.fAllocMemoryFunc)
+ return (*fEnvironment.fAllocMemoryFunc)(fEnvironment.fParam, size );
+ return NULL;
+ }
+
+ int MakeOutputDataBlockList( const vector<AliHLTComponent_BlockData>& blocks, AliHLTUInt32_t* blockCount,
+ AliHLTComponent_BlockData** outputBlocks ) {
+ if (fEnvironment.fMakeOutputDataBlockListFunc)
+ return (*fEnvironment.fMakeOutputDataBlockListFunc)(fEnvironment.fParam, blocks, blockCount, outputBlocks );
+ return -ENOSYS;
+ }
+
+ int GetEventDoneData( unsigned long size, AliHLTComponent_EventDoneData** edd ) {
+ if (fEnvironment.fGetEventDoneDataFunc)
+ return (*fEnvironment.fGetEventDoneDataFunc)(fEnvironment.fParam, fCurrentEvent, size, edd );
+ return -ENOSYS;
+ }
+
+ int Logging( AliHLTComponent_LogSeverity severity, const char* origin, const char* keyword, const char* message, ... );
+
+ private:
+ static AliHLTComponentHandler* fpComponentHandler;
+ AliHLTComponentEnvironment fEnvironment;
+
+ AliHLTEventID_t fCurrentEvent; // Set by ProcessEvent before actual processing starts (e.g. before calling AliHLTProcessor::DoEvent)
+
+ ClassDef(AliHLTComponent, 0)
+};
+#endif
--- /dev/null
+// $Id$
+
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * 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 *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+///////////////////////////////////////////////////////////////////////////////
+// //
+// handler class for HLT analysis components //
+// //
+///////////////////////////////////////////////////////////////////////////////
+
+#if __GNUC__== 3
+using namespace std;
+#endif
+
+#include <errno.h>
+#include <string.h>
+#include <dlfcn.h>
+#include "AliL3StandardIncludes.h"
+#include "AliHLTComponentHandler.h"
+#include "AliHLTComponent.h"
+#include "AliHLTDataTypes.h"
+#include "AliHLTSystem.h"
+
+ClassImp(AliHLTComponentHandler)
+
+AliHLTComponentHandler::AliHLTComponentHandler()
+{
+}
+
+
+AliHLTComponentHandler::~AliHLTComponentHandler()
+{
+ UnloadLibraries();
+}
+
+Int_t AliHLTComponentHandler::RegisterComponent(AliHLTComponent* pSample)
+{
+ Int_t iResult=0;
+ if (pSample) {
+ if (FindComponent(pSample->GetComponentID())==NULL) {
+ iResult=InsertComponent(pSample);
+ if (iResult>=0) {
+ Logging(kHLTLogInfo, "BASE", "Component Handler", "component %s registered", pSample->GetComponentID());
+ }
+ } else {
+ // component already registered
+ Logging(kHLTLogInfo, "BASE", "Component Handler", "component %s already registered, skipped", pSample->GetComponentID());
+ iResult=-EEXIST;
+ }
+ } else {
+ iResult=-EINVAL;
+ }
+ return iResult;
+}
+
+int AliHLTComponentHandler::DeregisterComponent( const char* componentID )
+{
+ return 0;
+}
+
+Int_t AliHLTComponentHandler::ScheduleRegister(AliHLTComponent* pSample)
+{
+ Int_t iResult=0;
+ if (pSample) {
+ fScheduleList.push_back(pSample);
+ } else {
+ iResult=-EINVAL;
+ }
+ return iResult;
+}
+
+int AliHLTComponentHandler::CreateComponent(const Char_t* componentID, void* environ_param, int argc, const char** argv, AliHLTComponent*& component )
+{
+ int iResult=0;
+ if (componentID) {
+ AliHLTComponent* pSample=FindComponent(componentID);
+ if (pSample!=NULL) {
+ component=pSample->Spawn();
+ if (component) {
+ component->Init(&fEnvironment, environ_param, argc, argv);
+ }
+ }
+ } else {
+ iResult=-EINVAL;
+ }
+ return iResult;
+}
+
+Int_t AliHLTComponentHandler::FindComponentIndex(const Char_t* componentID)
+{
+ Int_t iResult=0;
+ if (componentID) {
+ vector<AliHLTComponent*>::iterator element=fComponentList.begin();
+ while (element!=fComponentList.end() && iResult>=0) {
+ if (strcmp(componentID, (*element)->GetComponentID())==0) {
+ break;
+ }
+ element++;
+ iResult++;
+ }
+ if (element==fComponentList.end()) iResult=-ENOENT;
+ } else {
+ iResult=-EINVAL;
+ }
+ return iResult;
+}
+
+AliHLTComponent* AliHLTComponentHandler::FindComponent(const Char_t* componentID)
+{
+ AliHLTComponent* pSample=NULL;
+ Int_t index=FindComponentIndex(componentID);
+ if (index>=0) {
+ pSample=(AliHLTComponent*)fComponentList.at(index);
+ }
+ return pSample;
+}
+
+Int_t AliHLTComponentHandler::InsertComponent(AliHLTComponent* pSample)
+{
+ Int_t iResult=0;
+ if (pSample!=NULL) {
+ fComponentList.push_back(pSample);
+ } else {
+ iResult=-EINVAL;
+ }
+ return iResult;
+}
+
+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());
+ }
+}
+
+void AliHLTComponentHandler::SetEnvironment(AliHLTComponentEnvironment* pEnv) {
+ if (pEnv) {
+ memcpy(&fEnvironment, pEnv, sizeof(AliHLTComponentEnvironment));
+ }
+}
+
+int AliHLTComponentHandler::LoadLibrary( const char* libraryPath )
+{
+ int iResult=0;
+ if (libraryPath) {
+ AliHLTComponent::SetGlobalComponentHandler(this);
+ AliHLTLibHandle hLib=dlopen(libraryPath, RTLD_NOW);
+ if (hLib) {
+ AliHLTComponent::UnsetGlobalComponentHandler();
+ Logging(kHLTLogDebug, "BASE", "Component Handler", "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);
+ }
+ } else {
+ Logging(kHLTLogError, "BASE", "Component Handler", "can not load library %s", libraryPath);
+ Logging(kHLTLogError, "BASE", "Component Handler", "dlopen error: %s", dlerror());
+ iResult=-ELIBACC;
+ }
+ } else {
+ iResult=-EINVAL;
+ }
+ return iResult;
+}
+
+int AliHLTComponentHandler::UnloadLibrary( const char* libraryPath )
+{
+ int iResult=0;
+ return iResult;
+}
+
+int AliHLTComponentHandler::UnloadLibraries()
+{
+ int iResult=0;
+ vector<AliHLTLibHandle>::iterator element=fLibraryList.begin();
+ while (element!=fLibraryList.end()) {
+ dlclose(*element);
+ element++;
+ }
+ return iResult;
+}
+
+int AliHLTComponentHandler::Logging(AliHLTComponent_LogSeverity severity, const char* origin, const char* keyword, const char* format, ... ) {
+ if (fEnvironment.fLoggingFunc) {
+ va_list args;
+ va_start(args, format);
+ return (*fEnvironment.fLoggingFunc)( fEnvironment.fParam, severity, origin, keyword, AliHLTSystem::BuildLogString(format, args));
+ }
+ return -ENOSYS;
+}
--- /dev/null
+// @(#) $Id$
+
+#ifndef ALIHLTCOMPONENTHANDLER_H
+#define ALIHLTCOMPONENTHANDLER_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+/* AliHltcomponentHandler
+ handler of HLT processing components
+ */
+
+#include "TObject.h"
+#include "AliHLTDataTypes.h"
+
+class AliHLTComponent;
+struct AliHLTComponentEnvironment;
+struct AliHLTComponent_DataType;
+
+typedef void* AliHLTLibHandle;
+
+class AliHLTComponentHandler {
+ public:
+ AliHLTComponentHandler();
+ virtual ~AliHLTComponentHandler();
+
+ void SetEnvironment(AliHLTComponentEnvironment* pEnv);
+
+ // Load a component shared library
+ int LoadLibrary( const char* libraryPath );
+ int UnloadLibrary( const char* libraryPath );
+
+ /* Component registration funcions
+ * registration is done by passing a sample object of the component to the handler
+ * the object has to be valid during the whole runtime and should thus be a global object
+ */
+ // Schedule a component for registration, full registration will be done
+ // after successfull loading of the shared library
+ int ScheduleRegister(AliHLTComponent* pSample );
+
+ // Register a component with the list of available components
+ int RegisterComponent(AliHLTComponent* pSample );
+ int DeregisterComponent( const char* componentID );
+
+ // Find the ID of a component with the given output data
+ // prevType can be used to iterate if there are multiple components with the same output data type.
+ const char* FindComponentType( AliHLTComponent_DataType, const char* prevType = NULL ) { return NULL;}
+
+ // Create a component of the given name
+ int CreateComponent( const char* componentType, void* environ_param, int argc, const char** argv, AliHLTComponent*& component );
+ int CreateComponent( const char* componentType, void* environ_param, AliHLTComponent*& component ) {
+ return CreateComponent( componentType, environ_param, 0, NULL, component );
+ }
+
+ /* print registered components to stdout
+ */
+ void List();
+ protected:
+ int Logging( AliHLTComponent_LogSeverity severity, const char* origin, const char* keyword, const char* message, ... );
+
+ private:
+ /* find a component
+ return index
+ */
+ int FindComponentIndex(const char* componentID);
+
+ /* find a component
+ return descriptor
+ */
+ AliHLTComponent* FindComponent(const char* componentID);
+
+ int InsertComponent(AliHLTComponent* pSample);
+
+ // close all libraries
+ int UnloadLibraries();
+
+ /* list of registered components
+ */
+ vector<AliHLTComponent*> fComponentList;
+
+ /* list of scheduled components
+ */
+ vector<AliHLTComponent*> fScheduleList;
+
+ /* list of libraries
+ */
+ vector<AliHLTLibHandle> fLibraryList;
+
+ AliHLTComponentEnvironment fEnvironment;
+
+ ClassDef(AliHLTComponentHandler, 0)
+ };
+#endif
+
--- /dev/null
+// @(#) $Id$
+
+#ifndef ALIHLTDATATYPES_H
+#define ALIHLTDATATYPES_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+#include <vector>
+using namespace std;
+
+extern "C" {
+
+ typedef unsigned char AliHLTUInt8_t;
+
+ typedef unsigned int AliHLTUInt32_t;
+
+ typedef unsigned long long AliHLTUInt64_t;
+
+ typedef AliHLTUInt64_t AliHLTEventID_t;
+
+ enum AliHLTComponent_LogSeverity { kHLTLogNone=0, kHLTLogBenchmark=1, kHLTLogDebug=2, kHLTLogInfo=4, kHLTLogWarning=8, kHLTLogError=16, kHLTLogFatal=32 };
+
+ struct AliHLTComponent_EventData
+ {
+ AliHLTUInt32_t fStructSize;
+ AliHLTEventID_t fEventID;
+ AliHLTUInt32_t fEventCreation_s;
+ AliHLTUInt32_t fEventCreation_us;
+ AliHLTUInt32_t fBlockCnt;
+ };
+
+ struct AliHLTComponent_ShmData
+ {
+ AliHLTUInt32_t fStructSize;
+ AliHLTUInt32_t fShmType;
+ AliHLTUInt64_t fShmID;
+ };
+
+ struct AliHLTComponent_DataType
+ {
+ AliHLTUInt32_t fStructSize;
+ char fID[8];
+ char fOrigin[4];
+ };
+
+ struct AliHLTComponent_BlockData
+ {
+ AliHLTUInt32_t fStructSize;
+ AliHLTComponent_ShmData fShmKey;
+ AliHLTUInt32_t fOffset;
+ void* fPtr;
+ AliHLTUInt32_t fSize;
+ AliHLTComponent_DataType fDataType;
+ AliHLTUInt32_t fSpecification;
+ };
+
+ struct AliHLTComponent_TriggerData
+ {
+ AliHLTUInt32_t fStructSize;
+ AliHLTUInt32_t fDataSize;
+ void* fData;
+ };
+
+ struct AliHLTComponent_EventDoneData
+ {
+ AliHLTUInt32_t fStructSize;
+ AliHLTUInt32_t fDataSize;
+ void* fData;
+ };
+
+ struct AliHLTComponentEnvironment
+ {
+ AliHLTUInt32_t fStructSize;
+ void* fParam;
+ void* (*fAllocMemoryFunc)( void* param, unsigned long size );
+#if 0
+ int (*fAllocShmMemoryFunc)( void* param, unsigned long size, AliHLTComponent_BlockData* blockLocation ); // future addition already foreseen/envisioned
+#endif
+ int (*fMakeOutputDataBlockListFunc)( void* param, const vector<AliHLTComponent_BlockData>& blocks, AliHLTUInt32_t* blockCount, AliHLTComponent_BlockData** outputBlocks );
+ int (*fGetEventDoneDataFunc)( void* param, AliHLTEventID_t eventID, unsigned long size, AliHLTComponent_EventDoneData** edd );
+ int (*fLoggingFunc)( void* param, AliHLTComponent_LogSeverity severity, const char* origin, const char* keyword, const char* message );
+ };
+}
+
+#endif
--- /dev/null
+// $Id$
+
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * 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 *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+///////////////////////////////////////////////////////////////////////////////
+// //
+// base class for HLT analysis components //
+// //
+///////////////////////////////////////////////////////////////////////////////
+
+#if __GNUC__== 3
+using namespace std;
+#endif
+
+#include "AliHLTProcessor.h"
+#include <string.h>
+
+ClassImp(AliHLTProcessor)
+
+AliHLTProcessor::AliHLTProcessor()
+{
+}
+
+AliHLTProcessor::~AliHLTProcessor()
+{
+}
+
+int AliHLTProcessor::Init( AliHLTComponentEnvironment* environ, void* environ_param, int argc, const char** argv )
+{
+ int iResult=0;
+ iResult=AliHLTComponent::Init(environ, environ_param, argc, argv);
+ return iResult;
+}
+
+int AliHLTProcessor::Deinit()
+{
+ int iResult=0;
+ iResult=AliHLTComponent::Deinit();
+ return iResult;
+}
+
+int AliHLTProcessor::ProcessEvent( AliHLTComponent_EventData evtData, AliHLTComponent_BlockData* blocks,
+ AliHLTComponent_TriggerData trigData, AliHLTUInt8_t* outputPtr,
+ AliHLTUInt32_t* size, AliHLTUInt32_t* outputBlockCnt,
+ AliHLTComponent_BlockData** outputBlocks,
+ AliHLTComponent_EventDoneData** edd )
+{
+ int iResult=0;
+ vector<AliHLTComponent_BlockData> blockData;
+ iResult=DoEvent(evtData, blocks, trigData, outputPtr, size, blockData);
+ if (iResult>=0) {
+ iResult=MakeOutputDataBlockList(blockData, outputBlockCnt, outputBlocks);
+ }
+ return iResult;
+}
+
--- /dev/null
+// @(#) $Id$
+
+#ifndef ALIHLTPROCESSOR_H
+#define ALIHLTPROCESSOR_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+/* AliHLTProcessor
+ base class for HLT processing components
+ */
+
+#include "AliHLTComponent.h"
+
+class AliHLTProcessor : public AliHLTComponent {
+ public:
+ AliHLTProcessor();
+ virtual ~AliHLTProcessor();
+
+ int Init( AliHLTComponentEnvironment* environ, void* environ_param, int argc, const char** argv );
+ int Deinit();
+ int ProcessEvent( AliHLTComponent_EventData evtData, AliHLTComponent_BlockData* blocks,
+ AliHLTComponent_TriggerData trigData, AliHLTUInt8_t* outputPtr,
+ AliHLTUInt32_t* size, AliHLTUInt32_t* outputBlockCnt,
+ AliHLTComponent_BlockData** outputBlocks,
+ AliHLTComponent_EventDoneData** edd );
+
+ // Information member functions for registration.
+ TComponentType GetComponentType() { return AliHLTComponent::kProcessor;}
+
+ private:
+ virtual int DoInit( int argc, const char** argv ){
+ return 0;
+ }
+
+ virtual int DoDeinit(){
+ return 0;
+ }
+ virtual int DoEvent( AliHLTComponent_EventData evtData, AliHLTComponent_BlockData* blocks,
+ AliHLTComponent_TriggerData trigData, AliHLTUInt8_t* outputPtr,
+ AliHLTUInt32_t* size, vector<AliHLTComponent_BlockData>& outputBlocks ) = 0;
+
+
+ ClassDef(AliHLTProcessor, 0)
+};
+#endif
--- /dev/null
+// $Id$
+
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * 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 *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+///////////////////////////////////////////////////////////////////////////////
+// //
+// global HLT module management //
+// //
+///////////////////////////////////////////////////////////////////////////////
+
+#if __GNUC__== 3
+using namespace std;
+#endif
+
+#include <errno.h>
+#include <string.h>
+#include "AliL3StandardIncludes.h"
+#include "AliHLTSystem.h"
+#include "AliHLTComponentHandler.h"
+#include "AliHLTComponent.h"
+
+ClassImp(AliHLTSystem)
+
+char AliHLTSystem::fLogBuffer[LOG_BUFFER_SIZE]="";
+
+AliHLTSystem::AliHLTSystem()
+{
+ fpComponentHandler=new AliHLTComponentHandler();
+ if (fpComponentHandler) {
+ AliHLTComponentEnvironment env;
+ memset(&env, 0, sizeof(AliHLTComponentEnvironment));
+ env.fLoggingFunc=AliHLTSystem::Logging;
+ fpComponentHandler->SetEnvironment(&env);
+ }
+}
+
+
+AliHLTSystem::~AliHLTSystem()
+{
+}
+
+int AliHLTSystem::Logging(void *param, AliHLTComponent_LogSeverity severity, const char* origin, const char* keyword, const char* message) {
+ int iResult=0;
+ const char* strSeverity="";
+ switch (severity) {
+ case kHLTLogBenchmark:
+ strSeverity="benchmark";
+ break;
+ case kHLTLogDebug:
+ strSeverity="debug";
+ break;
+ case kHLTLogInfo:
+ strSeverity="info";
+ break;
+ case kHLTLogWarning:
+ strSeverity="warning";
+ break;
+ case kHLTLogError:
+ strSeverity="error";
+ break;
+ case kHLTLogFatal:
+ strSeverity="fatal";
+ break;
+ default:
+ break;
+ }
+ cout << "HLT Log " << strSeverity << ": " << origin << " (" << keyword << ") " << message << endl;
+ return iResult;
+}
+
+const char* AliHLTSystem::BuildLogString(const char *format, va_list ap) {
+ int tgtLen=0;
+ int iBufferSize=LOG_BUFFER_SIZE;
+ char* tgtBuffer=fLogBuffer;
+ tgtBuffer[tgtLen]=0;
+
+ tgtLen = snprintf(tgtBuffer, iBufferSize, LOG_PREFIX); // add logging prefix
+ if (tgtLen>=0) {
+ tgtBuffer+=tgtLen; iBufferSize-=tgtLen;
+ tgtLen = vsnprintf(tgtBuffer, iBufferSize, format, ap);
+ if (tgtLen>0) {
+ tgtBuffer+=tgtLen;
+// if (tgtLen<LOG_BUFFER_SIZE-1) {
+// *tgtBuffer++='\n'; // add newline if space in buffer
+// }
+ *tgtBuffer=0; // terminate the buffer
+ }
+ }
+ return fLogBuffer;
+}
+
+
--- /dev/null
+// @(#) $Id$
+
+#ifndef ALIHLTSYSTEM_H
+#define ALIHLTSYSTEM_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+/* AliHLTComponentHandler
+ global HLT module management
+ */
+
+
+#include "AliL3RootTypes.h"
+#include "AliHLTDataTypes.h"
+#include <stdarg.h>
+class AliHLTComponentHandler;
+
+#define LOG_BUFFER_SIZE 100 // global logging buffer
+#define LOG_PREFIX " " // logging prefix, for later extensions
+
+class AliHLTSystem {
+public:
+ AliHLTSystem();
+ virtual ~AliHLTSystem();
+
+ Int_t SetLogLevel(Int_t iLogLevel) {return fLogLevel;}
+ static int Logging(void * param, AliHLTComponent_LogSeverity severity, const char* origin, const char* keyword, const char* message);
+ static const char* BuildLogString(const char *format, va_list ap);
+ AliHLTComponentHandler* fpComponentHandler;
+protected:
+
+private:
+ Int_t fLogLevel;
+ static char fLogBuffer[LOG_BUFFER_SIZE];
+
+ ClassDef(AliHLTSystem, 0)
+};
+#endif
+
--- /dev/null
+// $Id$
+
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * 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 *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+///////////////////////////////////////////////////////////////////////////////
+// //
+// pure C interface to the AliRoot HLT component handler //
+// //
+///////////////////////////////////////////////////////////////////////////////
+
+#if __GNUC__== 3
+using namespace std;
+#endif
+
+#include "AliHLT_C_Component_WrapperInterface.h"
+#include "AliHLTComponentHandler.h"
+#include "AliHLTComponent.h"
+#include <errno.h>
+
+static AliHLTComponentHandler *gComponentHandler_C = NULL;
+
+
+int AliHLT_C_Component_InitSystem( AliHLTComponentEnvironment* environ )
+{
+ if ( gComponentHandler_C )
+ {
+ return EINPROGRESS;
+ }
+ gComponentHandler_C = new AliHLTComponentHandler();
+ if ( !gComponentHandler_C )
+ return EFAULT;
+ gComponentHandler_C->SetEnvironment( environ );
+ return 0;
+}
+
+int AliHLT_C_Component_DeinitSystem()
+{
+ if ( gComponentHandler_C )
+ {
+ delete gComponentHandler_C;
+ gComponentHandler_C = NULL;
+ }
+ return 0;
+}
+
+int AliHLT_C_Component_LoadLibrary( const char* libraryPath )
+{
+ if ( !gComponentHandler_C )
+ return ENXIO;
+ return gComponentHandler_C->LoadLibrary( libraryPath );
+}
+
+int AliHLT_C_Component_UnloadLibrary( const char* libraryPath )
+{
+ if ( !gComponentHandler_C )
+ return ENXIO;
+ return gComponentHandler_C->UnloadLibrary( libraryPath );
+}
+
+int AliHLT_C_CreateComponent( const char* componentType, void* environ_param, int argc, const char** argv, AliHLTComponentHandle* handle )
+{
+ if ( !gComponentHandler_C )
+ return ENXIO;
+ AliHLTComponent* comp;
+ int ret = gComponentHandler_C->CreateComponent( componentType, environ_param, argc, argv, comp );
+ *handle = reinterpret_cast<AliHLTComponentHandle>( comp );
+ return ret;
+}
+
+void AliHLT_C_DestroyComponent( AliHLTComponentHandle handle )
+{
+ if ( !handle )
+ return;
+ delete reinterpret_cast<AliHLTComponent*>( handle );
+}
+
+int AliHLT_C_ProcessEvent( AliHLTComponentHandle handle, AliHLTComponent_EventData evtData, AliHLTComponent_BlockData* blocks,
+ AliHLTComponent_TriggerData trigData, AliHLTUInt8_t* outputPtr,
+ AliHLTUInt32_t* size, AliHLTUInt32_t* outputBlockCnt,
+ AliHLTComponent_BlockData** outputBlocks,
+ AliHLTComponent_EventDoneData** edd )
+{
+ if ( !handle )
+ return ENXIO;
+ AliHLTComponent* comp = reinterpret_cast<AliHLTComponent*>( handle );
+ return comp->ProcessEvent( evtData, blocks, trigData, outputPtr, size, outputBlockCnt, outputBlocks, edd );
+}
--- /dev/null
+// @(#) $Id$
+
+#ifndef ALIHLT_C_COMPONENT_WARAPPERINTERFACE_H
+#define ALIHLT_C_COMPONENT_WARAPPERINTERFACE_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+/* AliHLT_C_Component_WrapperInterface
+ pure C interface to the AliRoot HLT component handler
+ utilized by the HLT PubSub Framework
+ */
+
+#include <AliHLTDataTypes.h>
+
+extern "C" {
+typedef void* AliHLTComponentHandle;
+
+ const AliHLTComponentHandle kEmptyHLTComponentHandle = 0;
+
+int AliHLT_C_Component_InitSystem( AliHLTComponentEnvironment* environ );
+int AliHLT_C_Component_DeinitSystem();
+int AliHLT_C_Component_LoadLibrary( const char* libraryPath );
+int AliHLT_C_Component_UnloadLibrary( const char* libraryPath );
+int AliHLT_C_CreateComponent( const char* componentType, void* environ_param, int argc, const char** argv, AliHLTComponentHandle* handle );
+void AliHLT_C_DestroyComponent( AliHLTComponentHandle );
+int AliHLT_C_ProcessEvent( AliHLTComponentHandle, AliHLTComponent_EventData evtData, AliHLTComponent_BlockData* blocks,
+ AliHLTComponent_TriggerData trigData, AliHLTUInt8_t* outputPtr,
+ AliHLTUInt32_t* size, AliHLTUInt32_t* outputBlockCnt,
+ AliHLTComponent_BlockData** outputBlocks,
+ AliHLTComponent_EventDoneData** edd );
+
+}
+
+#endif //ALIHLT_C_COMPONENT_WARAPPERINTERFACE_H
--- /dev/null
+// @(#) $Id$
+
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class AliHLTComponent;
+#pragma link C++ class AliHLTComponentHandler;
+#pragma link C++ class AliHLTProcessor;
+#pragma link C++ class AliHLTSystem;
+
+#endif
+
--- /dev/null
+#$Id$
+##########################################
+# Makefile for AliRoot HLT framework. #
+# #
+# Author: Matthias Richter, #
+# Timm Steinbeck #
+# Artur Szostack #
+##########################################
+
+MODNAME = HLTbase
+
+ifndef ALIHLT_TOPDIR
+ALIHLT_TOPDIR = $(shell pwd)/..
+endif
+
+include $(ALIHLT_TOPDIR)/Makefile.conf
+
+SRCS = AliHLTComponent.cxx AliHLTComponentHandler.cxx \
+ AliHLTSystem.cxx AliHLT_C_Component_WrapperInterface.cxx \
+ AliHLTProcessor.cxx
+
+SRCS += $(EXTRA_SRCS)
+
+
+include $(ALIHLT_TOPDIR)/Makefile.rules