]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/EveHLT/AliEveEventBuffer.h
remove obsolate macro
[u/mrichter/AliRoot.git] / EVE / EveHLT / AliEveEventBuffer.h
1 //-*- Mode: C++ -*-
2
3 // $Id$
4
5 #ifndef ALIEVEEVENTBUFFER_H
6 #define ALIEVEEVENTBUFFER_H
7
8 /* This file is property of and copyright by the ALICE HLT Project        * 
9  * ALICE Experiment at CERN, All rights reserved.                         *
10  * See cxx source for full Copyright notice     
11  */
12
13 /** @file   AliEveEventBuffer.h
14     @author Svein Lindal
15     @date
16     @brief  Manager for HOMER in aliroot
17 */
18
19
20 class TObjArray;
21 class TObject;
22 class TTimer;
23 class TThread;
24 #include "TMutex.h"
25 #include "TTimer.h"
26
27 class AliEveEventBuffer : public TObject{
28
29 public:
30   
31   /** default constructor */
32   AliEveEventBuffer();
33
34   /** destructor */
35   virtual ~AliEveEventBuffer();
36
37   void SetBufferSize(Int_t bs) { fBufferSize = bs;}
38   void SetBusy(Bool_t busy) { fBusy = busy;}
39   Bool_t GetBusy() { return fBusy;}
40   
41   //Navigate the event buffer
42   // TObject *  NavigateFwd();
43   // TObject *  NavigateBack();
44   TObject * NextEvent();
45   TObject * Back();
46   TObject * Fwd();
47   
48   void StartBufferMonitor();
49   void StopBufferMonitor();
50   //Needed for Homer buffer
51   virtual void ConnectToSource() = 0;
52   //Check if more events are needed in buffer
53   void MonitorBuffer();
54
55   static void * BufferThread(void * buffer);
56   virtual void WriteToFile(Int_t runnumber) = 0; 
57
58   void CreateBufferThread();
59
60   ULong64_t GetEventId() const { return fEventId[fBIndex[kCurrent]]; }
61   void SetEventId(ULong64_t eventId) { fEventId[fBIndex[kCurrent]] = eventId;}
62
63   Int_t LockMutex() { return fMutex->TryLock();}
64   Int_t UnLockMutex() { return fMutex->UnLock();}
65
66
67 protected:
68   
69   enum fBufferIndex {
70     kCurrent,
71     kLast, 
72     kTop,
73     kSize
74   };
75
76   
77   Int_t fBufferSize;
78   Int_t fPreBuffer;
79   Bool_t fBusy;
80
81   //TClonesArray containing the stored events
82   TObjArray * fEventBuffer;
83
84   //Pointer to current event
85   TObject * fCurrentEvent;
86
87   //Event buffer indexes
88   Int_t fBIndex[kSize];
89   
90   
91   //Add event to buffer
92   virtual void AddToBuffer(TObject * event);
93   virtual TObject * GetEventFromSource() = 0;
94   virtual ULong64_t GetEventIdFromSource() { return 0;}
95
96
97   void FetchEvent();
98   
99
100   //Calculate buffer index stuff
101   Int_t CalculateDifference(Int_t top, Int_t low);
102   Int_t CalculatePrevious(Int_t current);
103   Int_t CalculateNext(Int_t current);
104
105   
106   void SetBufferMonStarted(Bool_t started) {fBufferMonStarted = started;}
107   Bool_t GetBufferMonStarted () const { return fBufferMonStarted;}
108
109 private:
110
111   /** copy constructor prohibited */
112   AliEveEventBuffer(const AliEveEventBuffer&);
113
114   /** assignment operator prohibited */
115   AliEveEventBuffer& operator=(const AliEveEventBuffer&);
116
117   
118
119   TObject *  GetNextUnSeen();
120
121   void PrintIndeces();
122   void PrintBuffer();
123
124   TTimer * fTimer;
125
126   //Current event id
127   ULong64_t * fEventId;
128   
129   Bool_t fBufferMonStarted;
130
131   TThread * fThread;
132  TMutex * fMutex;
133
134   ClassDef(AliEveEventBuffer, 0); // Manage connections to HLT data-sources.
135 };
136
137 #endif