From: richterm Date: Thu, 18 Oct 2007 09:12:49 +0000 (+0000) Subject: code cleanup and coding conventions X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=commitdiff_plain;h=2be3f004f2c0326b310b1bc5fc2c67e493d34dce code cleanup and coding conventions --- diff --git a/HLT/BASE/AliHLTComponent.cxx b/HLT/BASE/AliHLTComponent.cxx index ae8e5b6410b..97da0d70096 100644 --- a/HLT/BASE/AliHLTComponent.cxx +++ b/HLT/BASE/AliHLTComponent.cxx @@ -95,7 +95,7 @@ AliHLTComponent::~AliHLTComponent() CleanupInputObjects(); if (fpStopwatches!=NULL) delete fpStopwatches; fpStopwatches=NULL; - vector::iterator element=fMemFiles.begin(); + AliHLTMemoryFilePList::iterator element=fMemFiles.begin(); while (element!=fMemFiles.end()) { if (*element) { if ((*element)->IsClosed()==0) { @@ -216,7 +216,7 @@ int AliHLTComponent::DoDeinit() return 0; } -int AliHLTComponent::GetOutputDataTypes(vector& /*tgtList*/) +int AliHLTComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& /*tgtList*/) { HLTLogKeyword("dummy"); return 0; @@ -264,7 +264,7 @@ void* AliHLTComponent::AllocMemory( unsigned long size ) return NULL; } -int AliHLTComponent::MakeOutputDataBlockList( const vector& blocks, AliHLTUInt32_t* blockCount, +int AliHLTComponent::MakeOutputDataBlockList( const AliHLTComponentBlockDataList& blocks, AliHLTUInt32_t* blockCount, AliHLTComponentBlockData** outputBlocks ) { // see header file for function documentation @@ -306,14 +306,14 @@ int AliHLTComponent::GetEventDoneData( unsigned long size, AliHLTComponentEventD return -ENOSYS; } -int AliHLTComponent::FindMatchingDataTypes(AliHLTComponent* pConsumer, vector* tgtList) +int AliHLTComponent::FindMatchingDataTypes(AliHLTComponent* pConsumer, AliHLTComponentDataTypeList* tgtList) { // see header file for function documentation int iResult=0; if (pConsumer) { - vector ctlist; + AliHLTComponentDataTypeList ctlist; ((AliHLTComponent*)pConsumer)->GetInputDataTypes(ctlist); - vector::iterator type=ctlist.begin(); + AliHLTComponentDataTypeList::iterator type=ctlist.begin(); //AliHLTComponentDataType ouptdt=GetOutputDataType(); //PrintDataTypeContent(ouptdt, "publisher \'%s\'"); while (type!=ctlist.end() && iResult==0) { @@ -936,7 +936,7 @@ int AliHLTComponent::CloseMemoryFile(AliHLTMemoryFile* pFile) // see header file for function documentation int iResult=0; if (pFile) { - vector::iterator element=fMemFiles.begin(); + AliHLTMemoryFilePList::iterator element=fMemFiles.begin(); int i=0; while (element!=fMemFiles.end() && iResult>=0) { if (*element && *element==pFile) { @@ -1033,7 +1033,7 @@ int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData, } } - vector blockData; + AliHLTComponentBlockDataList blockData; { // dont delete, sets the scope for the stopwatch guard ALIHLTCOMPONENT_DA_STOPWATCH(); iResult=DoProcessing(evtData, blocks, trigData, outputPtr, size, blockData, edd); @@ -1043,7 +1043,7 @@ int AliHLTComponent::ProcessEvent( const AliHLTComponentEventData& evtData, //HLTDebug("got %d block(s) via high level interface", fOutputBlocks.size()); // sync memory files and descriptors - vector::iterator element=fMemFiles.begin(); + AliHLTMemoryFilePList::iterator element=fMemFiles.begin(); int i=0; while (element!=fMemFiles.end() && iResult>=0) { if (*element) { diff --git a/HLT/BASE/AliHLTComponent.h b/HLT/BASE/AliHLTComponent.h index fe2942a6066..9c640f7a685 100644 --- a/HLT/BASE/AliHLTComponent.h +++ b/HLT/BASE/AliHLTComponent.h @@ -47,8 +47,18 @@ typedef AliHLTComponentEventDoneData AliHLTComponent_EventDoneData; class AliHLTComponentHandler; class TObjArray; class TStopwatch; +class AliHLTComponent; class AliHLTMemoryFile; +/** list of component data type structures */ +typedef vector AliHLTComponentDataTypeList; +/** list of component block data structures */ +typedef vector AliHLTComponentBlockDataList; +/** list of component pointers */ +typedef vector AliHLTComponentPList; +/** list of memory file pointers */ +typedef vector AliHLTMemoryFilePList; + /** * @class AliHLTComponent * Base class of HLT data processing components. @@ -310,7 +320,7 @@ class AliHLTComponent : public AliHLTLogging { virtual int DoProcessing( const AliHLTComponentEventData& evtData, const AliHLTComponentBlockData* blocks, AliHLTComponentTriggerData& trigData, AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size, - vector& outputBlocks, + AliHLTComponentBlockDataList& outputBlocks, AliHLTComponentEventDoneData*& edd ) = 0; // Information member functions for registration. @@ -335,7 +345,7 @@ class AliHLTComponent : public AliHLTLogging { * The function is pure virtual and must be implemented by the child class. * @return list of data types in the vector reference */ - virtual void GetInputDataTypes( vector& ) = 0; + virtual void GetInputDataTypes( AliHLTComponentDataTypeList& ) = 0; /** * Get the output data type of the component. @@ -353,7 +363,7 @@ class AliHLTComponent : public AliHLTLogging { * @param tgtList list to receive the data types * @return no of output data types, data types in the target list */ - virtual int GetOutputDataTypes(vector& tgtList); + virtual int GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList); /** * Get a ratio by how much the data volume is shrinked or enhanced. @@ -381,7 +391,7 @@ class AliHLTComponent : public AliHLTLogging { * @param tgtList reference to a vector list to receive the matching data types. * @return >= 0 success, neg. error code if failed */ - int FindMatchingDataTypes(AliHLTComponent* pConsumer, vector* tgtList); + int FindMatchingDataTypes(AliHLTComponent* pConsumer, AliHLTComponentDataTypeList* tgtList); /** * Set the global component handler. @@ -575,7 +585,7 @@ class AliHLTComponent : public AliHLTLogging { * framework. Function pointers are transferred via the @ref * AliHLTComponentEnvironment structure. */ - int MakeOutputDataBlockList( const vector& blocks, AliHLTUInt32_t* blockCount, + int MakeOutputDataBlockList( const AliHLTComponentBlockDataList& blocks, AliHLTUInt32_t* blockCount, AliHLTComponentBlockData** outputBlocks ); /** @@ -1056,13 +1066,13 @@ class AliHLTComponent : public AliHLTLogging { AliHLTUInt32_t fOutputBufferFilled; // see above /** list of ouput block data descriptors */ - vector fOutputBlocks; // see above + AliHLTComponentBlockDataList fOutputBlocks; // see above /** stopwatch array */ TObjArray* fpStopwatches; //! transient /** array of memory files AliHLTMemoryFile */ - vector fMemFiles; //! transient + AliHLTMemoryFilePList fMemFiles; //! transient /** descriptor of the current run */ AliHLTRunDesc* fpRunDesc; //! transient diff --git a/HLT/BASE/AliHLTDataBuffer.cxx b/HLT/BASE/AliHLTDataBuffer.cxx index 84159eb5da6..7c326dc5815 100644 --- a/HLT/BASE/AliHLTDataBuffer.cxx +++ b/HLT/BASE/AliHLTDataBuffer.cxx @@ -40,6 +40,9 @@ using namespace std; //#include //#include "AliHLTSystem.h" +typedef vector AliHLTDataSegmentList; +typedef vector AliHLTRawBufferPList; + /** ROOT macro for the implementation of ROOT specific class methods */ ClassImp(AliHLTDataBuffer) @@ -65,8 +68,8 @@ AliHLTDataBuffer::AliHLTDataBuffer() } int AliHLTDataBuffer::fgNofInstances=0; -vector AliHLTDataBuffer::fgFreeBuffers; -vector AliHLTDataBuffer::fgActiveBuffers; +AliHLTRawBufferPList AliHLTDataBuffer::fgFreeBuffers; +AliHLTRawBufferPList AliHLTDataBuffer::fgActiveBuffers; AliHLTUInt32_t AliHLTDataBuffer::fgMargin=1024; AliHLTLogging AliHLTDataBuffer::fgLogging; const Int_t AliHLTDataBuffer::fgkSafetyPatternSize=16; @@ -104,15 +107,15 @@ int AliHLTDataBuffer::SetConsumer(AliHLTComponent* pConsumer) return iResult; } -int AliHLTDataBuffer::FindMatchingDataBlocks(const AliHLTComponent* pConsumer, vector* tgtList) +int AliHLTDataBuffer::FindMatchingDataBlocks(const AliHLTComponent* pConsumer, AliHLTComponentDataTypeList* tgtList) { // see header file for function documentation int iResult=0; if (pConsumer) { - vector segments; + AliHLTDataSegmentList segments; if ((iResult=FindMatchingDataSegments(pConsumer, segments))>=0) { if (tgtList) { - vector::iterator segment=segments.begin(); + AliHLTDataSegmentList::iterator segment=segments.begin(); while (segment!=segments.end()) { tgtList->push_back((*segment).fDataType); segment++; @@ -139,11 +142,11 @@ int AliHLTDataBuffer::FindMatchingDataSegments(const AliHLTComponent* pConsumer, return iResult; if (pConsumer) { - vector dtlist; + AliHLTComponentDataTypeList dtlist; ((AliHLTComponent*)pConsumer)->GetInputDataTypes(dtlist); - vector::iterator segment=fSegments.begin(); + AliHLTDataSegmentList::iterator segment=fSegments.begin(); while (segment!=fSegments.end()) { - vector::iterator type=dtlist.begin(); + AliHLTComponentDataTypeList::iterator type=dtlist.begin(); while (type!=dtlist.end()) { if ((*segment).fDataType==(*type) || (*type)==kAliHLTAnyDataType) { @@ -169,13 +172,13 @@ int AliHLTDataBuffer::Subscribe(const AliHLTComponent* pConsumer, AliHLTComponen if (fpBuffer) { AliHLTConsumerDescriptor* pDesc=FindConsumer(pConsumer, fConsumers); if (pDesc) { - vector tgtList; + AliHLTDataSegmentList tgtList; // Matthias 26.07.2007 AliHLTSystem should behave the same way as PubSub // so it does not matter if there are matching data types or not, unless // we implement such a check in PubSub if ((iResult=FindMatchingDataSegments(pConsumer, tgtList))>=0) { int i =0; - vector::iterator segment=tgtList.begin(); + AliHLTDataSegmentList::iterator segment=tgtList.begin(); while (segment!=tgtList.end() && i::iterator buffer=fgFreeBuffers.begin(); + AliHLTRawBufferPList::iterator buffer=fgFreeBuffers.begin(); while (buffer!=fgFreeBuffers.end() && pRawBuffer==NULL) { if ((*buffer)->CheckSize(reqSize)) { // assign this element @@ -426,7 +429,7 @@ int AliHLTDataBuffer::ReleaseRawBuffer(AliHLTRawBuffer* pBuffer) // see header file for function documentation int iResult=0; if (pBuffer) { - vector::iterator buffer=fgActiveBuffers.begin(); + AliHLTRawBufferPList::iterator buffer=fgActiveBuffers.begin(); while (buffer!=fgActiveBuffers.end() && (*buffer)!=pBuffer) { buffer++; } @@ -456,7 +459,7 @@ int AliHLTDataBuffer::DeleteRawBuffers() { // see header file for function documentation int iResult=0; - vector::iterator buffer=fgFreeBuffers.begin(); + AliHLTRawBufferPList::iterator buffer=fgFreeBuffers.begin(); while (buffer!=fgFreeBuffers.end()) { delete *buffer; fgFreeBuffers.erase(buffer); @@ -472,11 +475,11 @@ int AliHLTDataBuffer::DeleteRawBuffers() return iResult; } -AliHLTConsumerDescriptor* AliHLTDataBuffer::FindConsumer(const AliHLTComponent* pConsumer, vector &list) const +AliHLTConsumerDescriptor* AliHLTDataBuffer::FindConsumer(const AliHLTComponent* pConsumer, AliHLTConsumerDescriptorPList &list) const { // see header file for function documentation AliHLTConsumerDescriptor* pDesc=NULL; - vector::iterator desc=list.begin(); + AliHLTConsumerDescriptorPList::iterator desc=list.begin(); while (desc!=list.end() && pDesc==NULL) { if ((pConsumer==NULL || (*desc)->GetComponent()==pConsumer)) { pDesc=*desc; @@ -494,7 +497,7 @@ int AliHLTDataBuffer::ResetDataBuffer() fpBuffer=NULL; // cleanup consumer states - vector::iterator desc; + AliHLTConsumerDescriptorPList::iterator desc; // if (GetNofPendingConsumers()>0) { // desc=fConsumers.begin(); // while (desc!=fConsumers.end()) { @@ -520,7 +523,7 @@ int AliHLTDataBuffer::ResetDataBuffer() } // cleanup segments - vector::iterator segment=fSegments.begin(); + AliHLTDataSegmentList::iterator segment=fSegments.begin(); while (segment!=fSegments.end()) { fSegments.erase(segment); segment=fSegments.begin(); @@ -540,11 +543,11 @@ int AliHLTDataBuffer::Reset() } // this is the version which works on lists of components instead of consumer descriptors -// int AliHLTDataBuffer::ChangeConsumerState(AliHLTComponent* pConsumer, vector &srcList, vector &tgtList) +// int AliHLTDataBuffer::ChangeConsumerState(AliHLTComponent* pConsumer, AliHLTComponentPList &srcList, AliHLTComponentPList &tgtList) // { // int iResult=0; // if (pDesc) { -// vector::iterator desc=srcList.begin(); +// AliHLTComponentPList::iterator desc=srcList.begin(); // while (desc!=srcList.end()) { // if ((*desc)==pConsumer) { // srcList.erase(desc); @@ -564,12 +567,12 @@ int AliHLTDataBuffer::Reset() // return iResult; // } -int AliHLTDataBuffer::ChangeConsumerState(AliHLTConsumerDescriptor* pDesc, vector &srcList, vector &tgtList) +int AliHLTDataBuffer::ChangeConsumerState(AliHLTConsumerDescriptor* pDesc, AliHLTConsumerDescriptorPList &srcList, AliHLTConsumerDescriptorPList &tgtList) { // see header file for function documentation int iResult=-ENOENT; if (pDesc) { - vector::iterator desc=srcList.begin(); + AliHLTConsumerDescriptorPList::iterator desc=srcList.begin(); while (desc!=srcList.end()) { if ((*desc)==pDesc) { srcList.erase(desc); @@ -594,7 +597,7 @@ int AliHLTDataBuffer::CleanupConsumerList() // see header file for function documentation int iResult=0; ResetDataBuffer(); - vector::iterator desc=fConsumers.begin(); + AliHLTConsumerDescriptorPList::iterator desc=fConsumers.begin(); while (desc!=fConsumers.end()) { delete *desc; fConsumers.erase(desc); @@ -606,7 +609,7 @@ int AliHLTDataBuffer::CleanupConsumerList() int AliHLTDataBuffer::FindConsumer(AliHLTComponent* pConsumer, int bAllLists) { // see header file for function documentation - vector::iterator desc=fConsumers.begin(); + AliHLTConsumerDescriptorPList::iterator desc=fConsumers.begin(); while (desc!=fConsumers.end()) { if ((*desc)->GetComponent()==pConsumer) return 1; @@ -704,6 +707,7 @@ int AliHLTDataBuffer::AliHLTRawBuffer::Reset() { // see header file for function documentation fSize=0; + return 0; } int AliHLTDataBuffer::AliHLTRawBuffer::WritePattern(const char* pattern, int size) diff --git a/HLT/BASE/AliHLTDataBuffer.h b/HLT/BASE/AliHLTDataBuffer.h index 672e6e64329..8fce7598c61 100644 --- a/HLT/BASE/AliHLTDataBuffer.h +++ b/HLT/BASE/AliHLTDataBuffer.h @@ -19,13 +19,16 @@ // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt #include +#include "TObject.h" #include "AliHLTLogging.h" #include "AliHLTDataTypes.h" -#include "TObject.h" +#include "AliHLTComponent.h" -class AliHLTComponent; class AliHLTConsumerDescriptor; +/** list of AliHLTConsumerDescriptor pointers */ +typedef vector AliHLTConsumerDescriptorPList; + /** * @class AliHLTDataBuffer * @brief Handling of data buffers for the HLT. @@ -80,7 +83,7 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging * -EINVAL invalid parameter
*/ int FindMatchingDataBlocks(const AliHLTComponent* pConsumer, - vector* tgtList=NULL); + AliHLTComponentDataTypeList* tgtList=NULL); /** * Subscribe to a segment of the data buffer. @@ -222,6 +225,7 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging { memset(&fDataType, 0, sizeof(AliHLTComponentDataType)); } + private: /** the data type of this segment */ AliHLTComponentDataType fDataType; // see above @@ -350,11 +354,11 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging vector fSegments; // see above // the list of all consumers which are going to subscribe to the buffer - vector fConsumers; // see above + AliHLTConsumerDescriptorPList fConsumers; // see above // the list of all consumers which are currently subscribed to the buffer - vector fActiveConsumers; // see above + AliHLTConsumerDescriptorPList fActiveConsumers; // see above // the list of all consumers which are already released for the current event - vector fReleasedConsumers; // see above + AliHLTConsumerDescriptorPList fReleasedConsumers; // see above // the buffer instance AliHLTRawBuffer* fpBuffer; //! transient @@ -426,7 +430,7 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging * @param list list where to search for the consumer */ AliHLTConsumerDescriptor* FindConsumer(const AliHLTComponent* pConsumer, - vector &list) const; + AliHLTConsumerDescriptorPList &list) const; /** * Change the state of a consumer. @@ -437,8 +441,8 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging * @param tgtList list where to move the consumer */ int ChangeConsumerState(AliHLTConsumerDescriptor* pDesc, - vector &srcList, - vector &tgtList); + AliHLTConsumerDescriptorPList &srcList, + AliHLTConsumerDescriptorPList &tgtList); /** * Cleanup a consumer list.