]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTDataBuffer.cxx
minor documentation fixes
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTDataBuffer.cxx
1 // $Id$
2
3 /**************************************************************************
4  * This file is property of and copyright by the ALICE HLT Project        * 
5  * ALICE Experiment at CERN, All rights reserved.                         *
6  *                                                                        *
7  * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
8  *                  for The ALICE HLT Project.                            *
9  *                                                                        *
10  * Permission to use, copy, modify and distribute this software and its   *
11  * documentation strictly for non-commercial purposes is hereby granted   *
12  * without fee, provided that the above copyright notice appears in all   *
13  * copies and that both the copyright notice and this permission notice   *
14  * appear in the supporting documentation. The authors make no claims     *
15  * about the suitability of this software for any purpose. It is          *
16  * provided "as is" without express or implied warranty.                  *
17  **************************************************************************/
18
19 /** @file   AliHLTDataBuffer.cxx
20     @author Matthias Richter
21     @date   
22     @brief  Handling of Data Buffers for HLT components.
23 */
24
25 // see header file for class documentation
26 // or
27 // refer to README to build package
28 // or
29 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
30
31 #if __GNUC__>= 3
32 using namespace std;
33 #endif
34
35 #include "AliHLTDataBuffer.h"
36 #include "AliHLTConsumerDescriptor.h"
37 #include "AliHLTComponent.h"
38 #include <cerrno>
39 //#include <string>
40 //#include "AliHLTSystem.h"
41
42 /** ROOT macro for the implementation of ROOT specific class methods */
43 ClassImp(AliHLTDataBuffer)
44
45 AliHLTDataBuffer::AliHLTDataBuffer()
46   :
47   fSegments(),
48   fConsumers(),
49   fActiveConsumers(),
50   fReleasedConsumers(),
51   fpBuffer(NULL),
52   fFlags(0)
53 {
54   // see header file for class documentation
55   // or
56   // refer to README to build package
57   // or
58   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
59   fSegments.empty();
60   fConsumers.empty();
61   fActiveConsumers.empty();
62   fReleasedConsumers.empty();
63   fgNofInstances++;
64 }
65
66 AliHLTDataBuffer::AliHLTDataBuffer(const AliHLTDataBuffer&)
67   :
68   TObject(),
69   AliHLTLogging(),
70   fSegments(),
71   fConsumers(),
72   fActiveConsumers(),
73   fReleasedConsumers(),
74   fpBuffer(NULL),
75   fFlags(0)
76 {
77   // see header file for function documentation
78   HLTFatal("copy constructor untested");
79 }
80
81 AliHLTDataBuffer& AliHLTDataBuffer::operator=(const AliHLTDataBuffer&)
82
83   // see header file for function documentation
84   HLTFatal("assignment operator untested");
85   return *this;
86 }
87
88 int AliHLTDataBuffer::fgNofInstances=0;
89 vector<AliHLTDataBuffer::AliHLTRawBuffer*> AliHLTDataBuffer::fgFreeBuffers;
90 vector<AliHLTDataBuffer::AliHLTRawBuffer*> AliHLTDataBuffer::fgActiveBuffers;
91 AliHLTUInt32_t AliHLTDataBuffer::fgMargin=1024;
92 AliHLTLogging AliHLTDataBuffer::fgLogging;
93 const Int_t AliHLTDataBuffer::fgkSafetyPatternSize=16;
94 const char AliHLTDataBuffer::fgkSafetyPattern[]={0x28, 0x63, 0x29, 0x4d, 0x52, 0x49, 0x43, 0x48, 0x54, 0x45, 0x52, 0x20, 0x32, 0x30, 0x30, 0x37};
95
96 AliHLTDataBuffer::~AliHLTDataBuffer()
97 {
98   // see header file for function documentation
99   if (--fgNofInstances<=0) {
100     DeleteRawBuffers();
101   }
102   CleanupConsumerList();
103 }
104
105 int AliHLTDataBuffer::SetConsumer(AliHLTComponent* pConsumer)
106 {
107   // see header file for function documentation
108   int iResult=0;
109   if (pConsumer) {
110     if (FindConsumer(pConsumer)) {
111       HLTWarning("consumer %s (%p) already set to data buffer %p", pConsumer->GetComponentID(), pConsumer, this);
112     }
113     AliHLTConsumerDescriptor* pDesc=new AliHLTConsumerDescriptor(pConsumer);
114     if (pDesc) {
115       fConsumers.push_back(pDesc);
116       HLTDebug("set consumer %s (%p) to data buffer %p", pConsumer->GetComponentID(), pConsumer, this);
117     } else {
118       HLTError("memory allocation failed");
119       iResult=-ENOMEM;
120     }
121   } else {
122     HLTError("invalid parameter: consumer component (nil)");
123     iResult=-EINVAL;
124   }
125   return iResult;
126 }
127
128 int AliHLTDataBuffer::FindMatchingDataBlocks(const AliHLTComponent* pConsumer, vector<AliHLTComponentDataType>* tgtList)
129 {
130   // see header file for function documentation
131   int iResult=0;
132   if (pConsumer) {
133     vector<AliHLTDataBuffer::AliHLTDataSegment> segments;
134     if ((iResult=FindMatchingDataSegments(pConsumer, segments))>=0) {
135       if (tgtList) {
136         vector<AliHLTDataBuffer::AliHLTDataSegment>::iterator segment=segments.begin();
137         while (segment!=segments.end()) {
138           tgtList->push_back((*segment).fDataType);
139           segment++;
140         }
141       }
142       iResult=segments.size();
143     }
144   } else {
145     iResult=-EINVAL;
146   }
147   return iResult;
148 }
149
150 int AliHLTDataBuffer::FindMatchingDataSegments(const AliHLTComponent* pConsumer, vector<AliHLTDataBuffer::AliHLTDataSegment>& tgtList)
151 {
152   // see header file for function documentation
153   int iResult=0;
154   if (pConsumer) {
155     vector<AliHLTComponentDataType> dtlist;
156     ((AliHLTComponent*)pConsumer)->GetInputDataTypes(dtlist);
157     vector<AliHLTDataBuffer::AliHLTDataSegment>::iterator segment=fSegments.begin();
158     while (segment!=fSegments.end()) {
159       vector<AliHLTComponentDataType>::iterator type=dtlist.begin();
160       while (type!=dtlist.end()) {
161         if ((*segment).fDataType==(*type) ||
162             (*type)==kAliHLTAnyDataType) {
163           tgtList.push_back(*segment);
164           iResult++;
165           break;
166         }
167         type++;
168       }
169       segment++;
170     }
171   } else {
172     iResult=-EINVAL;
173   }
174   return iResult;
175 }
176
177 int AliHLTDataBuffer::Subscribe(const AliHLTComponent* pConsumer, AliHLTComponentBlockData* arrayBlockDesc, int iArraySize)
178 {
179   // see header file for function documentation
180   int iResult=0;
181   if (pConsumer && arrayBlockDesc) {
182     if (fpBuffer) {
183       AliHLTConsumerDescriptor* pDesc=FindConsumer(pConsumer, fConsumers);
184       if (pDesc) {
185         vector<AliHLTDataBuffer::AliHLTDataSegment> tgtList;
186         /* TODO: think about a good policy for this check
187          * is it enough that at least one segment is available, or have all to be available?
188          * or is it possible to have optional segments?
189          */
190         if ((iResult=FindMatchingDataSegments(pConsumer, tgtList))>0) {
191           int i =0;
192           vector<AliHLTDataBuffer::AliHLTDataSegment>::iterator segment=tgtList.begin();
193           while (segment!=tgtList.end() && i<iArraySize) {
194             // fill the block data descriptor
195             arrayBlockDesc[i].fStructSize=sizeof(AliHLTComponentBlockData);
196             // the shared memory key is not used in AliRoot
197             arrayBlockDesc[i].fShmKey.fStructSize=sizeof(AliHLTComponentShmData);
198             arrayBlockDesc[i].fShmKey.fShmType=gkAliHLTComponentInvalidShmType;
199             arrayBlockDesc[i].fShmKey.fShmID=gkAliHLTComponentInvalidShmID;
200             arrayBlockDesc[i].fOffset=(*segment).fSegmentOffset;
201             arrayBlockDesc[i].fPtr=fpBuffer->fPtr;
202             arrayBlockDesc[i].fSize=(*segment).fSegmentSize;
203             arrayBlockDesc[i].fDataType=(*segment).fDataType;
204             arrayBlockDesc[i].fSpecification=(*segment).fSpecification;
205             pDesc->SetActiveDataSegment(arrayBlockDesc[i].fOffset, arrayBlockDesc[i].fSize);
206             HLTDebug("component %p (%s) subscribed to segment #%d offset %d", pConsumer, ((AliHLTComponent*)pConsumer)->GetComponentID(), i, arrayBlockDesc[i].fOffset);
207             i++;
208             segment++;
209           }
210           // move this consumer to the active list
211           if (ChangeConsumerState(pDesc, fConsumers, fActiveConsumers)>=0) {
212             HLTDebug("component %p (%s) subscribed to data buffer %p", pConsumer, ((AliHLTComponent*)pConsumer)->GetComponentID(), this);
213           } else {
214             // TODO: cleanup the consumer descriptor correctly
215             memset(arrayBlockDesc, 0, iArraySize*sizeof(AliHLTComponentBlockData));
216             HLTError("can not activate consumer %p for data buffer %p", pConsumer, this);
217             iResult=-EACCES;
218           }
219         } else {
220           HLTError("unresolved data segment(s) for component %p (%s)", pConsumer, ((AliHLTComponent*)pConsumer)->GetComponentID());
221           iResult=-EBADF;
222         }
223       } else {
224         HLTError("component %p is not a data consumer of data buffer %s", pConsumer, this);
225         iResult=-ENOENT;
226       }
227     } else {
228       HLTError("data buffer %p is empty", this);
229       iResult=-ENODATA;
230     }
231   } else {
232     HLTError("invalid parameter");
233     iResult=-EINVAL;
234   }
235   return iResult;
236 }
237
238 int AliHLTDataBuffer::Release(AliHLTComponentBlockData* pBlockDesc, const AliHLTComponent* pConsumer)
239 {
240   // see header file for function documentation
241   int iResult=0;
242   if (pBlockDesc && pConsumer) {
243     AliHLTConsumerDescriptor* pDesc=FindConsumer(pConsumer, fActiveConsumers);
244     if (pDesc) {
245       if ((iResult=pDesc->CheckActiveDataSegment(pBlockDesc->fOffset, pBlockDesc->fSize))!=1) {
246         HLTWarning("data segment missmatch, component %p has not subscribed to a segment with offset %#x and size %d", pConsumer, pBlockDesc->fOffset, pBlockDesc->fSize);
247         // TODO: appropriate error handling, but so far optional
248         iResult=0;
249       } else {
250         pDesc->ReleaseActiveDataSegment(pBlockDesc->fOffset, pBlockDesc->fSize);
251         pBlockDesc->fOffset=0;
252         pBlockDesc->fPtr=NULL;
253         pBlockDesc->fSize=0;
254       }
255       if (pDesc->GetNofActiveSegments()==0) {
256         if ((iResult=ChangeConsumerState(pDesc, fActiveConsumers, fReleasedConsumers))>=0) {
257           if (GetNofActiveConsumers()==0) {
258             // this is the last consumer, reset the consumer list and release the raw buffer
259             ResetDataBuffer();
260           }
261         } else {
262           HLTError("can not deactivate consumer %p for data buffer %p", pConsumer, this);
263           iResult=-EACCES;
264         }
265       }
266     } else {
267       HLTWarning("component %p has currently not subscribed to the data buffer %p", pConsumer, this);
268       iResult=-ENOENT;
269     }
270   } else {
271     HLTError("inavalid parameter: pBlockDesc=%p pConsumer=%p", pBlockDesc, pConsumer);
272     iResult=-EINVAL;
273   }
274   return iResult;
275 }
276
277 AliHLTUInt8_t* AliHLTDataBuffer::GetTargetBuffer(int iMinSize)
278 {
279   // see header file for function documentation
280   AliHLTUInt8_t* pTargetBuffer=NULL;
281   if (fpBuffer!=NULL) {
282     HLTWarning("data buffer not properly reset, possible memory leak\n");
283   }
284   fpBuffer=CreateRawBuffer(iMinSize);
285   if (fpBuffer) {
286     pTargetBuffer=(AliHLTUInt8_t*)fpBuffer->fPtr;
287   } else {
288     HLTError("can not create raw buffer");
289   }
290   return pTargetBuffer;
291 }
292
293 int AliHLTDataBuffer::SetSegments(AliHLTUInt8_t* pTgt, AliHLTComponentBlockData* arrayBlockData, int iSize)
294 {
295   // see header file for function documentation
296   int iResult=0;
297   if (pTgt && arrayBlockData && iSize>=0) {
298     if (fpBuffer) {
299       if (fpBuffer->fPtr==(void*)pTgt) {
300         AliHLTDataBuffer::AliHLTDataSegment segment;
301         for (int i=0; i<iSize; i++) {
302           if (arrayBlockData[i].fOffset+arrayBlockData[i].fSize<=fpBuffer->fSize) {
303             segment.fSegmentOffset=arrayBlockData[i].fOffset;
304             segment.fSegmentSize=arrayBlockData[i].fSize;
305             segment.fDataType=arrayBlockData[i].fDataType;
306             segment.fSpecification=arrayBlockData[i].fSpecification;
307             fSegments.push_back(segment);
308             HLTDebug("set segment %s with size %d at offset %d", AliHLTComponent::DataType2Text(segment.fDataType).data(), segment.fSegmentSize, segment.fSegmentOffset);
309           } else {
310             HLTError("block data specification %#d (%s) exceeds size of data buffer", i, AliHLTComponent::DataType2Text(arrayBlockData[i].fDataType).data());
311             HLTError("block offset=%d, block size=%d, buffer size=%d", arrayBlockData[i].fOffset, arrayBlockData[i].fSize, fpBuffer->fSize);
312             iResult=-E2BIG;
313           }
314         }
315       } else {
316         HLTError("this data buffer (%p) does not match the internal data buffer %p of raw buffer %p", pTgt, fpBuffer->fPtr, fpBuffer);
317         iResult=-EINVAL;
318       }
319     } else {
320       HLTFatal("internal data structur missmatch");
321       iResult=-EFAULT;
322     }
323   } else {
324     HLTError("invalid parameter: pTgtBuffer=%p arrayBlockData=%p", pTgt, arrayBlockData);
325     iResult=-EINVAL;
326   }
327   return iResult;
328 }
329
330 int AliHLTDataBuffer::IsEmpty()
331 {
332   // see header file for function documentation
333   int iResult=fpBuffer==NULL || GetNofSegments()==0;
334   return iResult;
335 }
336
337 int AliHLTDataBuffer::GetNofSegments()
338 {
339   // see header file for function documentation
340   int iResult=fSegments.size();
341   return iResult;
342 }
343
344 int AliHLTDataBuffer::GetNofConsumers()
345 {
346   // see header file for function documentation
347   int iResult=fConsumers.size() + GetNofActiveConsumers() + fReleasedConsumers.size();
348   return iResult;
349 }
350
351 int AliHLTDataBuffer::GetNofActiveConsumers()
352 {
353   // see header file for function documentation
354   int iResult=fActiveConsumers.size();
355   return iResult;
356 }
357
358 AliHLTDataBuffer::AliHLTRawBuffer* AliHLTDataBuffer::CreateRawBuffer(AliHLTUInt32_t size)
359 {
360   // see header file for function documentation
361   AliHLTRawBuffer* pRawBuffer=NULL;
362   unsigned int reqSize=size+fgkSafetyPatternSize;
363   vector<AliHLTRawBuffer*>::iterator buffer=fgFreeBuffers.begin();
364   while (buffer!=fgFreeBuffers.end() && pRawBuffer==NULL) {
365     if ((*buffer)->fTotalSize>=reqSize && ((*buffer)->fTotalSize-reqSize)<fgMargin) {
366       // assign this element
367       pRawBuffer=*buffer;
368       pRawBuffer->fSize=size;
369       fgFreeBuffers.erase(buffer);
370       fgLogging.Logging(kHLTLogDebug, "AliHLTDataBuffer::CreateRawBuffer", "data buffer handling", "raw buffer container %p provided for request of %d bytes (total %d available in buffer %p)", pRawBuffer, size, pRawBuffer->fTotalSize, pRawBuffer->fPtr);
371       fgActiveBuffers.push_back(pRawBuffer);
372       break;
373     }
374     buffer++;
375   }
376   if (pRawBuffer==NULL) {
377     // no buffer found, create a new one
378     pRawBuffer=new AliHLTRawBuffer;
379     if (pRawBuffer) {
380       pRawBuffer->fPtr=malloc(reqSize);
381       if (pRawBuffer->fPtr) {
382         pRawBuffer->fSize=size;
383         pRawBuffer->fTotalSize=reqSize;
384         fgActiveBuffers.push_back(pRawBuffer);
385         fgLogging.Logging(kHLTLogDebug, "AliHLTDataBuffer::CreateRawBuffer", "data buffer handling", "new raw buffer %p of size %d created (container %p)", pRawBuffer->fPtr, pRawBuffer->fTotalSize, pRawBuffer);
386         if (fgkSafetyPatternSize>0) {
387           memcpy(((char*)pRawBuffer->fPtr)+pRawBuffer->fSize, fgkSafetyPattern, fgkSafetyPatternSize);
388         }
389       } else {
390         delete pRawBuffer;
391         pRawBuffer=NULL;
392         fgLogging.Logging(kHLTLogError, "AliHLTDataBuffer::CreateRawBuffer", "data buffer handling", "memory allocation failed");
393       } 
394     } else {
395       fgLogging.Logging(kHLTLogError, "AliHLTDataBuffer::CreateRawBuffer", "data buffer handling", "memory allocation failed");
396     }
397   }
398   return pRawBuffer;
399 }
400
401 int AliHLTDataBuffer::ReleaseRawBuffer(AliHLTRawBuffer* pBuffer)
402 {
403   // see header file for function documentation
404   int iResult=0;
405   if (pBuffer) {
406     vector<AliHLTRawBuffer*>::iterator buffer=fgActiveBuffers.begin();
407     while (buffer!=fgActiveBuffers.end() && (*buffer)!=pBuffer) {
408       buffer++;
409     }
410     if (buffer!=fgActiveBuffers.end()) {
411       if (fgkSafetyPatternSize>0) {
412         if (memcmp(((char*)(*buffer)->fPtr)+(*buffer)->fSize, fgkSafetyPattern, fgkSafetyPatternSize)!=0) {
413           fgLogging.Logging(kHLTLogFatal, "AliHLTDataBuffer::ReleaseRawBuffer", "data buffer handling", "component has written beyond end of data buffer %p size %d", (*buffer)->fPtr, (*buffer)->fSize);
414         }
415       }
416       (*buffer)->fSize=0;
417       fgFreeBuffers.push_back(*buffer);
418       fgActiveBuffers.erase(buffer);
419     } else {
420       fgLogging.Logging(kHLTLogWarning, "AliHLTDataBuffer::ReleaseRawBuffer", "data buffer handling", "can not find raw buffer container %p in the list of active containers", pBuffer);
421       iResult=-ENOENT;
422     }
423   } else {
424     fgLogging.Logging(kHLTLogError, "AliHLTDataBuffer::ReleaseRawBuffer", "data buffer handling", "invalid parameter");
425     iResult=-EINVAL;
426   }
427   return iResult;
428 }
429
430
431 int AliHLTDataBuffer::DeleteRawBuffers() 
432 {
433   // see header file for function documentation
434   int iResult=0;
435   vector<AliHLTRawBuffer*>::iterator buffer=fgFreeBuffers.begin();
436   while (buffer!=fgFreeBuffers.end()) {
437     free((*buffer)->fPtr);
438     delete *buffer;
439     fgFreeBuffers.erase(buffer);
440     buffer=fgFreeBuffers.begin();
441   }
442   buffer=fgActiveBuffers.begin();
443   while (buffer!=fgActiveBuffers.end()) {
444     fgLogging.Logging(kHLTLogWarning, "AliHLTDataBuffer::ReleaseRawBuffer", "data buffer handling", "request to delete active raw buffer container (raw buffer %p, size %d)", (*buffer)->fPtr, (*buffer)->fTotalSize);
445     free((*buffer)->fPtr);
446     delete *buffer;
447     fgActiveBuffers.erase(buffer);
448     buffer=fgActiveBuffers.begin();
449   }
450   return iResult;
451 }
452
453 AliHLTConsumerDescriptor* AliHLTDataBuffer::FindConsumer(const AliHLTComponent* pConsumer, vector<AliHLTConsumerDescriptor*> &list) const
454 {
455   // see header file for function documentation
456   AliHLTConsumerDescriptor* pDesc=NULL;
457   vector<AliHLTConsumerDescriptor*>::iterator desc=list.begin();
458   while (desc!=list.end() && pDesc==NULL) {
459     if ((pConsumer==NULL || (*desc)->GetComponent()==pConsumer)) {
460       pDesc=*desc;
461     }
462     desc++;
463   }
464   return pDesc;
465 }
466
467 int AliHLTDataBuffer::ResetDataBuffer() 
468 {
469   // see header file for function documentation
470   int iResult=0;
471   AliHLTRawBuffer* pBuffer=fpBuffer;
472   fpBuffer=NULL;
473
474   // cleanup consumer states
475   vector<AliHLTConsumerDescriptor*>::iterator desc=fReleasedConsumers.begin();
476   while (desc!=fReleasedConsumers.end()) {
477     AliHLTConsumerDescriptor* pDesc=*desc;
478     fReleasedConsumers.erase(desc);
479     desc=fReleasedConsumers.begin();
480     fConsumers.push_back(pDesc);
481   }
482   desc=fActiveConsumers.begin();
483   while (desc!=fActiveConsumers.end()) {
484     AliHLTConsumerDescriptor* pDesc=*desc;
485     HLTWarning("consumer %p was not released", pDesc);
486     fActiveConsumers.erase(desc);
487     desc=fActiveConsumers.begin();
488     fConsumers.push_back(pDesc);
489   }
490
491   // cleanup segments
492   vector<AliHLTDataBuffer::AliHLTDataSegment>::iterator segment=fSegments.begin();
493   while (segment!=fSegments.end()) {
494     fSegments.erase(segment);
495     segment=fSegments.begin();
496   }
497
498   // cleanup raw buffer
499   if (pBuffer) {
500     ReleaseRawBuffer(pBuffer);
501   }
502   return iResult;
503 }
504
505 int AliHLTDataBuffer::Reset()
506 {
507   // see header file for function documentation
508   return ResetDataBuffer();
509 }
510
511 // this is the version which works on lists of components instead of consumer descriptors
512 // int AliHLTDataBuffer::ChangeConsumerState(AliHLTComponent* pConsumer, vector<AliHLTComponent*> &srcList, vector<AliHLTComponent*> &tgtList)
513 // {
514 //   int iResult=0;
515 //   if (pDesc) {
516 //     vector<AliHLTComponent*>::iterator desc=srcList.begin();
517 //     while (desc!=srcList.end()) {
518 //       if ((*desc)==pConsumer) {
519 //      srcList.erase(desc);
520 //      tgtList.push_back(pConsumer);
521 //      break;
522 //       }
523 //      desc++;
524 //     }
525 //     if (desc==srcList.end()) {
526 //       HLTError("can not find consumer component %p in list", pConsumer);
527 //       iResult=-ENOENT;
528 //     }
529 //   } else {
530 //     HLTError("invalid parameter");
531 //     iResult=-EINVAL;
532 //   }
533 //   return iResult;
534 // }
535
536 int AliHLTDataBuffer::ChangeConsumerState(AliHLTConsumerDescriptor* pDesc, vector<AliHLTConsumerDescriptor*> &srcList, vector<AliHLTConsumerDescriptor*> &tgtList)
537 {
538   // see header file for function documentation
539   int iResult=-ENOENT;
540   if (pDesc) {
541     vector<AliHLTConsumerDescriptor*>::iterator desc=srcList.begin();
542     while (desc!=srcList.end()) {
543       if ((*desc)==pDesc) {
544         srcList.erase(desc);
545         tgtList.push_back(pDesc);
546         iResult=0;
547         break;
548       }
549       desc++;
550     }
551     if (iResult<0) {
552       HLTError("can not find consumer descriptor %p in list", pDesc);
553     }
554   } else {
555     HLTError("invalid parameter");
556     iResult=-EINVAL;
557   }
558   return iResult;
559 }
560
561 int AliHLTDataBuffer::CleanupConsumerList() 
562 {
563   // see header file for function documentation
564   int iResult=0;
565   ResetDataBuffer();
566   vector<AliHLTConsumerDescriptor*>::iterator desc=fConsumers.begin();
567   while (desc!=fConsumers.end()) {
568     delete *desc;
569     fConsumers.erase(desc);
570     desc=fConsumers.begin();
571   }
572   return iResult;
573 }
574
575 int AliHLTDataBuffer::FindConsumer(AliHLTComponent* pConsumer, int bAllLists)
576 {
577   // see header file for function documentation
578   vector<AliHLTConsumerDescriptor*>::iterator desc=fConsumers.begin();
579   while (desc!=fConsumers.end()) {
580     if ((*desc)->GetComponent()==pConsumer)
581       return 1;
582     desc++;
583   }
584   if (bAllLists==0) return 0;
585
586   desc=fActiveConsumers.begin();
587   while (desc!=fActiveConsumers.end()) {
588     if ((*desc)->GetComponent()==pConsumer)
589       return 1;
590     desc++;
591   }
592   desc=fReleasedConsumers.begin();
593   while (desc!=fReleasedConsumers.end()) {
594     if ((*desc)->GetComponent()==pConsumer)
595       return 1;
596     desc++;
597   }
598   return 0;
599 }