]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ANALYSIS/AliEventBuffer.cxx
2cd074ef06e422fee4701f1d215d3b1876a8adc9
[u/mrichter/AliRoot.git] / ANALYSIS / AliEventBuffer.cxx
1 #include "AliEventBuffer.h"
2
3 ClassImp(AliEventBuffer)
4
5 //______________________________________________________
6 ////////////////////////////////////////////////////////
7 //
8 // class AliEventBuffer
9 //
10 // FIFO type event buffer
11 //
12 // Piotr.Skowronski@cern.ch
13 //
14 ////////////////////////////////////////////////////////
15
16 AliEventBuffer::AliEventBuffer():
17  fSize(-1),fEvents(),fIter(&fEvents)
18 {
19   //ctor
20 }
21 /***********************************************************/
22
23 AliEventBuffer::AliEventBuffer(Int_t size):
24  fSize(size),fEvents(),fIter(&fEvents)
25 {
26   //ctor
27 }
28 /***********************************************************/
29
30 AliEventBuffer::~AliEventBuffer()
31 {
32   //dtor -- TList::IsOwner(1) does not work - Valgrind says that there is mem leak
33   //take care owerseves
34   if (fEvents.IsOwner())
35    { 
36      AliAOD* e=0x0;
37      while (( e=RemoveLast() )) delete e;
38    }
39 }
40 /***********************************************************/
41
42 AliAOD* AliEventBuffer::Push(AliAOD* event)
43 {
44   //adds a new event, and returns old of do not fit in size
45   if (fSize == 0) return event;
46   
47   AliAOD* ret = 0x0;
48   
49   if (fSize == fEvents.GetSize()) 
50     ret = dynamic_cast<AliAOD*>(fEvents.Remove(fEvents.Last()));
51   if (event) fEvents.AddFirst(event);
52   return ret;
53 }
54