]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
code cleanup and coding conventions
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 18 Oct 2007 09:12:49 +0000 (09:12 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 18 Oct 2007 09:12:49 +0000 (09:12 +0000)
HLT/BASE/AliHLTComponent.cxx
HLT/BASE/AliHLTComponent.h
HLT/BASE/AliHLTDataBuffer.cxx
HLT/BASE/AliHLTDataBuffer.h

index ae8e5b6410b70e58c56de157a7d29f9d235191ec..97da0d70096af4e5e0044425a2684a8ac62f6c39 100644 (file)
@@ -95,7 +95,7 @@ AliHLTComponent::~AliHLTComponent()
   CleanupInputObjects();
   if (fpStopwatches!=NULL) delete fpStopwatches;
   fpStopwatches=NULL;
-  vector<AliHLTMemoryFile*>::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<AliHLTComponentDataType>& /*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<AliHLTComponentBlockData>& 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<AliHLTComponentDataType>* tgtList) 
+int AliHLTComponent::FindMatchingDataTypes(AliHLTComponent* pConsumer, AliHLTComponentDataTypeList* tgtList) 
 {
   // see header file for function documentation
   int iResult=0;
   if (pConsumer) {
-    vector<AliHLTComponentDataType> ctlist;
+    AliHLTComponentDataTypeList ctlist;
     ((AliHLTComponent*)pConsumer)->GetInputDataTypes(ctlist);
-    vector<AliHLTComponentDataType>::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<AliHLTMemoryFile*>::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<AliHLTComponentBlockData> 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<AliHLTMemoryFile*>::iterator element=fMemFiles.begin();
+      AliHLTMemoryFilePList::iterator element=fMemFiles.begin();
       int i=0;
       while (element!=fMemFiles.end() && iResult>=0) {
        if (*element) {
index fe2942a60664a10bb8dd1b04a3e89fcbd8ea2cc0..9c640f7a68564b31939a67e30cb35e7c0cbd5e49 100644 (file)
@@ -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<AliHLTComponentDataType>   AliHLTComponentDataTypeList;
+/** list of component block data structures */
+typedef vector<AliHLTComponentBlockData>  AliHLTComponentBlockDataList;
+/** list of component pointers */
+typedef vector<AliHLTComponent*>          AliHLTComponentPList;
+/** list of memory file pointers */
+typedef vector<AliHLTMemoryFile*>         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<AliHLTComponentBlockData>& 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<AliHLTComponentDataType>& ) = 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<AliHLTComponentDataType>& 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<AliHLTComponentDataType>* 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<AliHLTComponentBlockData>& 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<AliHLTComponentBlockData> fOutputBlocks;                  // see above
+  AliHLTComponentBlockDataList fOutputBlocks;                      // see above
 
   /** stopwatch array */
   TObjArray* fpStopwatches;                                        //! transient
 
   /** array of memory files AliHLTMemoryFile */
-  vector<AliHLTMemoryFile*> fMemFiles;                             //! transient
+  AliHLTMemoryFilePList fMemFiles;                                 //! transient
 
   /** descriptor of the current run */
   AliHLTRunDesc* fpRunDesc;                                        //! transient
index 84159eb5da6b0e8197f961b603f20e357bd108a0..7c326dc5815d05c869c22749959a10012a84d960 100644 (file)
@@ -40,6 +40,9 @@ using namespace std;
 //#include <string>
 //#include "AliHLTSystem.h"
 
+typedef vector<AliHLTDataBuffer::AliHLTDataSegment> AliHLTDataSegmentList;
+typedef vector<AliHLTDataBuffer::AliHLTRawBuffer*>  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::AliHLTRawBuffer*> AliHLTDataBuffer::fgFreeBuffers;
-vector<AliHLTDataBuffer::AliHLTRawBuffer*> 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<AliHLTComponentDataType>* tgtList)
+int AliHLTDataBuffer::FindMatchingDataBlocks(const AliHLTComponent* pConsumer, AliHLTComponentDataTypeList* tgtList)
 {
   // see header file for function documentation
   int iResult=0;
   if (pConsumer) {
-    vector<AliHLTDataBuffer::AliHLTDataSegment> segments;
+    AliHLTDataSegmentList segments;
     if ((iResult=FindMatchingDataSegments(pConsumer, segments))>=0) {
       if (tgtList) {
-       vector<AliHLTDataBuffer::AliHLTDataSegment>::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<AliHLTComponentDataType> dtlist;
+    AliHLTComponentDataTypeList dtlist;
     ((AliHLTComponent*)pConsumer)->GetInputDataTypes(dtlist);
-    vector<AliHLTDataBuffer::AliHLTDataSegment>::iterator segment=fSegments.begin();
+    AliHLTDataSegmentList::iterator segment=fSegments.begin();
     while (segment!=fSegments.end()) {
-      vector<AliHLTComponentDataType>::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<AliHLTDataBuffer::AliHLTDataSegment> 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<AliHLTDataBuffer::AliHLTDataSegment>::iterator segment=tgtList.begin();
+         AliHLTDataSegmentList::iterator segment=tgtList.begin();
          while (segment!=tgtList.end() && i<iArraySize) {
            // fill the block data descriptor
            arrayBlockDesc[i].fStructSize=sizeof(AliHLTComponentBlockData);
@@ -383,7 +386,7 @@ AliHLTDataBuffer::AliHLTRawBuffer* AliHLTDataBuffer::CreateRawBuffer(AliHLTUInt3
   // see header file for function documentation
   AliHLTRawBuffer* pRawBuffer=NULL;
   unsigned int reqSize=size+fgkSafetyPatternSize;
-  vector<AliHLTRawBuffer*>::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<AliHLTRawBuffer*>::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<AliHLTRawBuffer*>::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<AliHLTConsumerDescriptor*> &list) const
+AliHLTConsumerDescriptor* AliHLTDataBuffer::FindConsumer(const AliHLTComponent* pConsumer, AliHLTConsumerDescriptorPList &list) const
 {
   // see header file for function documentation
   AliHLTConsumerDescriptor* pDesc=NULL;
-  vector<AliHLTConsumerDescriptor*>::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<AliHLTConsumerDescriptor*>::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<AliHLTDataBuffer::AliHLTDataSegment>::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<AliHLTComponent*> &srcList, vector<AliHLTComponent*> &tgtList)
+// int AliHLTDataBuffer::ChangeConsumerState(AliHLTComponent* pConsumer, AliHLTComponentPList &srcList, AliHLTComponentPList &tgtList)
 // {
 //   int iResult=0;
 //   if (pDesc) {
-//     vector<AliHLTComponent*>::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<AliHLTConsumerDescriptor*> &srcList, vector<AliHLTConsumerDescriptor*> &tgtList)
+int AliHLTDataBuffer::ChangeConsumerState(AliHLTConsumerDescriptor* pDesc, AliHLTConsumerDescriptorPList &srcList, AliHLTConsumerDescriptorPList &tgtList)
 {
   // see header file for function documentation
   int iResult=-ENOENT;
   if (pDesc) {
-    vector<AliHLTConsumerDescriptor*>::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<AliHLTConsumerDescriptor*>::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<AliHLTConsumerDescriptor*>::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)
index 672e6e643298db0f19ee2073128f17689cada18d..8fce7598c6122e2f35a077674af07eda1da19cda 100644 (file)
 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
 
 #include <vector>
+#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<AliHLTConsumerDescriptor*> AliHLTConsumerDescriptorPList;
+
 /**
  * @class AliHLTDataBuffer
  * @brief  Handling of data buffers for the HLT.
@@ -80,7 +83,7 @@ class AliHLTDataBuffer : public TObject, public AliHLTLogging
    *          -EINVAL       invalid parameter <br>
    */
   int FindMatchingDataBlocks(const AliHLTComponent* pConsumer,
-                            vector<AliHLTComponentDataType>* 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<AliHLTDataSegment> fSegments;                             // see above
 
   // the list of all consumers which are going to subscribe to the buffer
-  vector<AliHLTConsumerDescriptor*> fConsumers;                    // see above
+  AliHLTConsumerDescriptorPList fConsumers;                         // see above
   // the list of all consumers which are currently subscribed to the buffer
-  vector<AliHLTConsumerDescriptor*> fActiveConsumers;              // see above
+  AliHLTConsumerDescriptorPList fActiveConsumers;                   // see above
   // the list of all consumers which are already released for the current event
-  vector<AliHLTConsumerDescriptor*> 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<AliHLTConsumerDescriptor*> &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<AliHLTConsumerDescriptor*> &srcList,
-                         vector<AliHLTConsumerDescriptor*> &tgtList);
+                         AliHLTConsumerDescriptorPList &srcList,
+                         AliHLTConsumerDescriptorPList &tgtList);
 
   /**
    * Cleanup a consumer list.