From: richterm Date: Fri, 19 Oct 2007 13:08:28 +0000 (+0000) Subject: further work on HLTOUT framework X-Git-Url: http://git.uio.no/git/?a=commitdiff_plain;h=4de7334f2d94b0375e7f1726eef6f8d5184c1ec1;p=u%2Fmrichter%2FAliRoot.git further work on HLTOUT framework --- diff --git a/HLT/BASE/AliHLTOUT.cxx b/HLT/BASE/AliHLTOUT.cxx index d2497907f96..cab6fc2f60d 100644 --- a/HLT/BASE/AliHLTOUT.cxx +++ b/HLT/BASE/AliHLTOUT.cxx @@ -21,19 +21,27 @@ @date @brief The control class for HLTOUT data. */ - // see header file for class documentation - // or - // refer to README to build package - // or - // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt +// see header file for class documentation +// or +// refer to README to build package +// or +// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt +#include #include "AliHLTOUT.h" /** ROOT macro for the implementation of ROOT specific class methods */ ClassImp(AliHLTOUT) AliHLTOUT::AliHLTOUT() -{ + : + fSearchDataType(kAliHLTVoidDataType), + fSearchSpecification(kAliHLTVoidDataSpec), + fbLocked(0), + fBlockDescList(), + fCurrent(fBlockDescList.begin()), + fpBuffer(NULL) +{ // see header file for class documentation // or // refer to README to build package @@ -42,6 +50,83 @@ AliHLTOUT::AliHLTOUT() } AliHLTOUT::~AliHLTOUT() -{ +{ + // see header file for class documentation +} + +int AliHLTOUT::GetNofDataBlocks() +{ + // see header file for class documentation + return fBlockDescList.size(); +} + +int AliHLTOUT::SelectFirstDataBlock(AliHLTComponentDataType dt, AliHLTUInt32_t spec) +{ + // see header file for class documentation + if (fbLocked) return -EPERM; + fCurrent=fBlockDescList.begin(); + fSearchDataType=dt; + fSearchSpecification=spec; + return SelectNextDataBlock(); +} + +int AliHLTOUT::SelectNextDataBlock() +{ + // see header file for class documentation + if (fbLocked) return -EPERM; + int iResult=-ENOENT; + while (fCurrent!=fBlockDescList.end() && iResult==-ENOENT) { + if ((fSearchDataType==kAliHLTAnyDataType || (*fCurrent)==fSearchDataType) && + fSearchSpecification==kAliHLTVoidDataSpec || (*fCurrent)==fSearchSpecification) { + iResult=0; + } + } + return iResult; +} + +int AliHLTOUT::GetDataBlockDescription(AliHLTComponentDataType& dt, AliHLTUInt32_t& spec) +{ + // see header file for class documentation + int iResult=-ENOENT; + if (fCurrent!=fBlockDescList.end()) { + iResult=0; + dt=(*fCurrent); + spec=(*fCurrent); + } + return iResult; +} + +int AliHLTOUT::GetDataBuffer(const AliHLTUInt8_t* &pBuffer, AliHLTUInt32_t& size) +{ + // see header file for class documentation + int iResult=-ENOENT; + pBuffer=NULL; + size=0; + if (fCurrent!=fBlockDescList.end()) { + if ((iResult=GetDataBuffer((*fCurrent).GetIndex(), pBuffer, size))>=0) { + fpBuffer=pBuffer; + } + } + return iResult; +} + +int AliHLTOUT::ReleaseDataBuffer(const AliHLTUInt8_t* pBuffer) +{ + // see header file for class documentation + int iResult=0; + if (pBuffer==fpBuffer) { + fpBuffer=NULL; + } else { + HLTWarning("buffer %p does not match the provided one %p", pBuffer, fpBuffer); + } + return iResult; +} + +int AliHLTOUT::AddBlockDescriptor(const AliHLTOUTBlockDescriptor desc) +{ // see header file for class documentation + if (!fbLocked) return -EPERM; + int iResult=0; + fBlockDescList.push_back(desc); + return iResult; } diff --git a/HLT/BASE/AliHLTOUT.h b/HLT/BASE/AliHLTOUT.h index 8c8920c3e0b..055d867b12f 100644 --- a/HLT/BASE/AliHLTOUT.h +++ b/HLT/BASE/AliHLTOUT.h @@ -17,7 +17,9 @@ // refer to README to build package // or // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt + */ +#include #include "AliHLTLogging.h" /** @@ -36,7 +38,110 @@ class AliHLTOUT : public AliHLTLogging { /** standard destructor */ virtual ~AliHLTOUT(); + /** + * Get number of data blocks in the HLTOUT data + */ + int GetNofDataBlocks(); + + /** + * Select the first data block of a certain data type and specification. + * The selection criteria can be of kAliHLTAnyDataType and/or + * kAliHLTVoidDataSpec in order to be ignored and just match any data block. + * @param dt [in] data type to match
+ * @param spec [in] data specification to match
+ * @return identifier >=0 if success, neg. error code if failed
+ * -ENOENT if no block found
+ * -EPERM if access denied (object locked) + */ + int SelectFirstDataBlock(AliHLTComponentDataType dt, AliHLTUInt32_t spec); + + /** + * Select the next data block of data type and specification of the previous + * call to @ref SelectFirstDataBlock. + * @return identifier >=0 if success, neg. error code if failed
+ * -ENOENT if no block found
+ * -EPERM if access denied (object locked) + */ + int SelectNextDataBlock(); + + /** + * Get properties of the selected data block. + * @param dt [out] data type of the selected block + * @param spec [out] data specification of the selected block + */ + int GetDataBlockDescription(AliHLTComponentDataType& dt, AliHLTUInt32_t& spec); + + /** + * Get buffer of the selected data block. + * @param pBuffer [out] buffer of the selected data block + * @param size [out] size of the selected data block + */ + int GetDataBuffer(const AliHLTUInt8_t* &pBuffer, AliHLTUInt32_t& size); + + /** + * Release buffer after use. + * @param pBuffer [in] buffer of the selected data block + */ + int ReleaseDataBuffer(const AliHLTUInt8_t* pBuffer); + + /** + * Locking guard for the AliHLTOUT object. + * If the object is locked, the selection of data blocks can not be changed. + */ + class AliHLTOUTLockGuard { + public: + /** constructor */ + AliHLTOUTLockGuard(AliHLTOUT* pInstance) : fpInstance(pInstance) + {if (fpInstance) fpInstance->fbLocked=1;} + /** destructor */ + ~AliHLTOUTLockGuard() + {if (fpInstance) fpInstance->fbLocked=0;} + + private: + /** standard constructor prohibited */ + AliHLTOUTLockGuard(); + /** copy constructor prohibited */ + AliHLTOUTLockGuard(const AliHLTOUTLockGuard&); + /** assignment operator prohibited */ + AliHLTOUTLockGuard& operator=(const AliHLTOUTLockGuard&); + + /** the AliHLTOUT instance the guard is locking */ + AliHLTOUT* fpInstance; //!transient + }; + + /** + * Block descriptor. + */ + class AliHLTOUTBlockDescriptor { + public: + AliHLTOUTBlockDescriptor(AliHLTComponentDataType dt, AliHLTUInt32_t spec, AliHLTUInt32_t index) + : fDataType(dt), fSpecification(spec), fIndex(index) {}; + ~AliHLTOUTBlockDescriptor() {} + + operator AliHLTComponentDataType() const {return fDataType;} + operator AliHLTUInt32_t() const {return fSpecification;} + int operator==(AliHLTComponentDataType dt) const {return dt==fDataType;} + int operator==(AliHLTUInt32_t spec) const {return spec==fSpecification;} + + AliHLTUInt32_t GetIndex() const {return fIndex;} + private: + /** data type of the block */ + AliHLTComponentDataType fDataType; //!transient + /** data specification of the block */ + AliHLTUInt32_t fSpecification; //!transient + /** index in the data stream */ + AliHLTUInt32_t fIndex; //!transient + }; + protected: + /** + * Add a block descriptor. + * This is done by the child classes generating the index. The AliHLTOUT + * object must be locked for index generation. + * @param desc the block descriptor + * @return 0 if success, -EPERM if access denied + */ + int AddBlockDescriptor(const AliHLTOUTBlockDescriptor desc); private: /** copy constructor prohibited */ @@ -44,6 +149,39 @@ class AliHLTOUT : public AliHLTLogging { /** assignment operator prohibited */ AliHLTOUT& operator=(const AliHLTOUT&); + /** + * Generate the index of the HLTOUT data. + * Must be implemented by the child classes. + */ + virtual int GenerateIndex()=0; + + /** + * Get the data buffer + * @param index [in] index of the block + * @param pBuffer [out] buffer of the selected data block + * @param size [out] size of the selected data block + */ + virtual int GetDataBuffer(AliHLTUInt32_t index, const AliHLTUInt8_t* &pBuffer, + AliHLTUInt32_t& size)=0; + + /** data type for the current block search, set from @ref SelectFirstDataBlock */ + AliHLTComponentDataType fSearchDataType; //!transient + + /** data specification for the current block search */ + AliHLTUInt32_t fSearchSpecification; //!transient + + /** instance locked or not */ + int fbLocked; //!transient + + /** list of block descriptors */ + vector fBlockDescList; //!transient + + /** current position in the list */ + vector::iterator fCurrent; //!transient + + /** data buffer under processing */ + const AliHLTUInt8_t* fpBuffer; //!transient + ClassDef(AliHLTOUT, 0) }; #endif diff --git a/HLT/BASE/AliHLTOUTHomerBuffer.cxx b/HLT/BASE/AliHLTOUTHomerBuffer.cxx new file mode 100644 index 00000000000..0f95b3ca4ba --- /dev/null +++ b/HLT/BASE/AliHLTOUTHomerBuffer.cxx @@ -0,0 +1,77 @@ +// $Id$ + +/************************************************************************** + * This file is property of and copyright by the ALICE HLT Project * + * ALICE Experiment at CERN, All rights reserved. * + * * + * Primary Authors: Matthias Richter * + * for The ALICE HLT 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 AliHLTOUTHomerBuffer.cxx + @author Matthias Richter + @date + @brief HLTOUT data wrapper for AliRawReader. */ + +// see header file for class documentation +// or +// refer to README to build package +// or +// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt + +#include +#include "AliHLTOUTHomerBuffer.h" +#include "AliHLTHOMERReader.h" + +/** ROOT macro for the implementation of ROOT specific class methods */ +ClassImp(AliHLTOUTHomerBuffer) + +AliHLTOUTHomerBuffer::AliHLTOUTHomerBuffer(const AliHLTUInt8_t* pBuffer) + : + AliHLTOUT(), + fpBuffer(pBuffer), + fpReader(NULL) +{ + // see header file for class documentation + // or + // refer to README to build package + // or + // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt +} + +AliHLTOUTHomerBuffer::~AliHLTOUTHomerBuffer() +{ + // see header file for class documentation +} + +int AliHLTOUTHomerBuffer::GenerateIndex() +{ + // see header file for class documentation + int iResult=0; + return iResult; +} + +int AliHLTOUTHomerBuffer::GetDataBuffer(AliHLTUInt32_t index, const AliHLTUInt8_t* &pBuffer, + AliHLTUInt32_t& size) +{ + // see header file for class documentation + int iResult=0; + if (fpReader) { + if ((pBuffer=static_cast(fpReader->GetBlockData(index)))!=NULL) { + size=fpReader->GetBlockDataLength(index); + } else { + iResult=-ENOENT; + } + } else { + iResult=-ENODEV; + } + return iResult; +} diff --git a/HLT/BASE/AliHLTOUTHomerBuffer.h b/HLT/BASE/AliHLTOUTHomerBuffer.h new file mode 100644 index 00000000000..a1f52c08121 --- /dev/null +++ b/HLT/BASE/AliHLTOUTHomerBuffer.h @@ -0,0 +1,68 @@ +//-*- Mode: C++ -*- +// @(#) $Id$ + +#ifndef ALIHLTOUTHOMERBUFFER_H +#define ALIHLTOUTHOMERBUFFER_H +/* This file is property of and copyright by the ALICE HLT Project * + * ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/** @file AliHLTOUTHomerBuffer.h + @author Matthias Richter + @date + @brief HLTOUT data wrapper for a data buffer. + +// see below for class documentation +// or +// refer to README to build package +// or +// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt + */ +#include "AliHLTOUT.h" + +class HOMERReader; + +/** + * @class AliHLTOUTHomerBuffer + * Handler of HLTOUT data for buffer input. + */ +class AliHLTOUTHomerBuffer : public AliHLTOUT { + public: + /** constructor */ + AliHLTOUTHomerBuffer(const AliHLTUInt8_t* pBuffer); + /** destructor */ + virtual ~AliHLTOUTHomerBuffer(); + + protected: + + private: + /** standard constructor prohibited */ + AliHLTOUTHomerBuffer(); + /** copy constructor prohibited */ + AliHLTOUTHomerBuffer(const AliHLTOUTHomerBuffer&); + /** assignment operator prohibited */ + AliHLTOUTHomerBuffer& operator=(const AliHLTOUTHomerBuffer&); + + /** + * Generate the index of the HLTOUT data from the data buffer. + */ + virtual int GenerateIndex(); + + /** + * Get the data buffer + * @param index [in] index of the block + * @param pBuffer [out] buffer of the selected data block + * @param size [out] size of the selected data block + */ + virtual int GetDataBuffer(AliHLTUInt32_t index, const AliHLTUInt8_t* &pBuffer, + AliHLTUInt32_t& size); + + /** data buffer */ + const AliHLTUInt8_t* fpBuffer; //! transient + + /** instance of the HOMER reader */ + HOMERReader* fpReader; //!transient + + ClassDef(AliHLTOUTHomerBuffer, 0) +}; +#endif diff --git a/HLT/libHLTbase.pkg b/HLT/libHLTbase.pkg index f9e59d7285d..17885ce6ca4 100644 --- a/HLT/libHLTbase.pkg +++ b/HLT/libHLTbase.pkg @@ -25,6 +25,7 @@ CLASS_HDRS:= AliHLTComponent.h \ AliHLTOfflineDataSink.h \ AliHLTModuleAgent.h \ AliHLTOUT.h \ + AliHLTOUTHomerBuffer.h \ AliHLTOUTHandler.h \ AliHLTMemoryFile.h \ AliHLTMessage.h @@ -48,4 +49,7 @@ PACKCXXFLAGS := ${HLTCXXFLAGS} PACKCFLAGS := ${HLTCLFAGS} PACKDCXXFLAGS:= ${HLTDCXXFLAGS} -EINCLUDE := HLT/BASE +# the libHLTbase depends on the abstract interface of the monitoring reader +# and needs include patch HLT/BASE/HOMER because of that. There is no library +# dependency. Objects are intantianted dynamically. +EINCLUDE := HLT/BASE HLT/BASE/HOMER