From a742f6f8a15d9829df6f5df5e7b483d66614aa13 Mon Sep 17 00:00:00 2001 From: richterm Date: Fri, 27 Apr 2007 11:25:35 +0000 Subject: [PATCH] HLT base - memory leaks corrected - AliLog support moved to libAliHLTUtil in order to keep - libHLTbase free of AliRoot dependencies - dynamic loeding of AliLog support - AliHLTFileWriter moved to libAliHLTUtil --- HLT/BASE/AliHLTComponentHandler.cxx | 70 ++-- HLT/BASE/AliHLTComponentHandler.h | 12 +- HLT/BASE/AliHLTConfiguration.cxx | 57 +++- HLT/BASE/AliHLTFileWriter.cxx | 304 ------------------ HLT/BASE/AliHLTFileWriter.h | 190 ----------- HLT/BASE/AliHLTLogging.cxx | 86 ++--- HLT/BASE/AliHLTLogging.h | 106 ++++-- HLT/BASE/AliHLTSystem.cxx | 37 ++- HLT/BASE/AliHLTSystem.h | 10 +- HLT/BASE/AliHLTTask.h | 16 + .../AliHLT_C_Component_WrapperInterface.cxx | 1 + HLT/BASE/HLTbaseLinkDef.h | 2 +- HLT/BASE/Makefile.am | 5 +- HLT/BASE/util/AliHLTDynamicAliLog.cxx | 102 ++++++ HLT/BASE/util/Makefile.am | 6 +- HLT/ChangeLog | 6 + HLT/PHOS/Makefile.am | 4 +- HLT/SampleLib/tutorial.c | 2 +- HLT/libAliHLTPHOS.pkg | 2 +- HLT/libAliHLTUtil.pkg | 3 + HLT/libHLTbase.pkg | 7 +- 21 files changed, 417 insertions(+), 611 deletions(-) delete mode 100644 HLT/BASE/AliHLTFileWriter.cxx delete mode 100644 HLT/BASE/AliHLTFileWriter.h create mode 100644 HLT/BASE/util/AliHLTDynamicAliLog.cxx diff --git a/HLT/BASE/AliHLTComponentHandler.cxx b/HLT/BASE/AliHLTComponentHandler.cxx index 50aa238e3ca..6d1cf4b62a0 100644 --- a/HLT/BASE/AliHLTComponentHandler.cxx +++ b/HLT/BASE/AliHLTComponentHandler.cxx @@ -39,7 +39,7 @@ using namespace std; // the standard components // #include "AliHLTFilePublisher.h" -#include "AliHLTFileWriter.h" +// #include "AliHLTFileWriter.h" // #include "AliHLTRootFilePublisherComponent.h" // #include "AliHLTRootFileWriterComponent.h" @@ -89,8 +89,8 @@ AliHLTComponentHandler::AliHLTComponentHandler(AliHLTComponentEnvironment* pEnv) AliHLTComponentHandler::~AliHLTComponentHandler() { // see header file for class documentation - UnloadLibraries(); DeleteStandardComponents(); + UnloadLibraries(); } int AliHLTComponentHandler::AnnounceVersion() @@ -106,7 +106,7 @@ int AliHLTComponentHandler::AnnounceVersion() if (!time) time="unknown"; HLTInfo("%s build on %s (%s)", PACKAGE_STRING, date, time); #else - HLTInfo("ALICE High Level Trigger (embedded AliRoot build)"); + HLTInfo("ALICE High Level Trigger build on %s (%s) (embedded AliRoot build)", __DATE__, __TIME__); #endif return iResult; } @@ -313,39 +313,61 @@ int AliHLTComponentHandler::UnloadLibrary( const char* libraryPath ) // see header file for class documentation int iResult=0; if (libraryPath) { + vector::iterator element=fLibraryList.begin(); + while (element!=fLibraryList.end()) { + TString* pName=reinterpret_cast((*element).name); + if (pName->CompareTo(libraryPath)==0) { + UnloadLibrary(*element); + fLibraryList.erase(element); + break; + } + element++; + } } else { iResult=-EINVAL; } return iResult; } -int AliHLTComponentHandler::UnloadLibraries() +int AliHLTComponentHandler::UnloadLibrary(AliHLTComponentHandler::AliHLTLibHandle &handle) { // see header file for class documentation int iResult=0; - vector::iterator element=fLibraryList.begin(); - while (element!=fLibraryList.end()) { - TString* pName=reinterpret_cast((*element).name); + fgAliLoggingFunc=NULL; + TString* pName=reinterpret_cast(handle.name); #ifdef HAVE_DLFCN_H - dlclose((*element).handle); + dlclose(handle.handle); #else - int* pCount=reinterpret_cast((*element).handle); - if (--(*pCount)==0) { - if (pName) - gSystem->Unload(pName->Data()); - else { - HLTError("missing library name, can not unload"); - } - delete pCount; - } -#endif //HAVE_DLFCN_H + int* pCount=reinterpret_cast(handle.handle); + if (--(*pCount)==0) { if (pName) { - HLTDebug("unload library %s", pName->Data()); - delete pName; - } else { - HLTWarning("missing name for unloaded library"); + gSystem->Unload(pName->Data()); + } + else { + HLTError("missing library name, can not unload"); } - pName=NULL; + delete pCount; + } +#endif //HAVE_DLFCN_H + handle.name=NULL; + handle.handle=NULL; + if (pName) { + HLTDebug("unload library %s", pName->Data()); + delete pName; + } else { + HLTWarning("missing name for unloaded library"); + } + pName=NULL; + return iResult; +} + +int AliHLTComponentHandler::UnloadLibraries() +{ + // see header file for class documentation + int iResult=0; + vector::iterator element=fLibraryList.begin(); + while (element!=fLibraryList.end()) { + UnloadLibrary(*element); fLibraryList.erase(element); element=fLibraryList.begin(); } @@ -389,7 +411,7 @@ int AliHLTComponentHandler::AddStandardComponents() int iResult=0; AliHLTComponent::SetGlobalComponentHandler(this); // fStandardList.push_back(new AliHLTFilePublisher); - fStandardList.push_back(new AliHLTFileWriter); +// fStandardList.push_back(new AliHLTFileWriter); // fStandardList.push_back(new AliHLTRootFilePublisherComponent); // fStandardList.push_back(new AliHLTRootFileWriterComponent); AliHLTComponent::UnsetGlobalComponentHandler(); diff --git a/HLT/BASE/AliHLTComponentHandler.h b/HLT/BASE/AliHLTComponentHandler.h index f00314e8be1..6e0288d8f30 100644 --- a/HLT/BASE/AliHLTComponentHandler.h +++ b/HLT/BASE/AliHLTComponentHandler.h @@ -71,7 +71,8 @@ class AliHLTComponentHandler : public AliHLTLogging { /** * Unload a component shared library. - * All components will be de-registered. + * All components will be de-registered when the last instance of the + * library was unloaded. * @param libraryPath library name as specified to @ref LoadLibrary * @return 0 if succeeded, neg. error code if failed */ @@ -223,6 +224,15 @@ class AliHLTComponentHandler : public AliHLTLogging { */ AliHLTLibHandle* FindLibrary(const char* library); + /** + * Unload a component shared library. + * All components will be de-registered when the last instance of the + * library was unloaded. + * @param handle handle to the library to unload + * @return 0 if succeeded, neg. error code if failed + */ + int UnloadLibrary(AliHLTComponentHandler::AliHLTLibHandle &handle); + /** list of registered components */ vector fComponentList; // see above /** list of scheduled components */ diff --git a/HLT/BASE/AliHLTConfiguration.cxx b/HLT/BASE/AliHLTConfiguration.cxx index 326015650ab..605ad268063 100644 --- a/HLT/BASE/AliHLTConfiguration.cxx +++ b/HLT/BASE/AliHLTConfiguration.cxx @@ -125,6 +125,12 @@ AliHLTConfiguration::~AliHLTConfiguration() delete[] fArgv; fArgv=NULL; } + + vector::iterator element=fListSources.begin(); + while (element!=fListSources.end()) { + fListSources.erase(element); + element=fListSources.begin(); + } } /* the global configuration handler which is used to automatically register the configuration @@ -298,7 +304,7 @@ int AliHLTConfiguration::ExtractSources() if (fgConfigurationHandler) { AliHLTConfiguration* pConf=fgConfigurationHandler->FindConfiguration(*element); if (pConf) { - HLTDebug("source \"%s\" inserted", pConf->GetName()); + //HLTDebug("configuration %s (%p): source \"%s\" (%p) inserted", GetName(), this, pConf->GetName(), pConf); fListSources.push_back(pConf); } else { HLTError("can not find source \"%s\"", (*element)); @@ -464,6 +470,21 @@ AliHLTTask& AliHLTTask::operator=(const AliHLTTask&) AliHLTTask::~AliHLTTask() { + TObjLink* lnk=fListDependencies.FirstLink(); + + while (lnk!=NULL) { + AliHLTTask* pTask=(AliHLTTask*)lnk->GetObject(); + pTask->UnsetTarget(this); + lnk=lnk->Next(); + } + lnk=fListTargets.FirstLink(); + + while (lnk!=NULL) { + AliHLTTask* pTask=(AliHLTTask*)lnk->GetObject(); + pTask->UnsetDependency(this); + lnk=lnk->Next(); + } + if (fpComponent) delete fpComponent; fpComponent=NULL; if (fpBlockDataArray) delete[] fpBlockDataArray; @@ -489,6 +510,7 @@ int AliHLTTask::Init(AliHLTConfiguration* pConf, AliHLTComponentHandler* pCH) // currently just set to NULL. iResult=pCH->CreateComponent(fpConfiguration->GetComponentID(), NULL, argc, argv, fpComponent); if (fpComponent || iResult<=0) { + //HLTDebug("component %s (%p) created", fpComponent->GetComponentID(), fpComponent); } else { HLTError("can not find component \"%s\" (%d)", fpConfiguration->GetComponentID(), iResult); } @@ -514,6 +536,7 @@ int AliHLTTask::Deinit() AliHLTComponent* pComponent=GetComponent(); fpComponent=NULL; if (pComponent) { + //HLTDebug("delete component %s (%p)", pComponent->GetComponentID(), pComponent); pComponent->Deinit(); delete pComponent; } else { @@ -631,6 +654,15 @@ int AliHLTTask::SetDependency(AliHLTTask* pDep) return iResult; } +int AliHLTTask::UnsetDependency(AliHLTTask* pDep) +{ + fListDependencies.Remove(pDep); + if (fpConfiguration) { + fpConfiguration->InvalidateSources(); + } + return 0; +} + int AliHLTTask::CheckDependencies() { // see header file for function documentation @@ -694,6 +726,12 @@ int AliHLTTask::SetTarget(AliHLTTask* pTgt) return iResult; } +int AliHLTTask::UnsetTarget(AliHLTTask* pTarget) +{ + fListTargets.Remove(pTarget); + return 0; +} + int AliHLTTask::StartRun() { // see header file for function documentation @@ -880,6 +918,7 @@ int AliHLTTask::ProcessTask(Int_t eventNo) HLTDebug("task %s: component %s ProcessEvent finnished (%d): size=%d blocks=%d", GetName(), pComponent->GetComponentID(), iResult, size, outputBlockCnt); if (iResult>=0 && pTgtBuffer) { iResult=fpDataBuffer->SetSegments(pTgtBuffer, outputBlocks, outputBlockCnt); + delete [] outputBlocks; outputBlocks=NULL; outputBlockCnt=0; } } else { HLTError("task %s: no target buffer available", GetName()); @@ -1037,14 +1076,12 @@ AliHLTConfigurationHandler::AliHLTConfigurationHandler() AliHLTConfigurationHandler::~AliHLTConfigurationHandler() { // see header file for function documentation - TObjLink* lnk=fgListConfigurations.FirstLink(); - while (lnk) { - TObject* obj=lnk->GetObject(); - if (fgListConfigurations.FindObject(obj->GetName())==NULL) { - HLTDebug("delete configuration \"%s\"", obj->GetName()); - delete obj; - } - lnk=lnk->Next(); + TObjLink* lnk=NULL; + while (lnk=fgListConfigurations.FirstLink()) { + AliHLTConfiguration* pConf=(AliHLTConfiguration*)lnk->GetObject(); + HLTDebug("delete configuration \"%s\"", pConf->GetName()); + fgListConfigurations.Remove(lnk); + delete pConf; } } @@ -1056,7 +1093,7 @@ int AliHLTConfigurationHandler::RegisterConfiguration(AliHLTConfiguration* pConf if (FindConfiguration(pConf->GetName()) == NULL) { AliHLTConfiguration* pClone=new AliHLTConfiguration(*pConf); fgListConfigurations.Add(pClone); - HLTDebug("configuration \"%s\" registered", pClone->GetName()); + HLTDebug("configuration \"%s\" (%p) registered from %p", pClone->GetName(), pClone, pConf); // mark all configurations with unresolved dependencies for re-evaluation TObjLink* lnk=fgListConfigurations.FirstLink(); diff --git a/HLT/BASE/AliHLTFileWriter.cxx b/HLT/BASE/AliHLTFileWriter.cxx deleted file mode 100644 index e0cfd10b9b4..00000000000 --- a/HLT/BASE/AliHLTFileWriter.cxx +++ /dev/null @@ -1,304 +0,0 @@ -// $Id$ - -/************************************************************************** - * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * - * * - * Authors: Matthias Richter * - * 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. * - **************************************************************************/ - -/** @file AliHLTFileWriter.cxx - @author Matthias Richter - @date - @brief HLT file writer component implementation. */ - -#if __GNUC__>= 3 -using namespace std; -#endif - -#include "AliHLTFileWriter.h" -#include -#include -#include -#include - -/** the global object for component registration */ -AliHLTFileWriter gAliHLTFileWriter; - -/** ROOT macro for the implementation of ROOT specific class methods */ -ClassImp(AliHLTFileWriter) - -AliHLTFileWriter::AliHLTFileWriter() - : - AliHLTDataSink(), - fBaseName(""), - fExtension(""), - fDirectory(""), - fCurrentFileName(""), - fMode(0) -{ - // see header file for class documentation - // or - // refer to README to build package - // or - // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt -} - -AliHLTFileWriter::AliHLTFileWriter(const AliHLTFileWriter&) - : - AliHLTDataSink(), - fBaseName(""), - fExtension(""), - fDirectory(""), - fCurrentFileName(""), - fMode(0) -{ - // see header file for class documentation - HLTFatal("copy constructor untested"); -} - -AliHLTFileWriter& AliHLTFileWriter::operator=(const AliHLTFileWriter&) -{ - // see header file for class documentation - HLTFatal("assignment operator untested"); - return *this; -} - -AliHLTFileWriter::~AliHLTFileWriter() -{ - // see header file for class documentation - - // file list and file name list are owner of their objects and - // delete all the objects -} - -const char* AliHLTFileWriter::GetComponentID() -{ - // see header file for class documentation - return "FileWriter"; -} - -void AliHLTFileWriter::GetInputDataTypes( vector& list) -{ - // see header file for class documentation - list.clear(); - list.push_back(kAliHLTAnyDataType); -} - -AliHLTComponent* AliHLTFileWriter::Spawn() -{ - // see header file for class documentation - return new AliHLTFileWriter; -} - -int AliHLTFileWriter::DoInit( int argc, const char** argv ) -{ - // see header file for class documentation - int iResult=0; - TString argument=""; - int bMissingParam=0; - for (int i=0; i=0; i++) { - argument=argv[i]; - if (argument.IsNull()) continue; - - // -basename - if (argument.CompareTo("-datafile")==0) { - if ((bMissingParam=(++i>=argc))) break; - fBaseName=argv[i]; - TObjArray* pTokens=fBaseName.Tokenize("."); - if (pTokens) { - int iEntries=pTokens->GetEntries(); - if (iEntries>1) { - int i=0; - fBaseName=((TObjString*)pTokens->At(i++))->GetString(); - while (iAt(i++))->GetString(); - } - fExtension=((TObjString*)pTokens->At(i))->GetString(); - } - delete pTokens; - } - - // -directory - } else if (argument.CompareTo("-directory")==0) { - if ((bMissingParam=(++i>=argc))) break; - fDirectory=argv[i]; - - // -enumeration - } else if (argument.CompareTo("-enumerate")==0) { - SetMode(kEnumerate); - - // -concatenate-blocks - } else if (argument.CompareTo("-concatenate-blocks")==0) { - SetMode(kConcatenateBlocks); - - // -concatenate-events - } else if (argument.CompareTo("-concatenate-events")==0) { - SetMode(kConcatenateEvents); - - } else { - if ((iResult=ScanArgument(argc-i, &argv[i]))==-EINVAL) { - HLTError("unknown argument %s", argument.Data()); - break; - } else if (iResult==-EPROTO) { - bMissingParam=1; - break; - } else if (iResult>=0) { - i+=iResult; - iResult=0; - } - } - } - if (bMissingParam) { - HLTError("missing parameter for argument %s", argument.Data()); - iResult=-EINVAL; - } - if (iResult>=0) { - iResult=InitWriter(); - } - - return iResult; -} - -int AliHLTFileWriter::InitWriter() -{ - // see header file for class documentation - return 0; // note: this doesn't mean 'error' -} - -int AliHLTFileWriter::ScanArgument(int argc, const char** argv) -{ - // see header file for class documentation - - // there are no other arguments than the standard ones - if (argc==0 && argv==NULL) { - // this is just to get rid of the warning "unused parameter" - } - return -EINVAL; -} - -int AliHLTFileWriter::DoDeinit() -{ - // see header file for class documentation - int iResult=CloseWriter(); - ClearMode(kEnumerate); - return iResult; -} - -int AliHLTFileWriter::CloseWriter() -{ - // see header file for class documentation - return 0; // note: this doesn't mean 'error' -} - -int AliHLTFileWriter::DumpEvent( const AliHLTComponentEventData& evtData, - const AliHLTComponentBlockData* blocks, - AliHLTComponentTriggerData& trigData ) -{ - // see header file for class documentation - int iResult=0; - if (CheckMode(kConcatenateEvents)==0) { - // reset the current file name in order to open a new file - // for the first block. If events are concatenated, the current - // file name stays in order to be opended in append mode. - fCurrentFileName=""; - } - for (int n=0; n<(int)evtData.fBlockCnt; n++ ) { - //HLTDebug("block %d out of %d", n, evtData.fBlockCnt); - TString filename; - HLTDebug("dataspec 0x%x", blocks[n].fSpecification); - iResult=BuildFileName(evtData.fEventID, n, blocks[n].fDataType, filename); - ios::openmode filemode=(ios::openmode)0; - if (fCurrentFileName.CompareTo(filename)==0) { - // append to the file - filemode=ios::app; - } else { - // store the file for the next block - fCurrentFileName=filename; - } - if (iResult>=0) { - ofstream dump(filename.Data(), filemode); - if (dump.good()) { - dump.write((const char*)blocks[n].fPtr, blocks[n].fSize); - HLTDebug("wrote %d byte(s) to file %s", blocks[n].fSize, filename.Data()); - } else { - HLTError("can not open file %s for writing", filename.Data()); - iResult=-EBADF; - } - dump.close(); - } - } - if (trigData.fStructSize==0) { - // this is just to get rid of the warning "unused parameter" - } - return iResult; -} - -int AliHLTFileWriter::BuildFileName(const AliHLTEventID_t eventID, const int blockID, const AliHLTComponentDataType& dataType, TString& filename) -{ - // see header file for class documentation - int iResult=0; - //HLTDebug("build file name for event %d block %d", eventID, blockID); - filename=""; - if (!fDirectory.IsNull()) { - filename+=fDirectory; - if (!fDirectory.EndsWith("/")) - filename+="/"; - } - if (!fBaseName.IsNull()) - filename+=fBaseName; - else - filename+="event"; - if (!CheckMode(kConcatenateEvents)) { - if (!CheckMode(kEnumerate)) { - if (eventID!=kAliHLTVoidEventID) { - filename+=Form("_0x%08x", eventID); - } - } else { - filename+=Form("_%d", GetEventCount()); - } - } - if (blockID>=0 && !CheckMode(kConcatenateBlocks)) { - filename+=Form("_0x%x", blockID); - if (dataType!=kAliHLTVoidDataType) { - filename+="_"; - filename+=AliHLTComponent::DataType2Text(dataType).data(); - } - } - if (!fExtension.IsNull()) - filename+="." + fExtension; - filename.ReplaceAll(" ", ""); - return iResult; -} - -int AliHLTFileWriter::SetMode(Short_t mode) -{ - // see header file for class documentation - fMode|=mode; - //HLTDebug("mode set to 0x%x", fMode); - return fMode; -} - -int AliHLTFileWriter::ClearMode(Short_t mode) -{ - // see header file for class documentation - fMode&=~mode; - //HLTDebug("mode set to 0x%x", fMode); - return fMode; -} - -int AliHLTFileWriter::CheckMode(Short_t mode) -{ - // see header file for class documentation - - //HLTDebug("check mode 0x%x for flag 0x%x: %d", fMode, mode, (fMode&mode)!=0); - return (fMode&mode)!=0; -} diff --git a/HLT/BASE/AliHLTFileWriter.h b/HLT/BASE/AliHLTFileWriter.h deleted file mode 100644 index bd994c75aba..00000000000 --- a/HLT/BASE/AliHLTFileWriter.h +++ /dev/null @@ -1,190 +0,0 @@ -// @(#) $Id$ - -#ifndef ALIHLTFILEWRITER_H -#define ALIHLTFILEWRITER_H -/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * - * See cxx source for full Copyright notice */ - -/** @file AliHLTFileWriter.h - @author Matthias Richter - @date - @brief An HLT file dump (data sink) component. -*/ - -#include "AliHLTDataSink.h" -#include - -/** - * @class AliHLTFileWriter - * An HLT data sink component which writes data to file(s). - * - * Component ID: \b FileWriter
- * Library: \b libHLTBase (in order to use the component from the external - * interface, it might be necessary to specify a dummy library with the - * \em -componentlibrary argument). - * - * Mandatory arguments:
- * - * - * Optional arguments:
- * - * \li -datafile filename
- * file name base - * \li -directory directory
- * target directory - * \li -enumerate
- * don't use the event number but an event counter beginning from 0 - * \li -concatenate-blocks
- * concatenate all blocks of one event into one file, this skips - * the block no, and the block data type in the file name - * \li -concatenate-events
- * concatenate all events into one file, this skips the event no, - * the block no, and the block data type in the file name. Currently, - * this implies the -concatenate-blocks option. - * - * The file name is built from the basename, the event number, the block - * number and the data type in the format: - *
- * basename_eventno_blockno_dt
- * 
- * If the basename was not given, \em 'event' ist used instead. A file - * extension after the last dot is separated from the basename and appended - * to the final name. - * - * The class can be used as a base class for file writers. Additional - * argument scan can be implemented in @ref ScanArgument which is called - * for each unknown argument. - * @ingroup alihlt_component - */ -class AliHLTFileWriter : public AliHLTDataSink { - public: - /** standard constructor */ - AliHLTFileWriter(); - /** not a valid copy constructor, defined according to effective C++ style */ - AliHLTFileWriter(const AliHLTFileWriter&); - /** not a valid assignment op, but defined according to effective C++ style */ - AliHLTFileWriter& operator=(const AliHLTFileWriter&); - /** destructor */ - virtual ~AliHLTFileWriter(); - - virtual const char* GetComponentID(); - virtual void GetInputDataTypes( vector& list); - virtual AliHLTComponent* Spawn(); - - protected: - /** - * Init method. - */ - int DoInit( int argc, const char** argv ); - - /** - * Deinit method. - */ - int DoDeinit(); - - /** - * Init the writer. - * The DoInit function is not available for child classes. InitWriter is the - * corresponding function for classes derived from AliHLTFileWriter. - */ - virtual int InitWriter(); - - /** - * Init the writer. - * The DoDeinit function is not available for child classes. CloseWriter is the - * corresponding function for classes derived from AliHLTFileWriter. - */ - virtual int CloseWriter(); - - /** - * Data processing method for the component. - * The function can be overloaded by other file writer components. - * @param evtData event data structure - * @param blocks input data block descriptors - * @param trigData trigger data structure - */ - virtual int DumpEvent( const AliHLTComponentEventData& evtData, - const AliHLTComponentBlockData* blocks, - AliHLTComponentTriggerData& trigData ); - - /** - * Scan one argument and adjacent parameters. - * Can be overloaded by child classes in order to add additional arguments - * beyond the standard arguments of the file publisher. The method is called - * whenever a non-standard argument is recognized. Make sure to return - * -EPROTO if the argument is not recognized be the child. - * @param argc size of the argument array - * @param argv agument array for component initialization - * @return number of processed members of the argv
- * -EINVAL unknown argument
- * -EPROTO parameter for argument missing
- */ - virtual int ScanArgument(int argc, const char** argv); - - /** - * Build file name from eventID data type and the specified directory and basename. - * @param eventID [in] the ID of the event - * @param blockID [in] the ID of the current block - * no block string appended if -1 - * @param dataType [in] the data type of the data block - * no type string appanded if @ref kAliHLTVoidDataType - * @param filename [out] string to receive the file name - */ - int BuildFileName(const AliHLTEventID_t eventID, const int blockID, const AliHLTComponentDataType& dataType, TString& filename); - - /** - * Set a mode flag. - * @return current mode flags - */ - int SetMode(Short_t mode); - - /** - * Clear a mode flag. - * @return current mode flags - */ - int ClearMode(Short_t mode); - - /** - * Check a mode flag. - * @return 1 if flag is set, 0 if not - */ - int CheckMode(Short_t mode); - - /** - * Working modes of the writer - * @internal - */ - enum TWriterMode { - /** - * flag to indicate whether to write each incoming block to separate files - * or all blocks of one event to one file. set = concatenate (one file). - */ - kConcatenateBlocks = 0x1, - - /** - * flag to indicate whether to concatenate incoming blocks of the same type - * for all events to one file. If also @ref kConcatenateBlocks is set, - * or all blocks of all events are written to the same file. - */ - kConcatenateEvents = 0x2, - - /** event enumeration flag */ - kEnumerate = 0x4 - }; - - private: - /** the basename of the output file */ - TString fBaseName; // see above - /** the extension of the output file */ - TString fExtension; // see above - /** target directory */ - TString fDirectory; // see above - /** enumeration format string */ - TString fCurrentFileName; // see above - - /** mode specifier, see @ref TWriterMode */ - Short_t fMode; // see above - - ClassDef(AliHLTFileWriter, 1) -}; -#endif diff --git a/HLT/BASE/AliHLTLogging.cxx b/HLT/BASE/AliHLTLogging.cxx index 6c8a17060a0..9f639a5d30b 100644 --- a/HLT/BASE/AliHLTLogging.cxx +++ b/HLT/BASE/AliHLTLogging.cxx @@ -26,34 +26,17 @@ using namespace std; #endif -#ifndef NOALIROOT_LOGGING -#include "AliLog.h" -#endif #include "AliHLTStdIncludes.h" #include "AliHLTLogging.h" +#include "AliHLTComponentHandler.h" #include "TString.h" #include "Varargs.h" #include #include #include -#ifndef NOALIROOT_LOGGING -/** - * Notification callback for AliRoot logging methods - */ -void LogNotification(AliLog::EType_t level, const char* message) -{ - AliHLTLogging hltlog; - hltlog.SwitchAliLog(0); - hltlog.Logging(kHLTLogInfo, "NotificationHandler", "AliLog", AliHLTLogging::fgLogstr.str().c_str()); - AliHLTLogging::fgLogstr.clear(); - string empty(""); - AliHLTLogging::fgLogstr.str(empty); -} -#endif - /** ROOT macro for the implementation of ROOT specific class methods */ -ClassImp(AliHLTLogging) +ClassImp(AliHLTLogging); AliHLTLogging::AliHLTLogging() : @@ -89,6 +72,7 @@ AliHLTLogging& AliHLTLogging::operator=(const AliHLTLogging&) ostringstream AliHLTLogging::fgLogstr; AliHLTComponentLogSeverity AliHLTLogging::fgGlobalLogFilter=kHLTLogAll; AliHLTfctLogging AliHLTLogging::fgLoggingFunc=NULL; +AliHLTLogging::AliHLTDynamicMessage AliHLTLogging::fgAliLoggingFunc=NULL; int AliHLTLogging::fgUseAliLog=1; AliHLTLogging::~AliHLTLogging() @@ -96,7 +80,9 @@ AliHLTLogging::~AliHLTLogging() // see header file for class documentation } +// the array will be grown dynamically, this is just an initial size TArrayC AliHLTLogging::fgAliHLTLoggingTarget(200); +// the maximum size of the array const int AliHLTLogging::fgkALIHLTLOGGINGMAXBUFFERSIZE=10000; int AliHLTLogging::Init(AliHLTfctLogging pFun) @@ -106,19 +92,34 @@ int AliHLTLogging::Init(AliHLTfctLogging pFun) (*fgLoggingFunc)(NULL/*fParam*/, kHLTLogWarning, "AliHLTLogging::Init", "no key", "overriding previously initialized logging function"); } fgLoggingFunc=pFun; - // older versions of AliLog does not support the notification callback and - // stringstreams, but they support the logging macros in general -#ifndef NOALIROOT_LOGGING -#ifndef NO_ALILOG_NOTIFICATION - AliLog* log=new AliLog; - log->SetLogNotification(LogNotification); - log->SetStreamOutput(&fgLogstr); -#endif // NO_ALILOG_NOTIFICATION -#endif // NOALIROOT_LOGGING return 0; } +int AliHLTLogging::InitAliLogTrap(AliHLTComponentHandler* pHandler) +{ + // see header file for class documentation + int iResult=0; + if (pHandler) { + AliHLTComponentLogSeverity loglevel=pHandler->GetLocalLoggingLevel(); + pHandler->SetLocalLoggingLevel(kHLTLogError); + pHandler->LoadLibrary("libAliHLTUtil.so"); + pHandler->SetLocalLoggingLevel(loglevel); + InitAliDynamicMessageCallback pFunc=(InitAliDynamicMessageCallback)pHandler->FindSymbol("libAliHLTUtil.so", "InitAliDynamicMessageCallback"); + if (pFunc) { + iResult=(*pFunc)(); + } else { + Message(NULL, kHLTLogError, "AliHLTLogging::InitAliLogTrap", "init logging", + "can not initialize AliLog callback"); + iResult=-ENOSYS; + } + } else { + iResult=-EINVAL; + } + + return iResult; +} + int AliHLTLogging::Message(void *param, AliHLTComponentLogSeverity severity, const char* origin, const char* keyword, const char* message) @@ -163,7 +164,7 @@ int AliHLTLogging::Message(void *param, AliHLTComponentLogSeverity severity, return iResult; } -#ifndef NOALIROOT_LOGGING +#if 0 int AliHLTLogging::AliMessage(AliHLTComponentLogSeverity severity, const char* originClass, const char* originFunc, const char* file, int line, const char* message) @@ -260,11 +261,9 @@ int AliHLTLogging::Logging(AliHLTComponentLogSeverity severity, if (fgLoggingFunc) { iResult = (*fgLoggingFunc)(NULL/*fParam*/, severity, origin, keyword, AliHLTLogging::BuildLogString(format, args )); } else { -#ifndef NOALIROOT_LOGGING - if (fgUseAliLog) - iResult=AliMessage(severity, NULL, origin, NULL, 0, AliHLTLogging::BuildLogString(format, args )); + if (fgUseAliLog!=0 && fgAliLoggingFunc!=NULL) + iResult=(*fgAliLoggingFunc)(severity, NULL, origin, NULL, 0, AliHLTLogging::BuildLogString(format, args )); else -#endif iResult=Message(NULL/*fParam*/, severity, origin, keyword, AliHLTLogging::BuildLogString(format, args )); } va_end(args); @@ -299,11 +298,9 @@ int AliHLTLogging::LoggingVarargs(AliHLTComponentLogSeverity severity, if (fgLoggingFunc) { iResult=(*fgLoggingFunc)(NULL/*fParam*/, severity, origin.Data(), GetKeyword(), AliHLTLogging::BuildLogString(NULL, args )); } else { -#ifndef NOALIROOT_LOGGING - if (fgUseAliLog) - iResult=AliMessage(severity, originClass, originFunc, file, line, AliHLTLogging::BuildLogString(NULL, args )); + if (fgUseAliLog!=0 && fgAliLoggingFunc!=NULL) + iResult=(*fgAliLoggingFunc)(severity, originClass, originFunc, file, line, AliHLTLogging::BuildLogString(NULL, args )); else -#endif iResult=Message(NULL/*fParam*/, severity, origin.Data(), GetKeyword(), AliHLTLogging::BuildLogString(NULL, args )); } va_end(args); @@ -326,9 +323,24 @@ void AliHLTLogging::SetGlobalLoggingLevel(AliHLTComponentLogSeverity level) fgGlobalLogFilter=level; } +AliHLTComponentLogSeverity AliHLTLogging::GetGlobalLoggingLevel() +{ + // see header file for class documentation + + return fgGlobalLogFilter; +} + void AliHLTLogging::SetLocalLoggingLevel(AliHLTComponentLogSeverity level) { // see header file for class documentation fLocalLogFilter=level; } + + +AliHLTComponentLogSeverity AliHLTLogging::GetLocalLoggingLevel() +{ + // see header file for class documentation + + return fLocalLogFilter; +} diff --git a/HLT/BASE/AliHLTLogging.h b/HLT/BASE/AliHLTLogging.h index e266319a381..a8b2337791b 100644 --- a/HLT/BASE/AliHLTLogging.h +++ b/HLT/BASE/AliHLTLogging.h @@ -16,6 +16,7 @@ #include "TObject.h" #include "TArrayC.h" +class AliHLTComponentHandler; //#define LOG_PREFIX "" // logging prefix, for later extensions @@ -52,13 +53,15 @@ public: AliHLTLogging& operator=(const AliHLTLogging&); virtual ~AliHLTLogging(); - // set the default key word - // the keyword is intended to simplify the use of logging macros - // + /** set the default key word + * the keyword is intended to simplify the use of logging macros + */ void SetDefaultKeyword(const char* keyword) { fpDefaultKeyword=keyword; } - // set a temporary keyword - // returns the old key value + /** + * Set a temporary keyword + * returns the old key value + */ const char* SetKeyword(const char* keyword) { const char* currentKeyword=fpCurrentKeyword; @@ -66,8 +69,9 @@ public: return currentKeyword; } - // get the current keyword - // + /** + * Get the current keyword + */ const char* GetKeyword() const { if (fpCurrentKeyword) return fpCurrentKeyword; @@ -75,45 +79,71 @@ public: return HLT_DEFAULT_LOG_KEYWORD; } + /** + * Init the AliLogging class for use from external package. + * This initializes the logging callback.
+ * Only deployed by external users of the C wrapper interface, not used + * when running in AliRoot + */ static int Init(AliHLTfctLogging pFun); - // genaral logging function - // + /** + * Init the message trap in AliLog. + * This initializes the AliLog trap, the AliLog class is the logging + * mechanism of AliRoot. The trap can fetch log messages written to + * AliLog, components and detector algorithms can use the AliLog + * mechanism to be as close as possible to Offline habits.
+ * Only used with external users of the C wrapper interface, not used + * when running in AliRoot + */ + static int InitAliLogTrap(AliHLTComponentHandler* pHandler); + + /** + * Genaral logging function + */ int Logging( AliHLTComponentLogSeverity severity, const char* origin, const char* keyword, const char* message, ... ); - // logging function with two origin parameters, used by the log macros - // + /* + * Logging function with two origin parameters, used by the log macros + */ int LoggingVarargs(AliHLTComponentLogSeverity severity, const char* originClass, const char* originFunc, const char* file, int line, ... ) const; - // apply filter, return 1 if message should pass - // + /** + * Apply filter + * @return 1 if message should pass + */ int CheckFilter(AliHLTComponentLogSeverity severity) const; - // set global logging level - // logging filter for all objects - // + /** + * Set global logging level + * logging filter for all objects + */ static void SetGlobalLoggingLevel(AliHLTComponentLogSeverity level); - // set local logging level - // logging filter for individual object - // + /** + * Get global logging level + * logging filter for all objects + */ + static AliHLTComponentLogSeverity GetGlobalLoggingLevel(); + + /** + * Set local logging level + * logging filter for individual object + */ void SetLocalLoggingLevel(AliHLTComponentLogSeverity level); /** - * Print message to stdout + * Get local logging level + * logging filter for individual object */ - static int Message(void * param, AliHLTComponentLogSeverity severity, const char* origin, const char* keyword, const char* message); + AliHLTComponentLogSeverity GetLocalLoggingLevel(); -#ifndef NOALIROOT_LOGGING /** - * Print message through AliRoot log channels. + * Print message to stdout */ - static int AliMessage(AliHLTComponentLogSeverity severity, - const char* originClass, const char* originFunc, - const char* file, int line, const char* message); -#endif + static int Message(void * param, AliHLTComponentLogSeverity severity, const char* origin, const char* keyword, const char* message); /** * Build the log string from format specifier and variadac arguments @@ -139,8 +169,28 @@ public: /** target stream for AliRoot logging methods */ static ostringstream fgLogstr; //! transient + + /** + * The message function for dynamic use. + * In order to avoid dependencies on AliRoot libraries, libHLTbase loads + * the library dynamically and looks for the symbol. + */ + typedef int (*AliHLTDynamicMessage)(AliHLTComponentLogSeverity severity, + const char* originClass, + const char* originFunc, + const char* file, int line, + const char* message); + + /** + * The init function of the message callback for dynamic use. + * In order to avoid dependencies on AliRoot libraries, libHLTbase loads + * the library dynamically and looks for the symbol. + */ + typedef int (*InitAliDynamicMessageCallback)(); protected: + /** the AliRoot logging function */ + static AliHLTDynamicMessage fgAliLoggingFunc; //! transient private: /** the global logging filter */ @@ -164,7 +214,7 @@ private: /** the maximum size of the buffer */ static const int fgkALIHLTLOGGINGMAXBUFFERSIZE; //! transient - + ClassDef(AliHLTLogging, 2) }; diff --git a/HLT/BASE/AliHLTSystem.cxx b/HLT/BASE/AliHLTSystem.cxx index 4c33d4173fc..f7d9ba93cb5 100644 --- a/HLT/BASE/AliHLTSystem.cxx +++ b/HLT/BASE/AliHLTSystem.cxx @@ -64,7 +64,16 @@ AliHLTSystem::AliHLTSystem() memset(&env, 0, sizeof(AliHLTComponentEnvironment)); env.fAllocMemoryFunc=AliHLTSystem::AllocMemory; env.fLoggingFunc=NULL; + AliHLTComponentLogSeverity loglevel=fpComponentHandler->GetLocalLoggingLevel(); + fpComponentHandler->SetLocalLoggingLevel(kHLTLogError); fpComponentHandler->SetEnvironment(&env); + fpComponentHandler->LoadLibrary("libAliHLTUtil.so"); + fgAliLoggingFunc=(AliHLTLogging::AliHLTDynamicMessage)fpComponentHandler->FindSymbol("libAliHLTUtil.so", "AliDynamicMessage"); + fpComponentHandler->SetLocalLoggingLevel(loglevel); + if (fgAliLoggingFunc==NULL) { + HLTError("symbol lookp failure: can not find AliDynamicMessage, switching to HLT logging system"); + } + fpComponentHandler->AnnounceVersion(); } else { HLTFatal("can not create Component Handler"); } @@ -152,6 +161,28 @@ int AliHLTSystem::DeleteConfiguration(AliHLTConfiguration* pConf) return iResult; } +int AliHLTSystem::BuildTaskList(const char* id) +{ + // see header file for class documentation + int iResult=0; + if (id) { + if (fpConfigurationHandler) { + AliHLTConfiguration* pConf=fpConfigurationHandler->FindConfiguration(id); + if (pConf) { + iResult=BuildTaskList(pConf); + } else { + HLTError("unknown configuration \"%s\"", id); + iResult=-EEXIST; + } + } else { + iResult=-EFAULT; + } + } else { + iResult=-EINVAL; + } + return iResult; +} + int AliHLTSystem::BuildTaskList(AliHLTConfiguration* pConf) { // see header file for class documentation @@ -220,9 +251,9 @@ int AliHLTSystem::CleanTaskList() // see header file for class documentation int iResult=0; TObjLink* lnk=NULL; - while ((lnk=fTaskList.FirstLink())!=NULL) { - fTaskList.Remove(lnk); + while ((lnk=fTaskList.LastLink())!=NULL) { delete (lnk->GetObject()); + fTaskList.Remove(lnk); } return iResult; } @@ -257,7 +288,7 @@ int AliHLTSystem::InsertTask(AliHLTTask* pTask) } else { fTaskList.AddFirst(pTask); } - HLTDebug("task \"%s\" inserted", pTask->GetName()); + HLTDebug("task \"%s\" (%p) inserted (size %d)", pTask->GetName(), pTask, sizeof(AliHLTTask)); } else if (iResult>0) { HLTError("can not resolve dependencies for configuration \"%s\" (%d unresolved)", pTask->GetName(), iResult); iResult=-ENOLINK; diff --git a/HLT/BASE/AliHLTSystem.h b/HLT/BASE/AliHLTSystem.h index 7b9103ff606..7a130133406 100644 --- a/HLT/BASE/AliHLTSystem.h +++ b/HLT/BASE/AliHLTSystem.h @@ -82,7 +82,7 @@ class AliHLTSystem : public AliHLTLogging { int DeleteConfiguration(AliHLTConfiguration* pConf); /** - * Build a task list from a configuration object. + * Build a task list * This method is used to build the tasks from the 'master' configuration * objects which are added to the HLT system handler. This is an iterative * process since the task might depend upon other configurations. For each @@ -90,6 +90,14 @@ class AliHLTSystem : public AliHLTLogging { * method will be called iteratively. Finally, after building all tasks which * the current one depends on have been created, the task is inserted to the * list of tasks with the InsertTask method. + * @param pConf configuration name/id + */ + int BuildTaskList(const char* pConf); + + /** + * Build task list from a configuration object. + * This method is kept for backward compatibility. Use the version + * with the configuration name. * @param pConf pointer to configuration to build the task list from */ int BuildTaskList(AliHLTConfiguration* pConf); diff --git a/HLT/BASE/AliHLTTask.h b/HLT/BASE/AliHLTTask.h index 0a1e80b57e9..c6d6bd0245c 100644 --- a/HLT/BASE/AliHLTTask.h +++ b/HLT/BASE/AliHLTTask.h @@ -117,6 +117,14 @@ class AliHLTTask : public TObject, public AliHLTLogging { */ int SetDependency(AliHLTTask* pDep); + /** + * Clear a dependency. + * The ROOT TList touches the object which is in the list, even though + * it shouldn't care about. Thats why all lists have to be cleared before + * objects are deleted. + */ + int UnsetDependency(AliHLTTask* pDep); + /** * Return number of unresolved dependencies. * Iterate through all the configurations the task depends on and check @@ -150,6 +158,14 @@ class AliHLTTask : public TObject, public AliHLTLogging { */ int SetTarget(AliHLTTask* pDep); + /** + * Clear a target. + * The ROOT TList touches the object which is in the list, even though + * it shouldn't care about. Thats why all lists have to be cleared before + * objects are deleted. + */ + int UnsetTarget(AliHLTTask* pTarget); + /** * Prepare the task for event processing. * The method initializes the Data Buffer and calls the diff --git a/HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx b/HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx index 87e14b68155..a770af94018 100644 --- a/HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx +++ b/HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx @@ -43,6 +43,7 @@ int AliHLT_C_Component_InitSystem( AliHLTComponentEnvironment* environ ) gComponentHandler_C = new AliHLTComponentHandler(environ); if ( !gComponentHandler_C ) return EFAULT; + gComponentHandler_C->InitAliLogTrap(gComponentHandler_C); gComponentHandler_C->AnnounceVersion(); return 0; } diff --git a/HLT/BASE/HLTbaseLinkDef.h b/HLT/BASE/HLTbaseLinkDef.h index a0f8e4122ea..e5e99c1fcb4 100644 --- a/HLT/BASE/HLTbaseLinkDef.h +++ b/HLT/BASE/HLTbaseLinkDef.h @@ -19,7 +19,7 @@ #pragma link C++ class AliHLTDataSource; #pragma link C++ class AliHLTDataSink; //#pragma link C++ class AliHLTFilePublisher; -#pragma link C++ class AliHLTFileWriter; +//#pragma link C++ class AliHLTFileWriter; //#pragma link C++ class AliHLTRootFileWriterComponent; //#pragma link C++ class AliHLTRootFilePublisherComponent; #pragma link C++ class AliHLTMessage; diff --git a/HLT/BASE/Makefile.am b/HLT/BASE/Makefile.am index 7e7a7dceb72..7da3c74e5e7 100644 --- a/HLT/BASE/Makefile.am +++ b/HLT/BASE/Makefile.am @@ -12,8 +12,7 @@ SUBDIRS = . util EXTRA_DIST = HLTbaseLinkDef.h -AM_CPPFLAGS = -DMODULE=$(MODULE) \ - -I@ALICE_ROOT@/STEER +AM_CPPFLAGS = -DMODULE=$(MODULE) bin_SCRIPTS = setenv.sh setenv.csh @@ -39,8 +38,6 @@ pkginclude_HEADERS = $(MODULE_HDRS) # linker flags libHLTbase_la_LDFLAGS = -L@ROOTLIBDIR@ \ @ROOTLIBS@ \ - @ALIROOT_LDFLAGS@ \ - @ALIROOT_LIBS@ \ -version-info $(LIBRARY_VERSION) # automatic generation of data and time of library build diff --git a/HLT/BASE/util/AliHLTDynamicAliLog.cxx b/HLT/BASE/util/AliHLTDynamicAliLog.cxx new file mode 100644 index 00000000000..174104533df --- /dev/null +++ b/HLT/BASE/util/AliHLTDynamicAliLog.cxx @@ -0,0 +1,102 @@ +// @(#) $Id$ + +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Authors: Matthias Richter * + * 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. * + **************************************************************************/ + +/** @file AliHLTDynamicAliLog.cxx + @author Matthias Richter + @date + @brief Implementation of dynamically loaded AliLog functionality +*/ + +#include +#include +#include "AliLog.h" +#include "AliHLTLogging.h" +#include "AliHLTDataTypes.h" + +/** + * Notification callback for AliRoot logging methods + */ +void LogNotification(AliLog::EType_t level, const char* message) +{ + // Notification callback for AliRoot logging methods + + AliHLTLogging hltlog; + // in case of the initialized callback we never want to redirect + // HLT logging messages to AliLog (that would be a circular function call) + hltlog.SwitchAliLog(0); + hltlog.Logging(kHLTLogInfo, "NotificationHandler", "AliLog", AliHLTLogging::fgLogstr.str().c_str()); + AliHLTLogging::fgLogstr.clear(); + string empty(""); + AliHLTLogging::fgLogstr.str(empty); +} + +/** + * This is the entry point for AliLog messages. + * The function pointer is fetched by the AliLogging class after libAliHLTUtil + * was loaded dynamically. By that we can keep libHLTbase free of AliRoot + * libraries. + */ +extern "C" int AliDynamicMessage(AliHLTComponentLogSeverity severity, + const char* originClass, const char* originFunc, + const char* file, int line, const char* message) +{ + // see header file for class documentation + + switch (severity) { + case kHLTLogBenchmark: + AliLog::Message(AliLog::kInfo, message, "HLT", originClass, originFunc, file, line); + break; + case kHLTLogDebug: + AliLog::Message(AliLog::kDebug, message, "HLT", originClass, originFunc, file, line); + break; + case kHLTLogInfo: + AliLog::Message(AliLog::kInfo, message, "HLT", originClass, originFunc, file, line); + break; + case kHLTLogWarning: + AliLog::Message(AliLog::kWarning, message, "HLT", originClass, originFunc, file, line); + break; + case kHLTLogError: + AliLog::Message(AliLog::kError, message, "HLT", originClass, originFunc, file, line); + break; + case kHLTLogFatal: + AliLog::Message(AliLog::kWarning, message, "HLT", originClass, originFunc, file, line); + break; + default: + break; + } + return 0; +} + +/** + * Init the AliLog callback. + * If libHLTbase is used within AliRoot, no message callback is initialized since + * all logging happens through AliRoot. If externally used by other frameworks (e.g. + * PubSub), all messages from components to AliLog must be trapped and redirected + * to the external callback. + */ +extern "C" int InitAliDynamicMessageCallback() +{ + // older versions of AliLog does not support the notification callback and + // stringstreams, but they support the logging macros in general +#ifndef NO_ALILOG_NOTIFICATION + AliLog* log=new AliLog; + log->SetLogNotification(LogNotification); + log->SetStreamOutput(&AliHLTLogging::fgLogstr); + return 0; +#endif // NO_ALILOG_NOTIFICATION + return -ENOSYS; +} diff --git a/HLT/BASE/util/Makefile.am b/HLT/BASE/util/Makefile.am index 434af5cce40..de5862e40cf 100644 --- a/HLT/BASE/util/Makefile.am +++ b/HLT/BASE/util/Makefile.am @@ -34,7 +34,11 @@ libAliHLTUtil_la_SOURCES = $(MODULE_SRCS) pkginclude_HEADERS = $(MODULE_HDRS) # linker flags -libAliHLTUtil_la_LDFLAGS = -version-info $(LIBRARY_VERSION) +libAliHLTUtil_la_LDFLAGS = -L@ROOTLIBDIR@ \ + @ROOTLIBS@ \ + @ALIROOT_LDFLAGS@ \ + @ALIROOT_LIBS@ \ + -version-info $(LIBRARY_VERSION) # automatic generation of data and time of library build COMPILE_INFO = HLTBaseCompileInfo.cxx diff --git a/HLT/ChangeLog b/HLT/ChangeLog index 54308f38183..60b19aab470 100644 --- a/HLT/ChangeLog +++ b/HLT/ChangeLog @@ -1,3 +1,9 @@ +2007-04-27 HLT base + - memory leaks corrected + - AliLog support moved to libAliHLTUtil in order to keep + - libHLTbase free of AliRoot dependencies + - dynamic loeding of AliLog support + - AliHLTFileWriter moved to libAliHLTUtil 2007-04-17 HLT sample applications - publisher for AliLoader trees added - sample analysis chain added tp sample lib diff --git a/HLT/PHOS/Makefile.am b/HLT/PHOS/Makefile.am index 8aaba9c2662..bea0973b42f 100644 --- a/HLT/PHOS/Makefile.am +++ b/HLT/PHOS/Makefile.am @@ -6,7 +6,8 @@ MODULE = AliHLTPHOS EXTRA_DIST = AliHLTPHOSLinkDef.h AM_CPPFLAGS = @ALIROOT_CPPFLAGS@ \ - -I$(top_srcdir)/BASE + -I$(top_srcdir)/BASE \ + -I$(top_srcdir)/BASE/util # library definition lib_LTLIBRARIES = libAliHLTPHOS.la @@ -70,6 +71,7 @@ pkginclude_HEADERS = $(CLASS_HDRS) \ # version info and linking flags for the library +libAliHLTPHOS_la_LIBADD = $(top_builddir)/BASE/util/libAliHLTUtil.la libAliHLTPHOS_la_LDFLAGS = -L@ROOTLIBDIR@ \ @ROOTLIBS@ \ @ALIROOT_LDFLAGS@ \ diff --git a/HLT/SampleLib/tutorial.c b/HLT/SampleLib/tutorial.c index 76f64f2c926..bb01efbca45 100644 --- a/HLT/SampleLib/tutorial.c +++ b/HLT/SampleLib/tutorial.c @@ -63,7 +63,7 @@ You can run the following macro from the AliRoot promt. AliHLTConfiguration publisher("fp1", "FilePublisher", NULL, "-datafile some-data.dat"); AliHLTConfiguration copy("cp", "Dummy", "fp1", "output_percentage 80"); AliHLTConfiguration sink1("sink1", "FileWriter", "cp", NULL); - gHLT.BuildTaskList(&sink1); + gHLT.BuildTaskList("sink1"); gHLT.Run(); } diff --git a/HLT/libAliHLTPHOS.pkg b/HLT/libAliHLTPHOS.pkg index a0bda82ac2e..aeccfdd9aa7 100644 --- a/HLT/libAliHLTPHOS.pkg +++ b/HLT/libAliHLTPHOS.pkg @@ -90,7 +90,7 @@ MODULE_SRCS:= PHOS/AliHLTPHOSPulseGenerator.cxx \ PHOS/AliHLTPHOSHistogramProducerComponent.cxx -EINCLUDE+= HLT/BASE HLT/src HLT/hough HLT/comp HLT/misc HLT/ITS HLT/MUON/src TPC ITS MUON STEER RAW +EINCLUDE+= HLT/BASE HLT/BASE/util HLT/src HLT/hough HLT/comp HLT/misc HLT/ITS HLT/MUON/src TPC ITS MUON STEER RAW EDEFINE := ${HLTDEFS} PACKCXXFLAGS := ${HLTCXXFLAGS} diff --git a/HLT/libAliHLTUtil.pkg b/HLT/libAliHLTUtil.pkg index 9c60815054e..116adc095ed 100644 --- a/HLT/libAliHLTUtil.pkg +++ b/HLT/libAliHLTUtil.pkg @@ -4,12 +4,15 @@ include $(MODDIR)/hlt.conf MODULE_SRCS= AliHLTFilePublisher.cxx \ + AliHLTFileWriter.cxx \ AliHLTRootFilePublisherComponent.cxx \ AliHLTRootFileWriterComponent.cxx \ AliHLTLoaderPublisherComponent.cxx \ + AliHLTDynamicAliLog.cxx \ AliHLTAgentUtil.cxx CLASS_HDRS:= AliHLTFilePublisher.h \ + AliHLTFileWriter.h \ AliHLTRootFilePublisherComponent.h \ AliHLTRootFileWriterComponent.h \ AliHLTLoaderPublisherComponent.h \ diff --git a/HLT/libHLTbase.pkg b/HLT/libHLTbase.pkg index 91b07881e3f..55b146cb4e2 100644 --- a/HLT/libHLTbase.pkg +++ b/HLT/libHLTbase.pkg @@ -14,7 +14,6 @@ MODULE_SRCS= AliHLTComponent.cxx \ AliHLTConsumerDescriptor.cxx \ AliHLTDataSource.cxx \ AliHLTDataSink.cxx \ - AliHLTFileWriter.cxx \ AliHLTOfflineInterface.cxx \ AliHLTOfflineDataSource.cxx \ AliHLTOfflineDataSink.cxx \ @@ -33,7 +32,6 @@ CLASS_HDRS:= AliHLTComponent.h \ AliHLTConsumerDescriptor.h \ AliHLTDataSource.h \ AliHLTDataSink.h \ - AliHLTFileWriter.h \ AliHLTOfflineInterface.h \ AliHLTOfflineDataSource.h \ AliHLTOfflineDataSink.h \ @@ -46,8 +44,9 @@ MODULE_HDRS:= $(CLASS_HDRS) \ AliHLTDefinitions.h \ AliHLTStdIncludes.h -DHDR:= BASE/HLTbaseLinkDef.h -CINTAUTOLINK:= +#DHDR:= BASE/HLTbaseLinkDef.h +DHDR:= +CINTAUTOLINK:= 1 SRCS:=$(patsubst %,BASE/%,$(MODULE_SRCS)) CINTHDRS:=$(patsubst %,BASE/%,$(CLASS_HDRS)) -- 2.43.0