Merge branch 'multipleThreads'
[u/mrichter/AliRoot.git] / EVE / EveHLT / AliEveEventBuffer.h
CommitLineData
30e7579c 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
20class TObjArray;
21class TObject;
22class TTimer;
23class TThread;
24
25#include "TTimer.h"
26
27class AliEveEventBuffer : public TObject{
28
29public:
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
40 //Navigate the event buffer
41 // TObject * NavigateFwd();
42 // TObject * NavigateBack();
43 TObject * NextEvent();
44 TObject * Back();
45 TObject * Fwd();
46
47 void StartBufferMonitor();
48 void StopBufferMonitor();
49 //Needed for Homer buffer
50 virtual void ConnectToSource() = 0;
51 //Check if more events are needed in buffer
52 void MonitorBuffer();
53
54 static void * BufferThread(void * buffer);
55 virtual void WriteToFile() {//Do nothing
56 ;
57 }
58
59 Int_t GetEventId() const { return fEventId[fBIndex[kCurrent]];}
60
61protected:
62
63 enum fBufferIndex {
64 kCurrent,
65 kLast,
66 kTop,
67 kSize
68 };
69
70
71 Int_t fBufferSize;
72 Int_t fPreBuffer;
73 Bool_t fBusy;
74
75 //TClonesArray containing the stored events
76 TObjArray * fEventBuffer;
77
78 //Pointer to current event
79 TObject * fCurrentEvent;
80
81 //Event buffer indexes
82 Int_t fBIndex[kSize];
83
84
85 //Add event to buffer
86 virtual void AddToBuffer(TObject * event);
87
88 virtual TObject * GetEventFromSource() = 0;
89
90 void FetchEvent();
91
92
93 //Calculate buffer index stuff
94 Int_t CalculateDifference(Int_t top, Int_t low);
95 Int_t CalculatePrevious(Int_t current);
96 Int_t CalculateNext(Int_t current);
97
98 void SetEventId(Int_t eventId) { fEventId[fBIndex[kCurrent]] = eventId;}
99
100
101private:
102
103 /** copy constructor prohibited */
104 AliEveEventBuffer(const AliEveEventBuffer&);
105
106 /** assignment operator prohibited */
107 AliEveEventBuffer& operator=(const AliEveEventBuffer&);
108
109
110 TObject * GetNextUnSeen();
111
112 void PrintIndeces();
113 void PrintBuffer();
114
115 TTimer * fTimer;
116
117 TThread * fThread;
118
119 //Current event id
120 Int_t * fEventId;
121
122
123 ClassDef(AliEveEventBuffer, 0); // Manage connections to HLT data-sources.
124};
125
126#endif