From f23a6e1a4d37f895e3e5f6693ccfd7060e55ae4b Mon Sep 17 00:00:00 2001 From: richterm Date: Mon, 1 Aug 2005 09:33:19 +0000 Subject: [PATCH] started the new framework module supporting PubSub and AliRoot --- HLT/BASE/AliHLTComponent.cxx | 75 +++++++ HLT/BASE/AliHLTComponent.h | 91 ++++++++ HLT/BASE/AliHLTComponentHandler.cxx | 212 ++++++++++++++++++ HLT/BASE/AliHLTComponentHandler.h | 93 ++++++++ HLT/BASE/AliHLTDataTypes.h | 85 +++++++ HLT/BASE/AliHLTProcessor.cxx | 71 ++++++ HLT/BASE/AliHLTProcessor.h | 45 ++++ HLT/BASE/AliHLTSystem.cxx | 107 +++++++++ HLT/BASE/AliHLTSystem.h | 39 ++++ .../AliHLT_C_Component_WrapperInterface.cxx | 102 +++++++++ .../AliHLT_C_Component_WrapperInterface.h | 34 +++ HLT/BASE/HLTbaseLinkDef.h | 15 ++ HLT/BASE/Makefile | 25 +++ 13 files changed, 994 insertions(+) create mode 100644 HLT/BASE/AliHLTComponent.cxx create mode 100644 HLT/BASE/AliHLTComponent.h create mode 100644 HLT/BASE/AliHLTComponentHandler.cxx create mode 100644 HLT/BASE/AliHLTComponentHandler.h create mode 100644 HLT/BASE/AliHLTDataTypes.h create mode 100644 HLT/BASE/AliHLTProcessor.cxx create mode 100644 HLT/BASE/AliHLTProcessor.h create mode 100644 HLT/BASE/AliHLTSystem.cxx create mode 100644 HLT/BASE/AliHLTSystem.h create mode 100644 HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx create mode 100644 HLT/BASE/AliHLT_C_Component_WrapperInterface.h create mode 100644 HLT/BASE/HLTbaseLinkDef.h create mode 100644 HLT/BASE/Makefile diff --git a/HLT/BASE/AliHLTComponent.cxx b/HLT/BASE/AliHLTComponent.cxx new file mode 100644 index 00000000000..bceb18de49b --- /dev/null +++ b/HLT/BASE/AliHLTComponent.cxx @@ -0,0 +1,75 @@ +// $Id$ + +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Authors: Matthias Richter * + * Timm Steinbeck * + * Artur Szostak * + * 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 +#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; +} diff --git a/HLT/BASE/AliHLTComponent.h b/HLT/BASE/AliHLTComponent.h new file mode 100644 index 00000000000..837430f5d60 --- /dev/null +++ b/HLT/BASE/AliHLTComponent.h @@ -0,0 +1,91 @@ +// @(#) $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 +#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& ) = 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& 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 diff --git a/HLT/BASE/AliHLTComponentHandler.cxx b/HLT/BASE/AliHLTComponentHandler.cxx new file mode 100644 index 00000000000..8e361d7054b --- /dev/null +++ b/HLT/BASE/AliHLTComponentHandler.cxx @@ -0,0 +1,212 @@ +// $Id$ + +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Authors: Matthias Richter * + * Timm Steinbeck * + * Artur Szostak * + * 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 +#include +#include +#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::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::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::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::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; +} diff --git a/HLT/BASE/AliHLTComponentHandler.h b/HLT/BASE/AliHLTComponentHandler.h new file mode 100644 index 00000000000..3876fe6a5b2 --- /dev/null +++ b/HLT/BASE/AliHLTComponentHandler.h @@ -0,0 +1,93 @@ +// @(#) $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 fComponentList; + + /* list of scheduled components + */ + vector fScheduleList; + + /* list of libraries + */ + vector fLibraryList; + + AliHLTComponentEnvironment fEnvironment; + + ClassDef(AliHLTComponentHandler, 0) + }; +#endif + diff --git a/HLT/BASE/AliHLTDataTypes.h b/HLT/BASE/AliHLTDataTypes.h new file mode 100644 index 00000000000..3aaea7af918 --- /dev/null +++ b/HLT/BASE/AliHLTDataTypes.h @@ -0,0 +1,85 @@ +// @(#) $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 +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& 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 diff --git a/HLT/BASE/AliHLTProcessor.cxx b/HLT/BASE/AliHLTProcessor.cxx new file mode 100644 index 00000000000..53b3863256f --- /dev/null +++ b/HLT/BASE/AliHLTProcessor.cxx @@ -0,0 +1,71 @@ +// $Id$ + +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Authors: Matthias Richter * + * Timm Steinbeck * + * Artur Szostak * + * 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 + +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 blockData; + iResult=DoEvent(evtData, blocks, trigData, outputPtr, size, blockData); + if (iResult>=0) { + iResult=MakeOutputDataBlockList(blockData, outputBlockCnt, outputBlocks); + } + return iResult; +} + diff --git a/HLT/BASE/AliHLTProcessor.h b/HLT/BASE/AliHLTProcessor.h new file mode 100644 index 00000000000..a44ba3c877a --- /dev/null +++ b/HLT/BASE/AliHLTProcessor.h @@ -0,0 +1,45 @@ +// @(#) $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& outputBlocks ) = 0; + + + ClassDef(AliHLTProcessor, 0) +}; +#endif diff --git a/HLT/BASE/AliHLTSystem.cxx b/HLT/BASE/AliHLTSystem.cxx new file mode 100644 index 00000000000..5d6429d5828 --- /dev/null +++ b/HLT/BASE/AliHLTSystem.cxx @@ -0,0 +1,107 @@ +// $Id$ + +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Authors: Matthias Richter * + * Timm Steinbeck * + * Artur Szostak * + * 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 +#include +#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 +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 + diff --git a/HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx b/HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx new file mode 100644 index 00000000000..71a9545f230 --- /dev/null +++ b/HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx @@ -0,0 +1,102 @@ +// $Id$ + +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Authors: Matthias Richter * + * Timm Steinbeck * + * Artur Szostak * + * 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 + +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( comp ); + return ret; +} + +void AliHLT_C_DestroyComponent( AliHLTComponentHandle handle ) +{ + if ( !handle ) + return; + delete reinterpret_cast( 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( handle ); + return comp->ProcessEvent( evtData, blocks, trigData, outputPtr, size, outputBlockCnt, outputBlocks, edd ); +} diff --git a/HLT/BASE/AliHLT_C_Component_WrapperInterface.h b/HLT/BASE/AliHLT_C_Component_WrapperInterface.h new file mode 100644 index 00000000000..566eeb4b214 --- /dev/null +++ b/HLT/BASE/AliHLT_C_Component_WrapperInterface.h @@ -0,0 +1,34 @@ +// @(#) $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 + +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 diff --git a/HLT/BASE/HLTbaseLinkDef.h b/HLT/BASE/HLTbaseLinkDef.h new file mode 100644 index 00000000000..7e55e67d8da --- /dev/null +++ b/HLT/BASE/HLTbaseLinkDef.h @@ -0,0 +1,15 @@ +// @(#) $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 + diff --git a/HLT/BASE/Makefile b/HLT/BASE/Makefile new file mode 100644 index 00000000000..3006a95c6bb --- /dev/null +++ b/HLT/BASE/Makefile @@ -0,0 +1,25 @@ +#$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 -- 2.31.1