Merge branch 'multipleThreads' into newdevel
[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
b088c0a1 100 void SetBufferMonStarted(Bool_t started) {fBufferMonStarted = started;}
101 Bool_t GetBufferMonStarted () const { return fBufferMonStarted;}
30e7579c 102
103private:
104
105 /** copy constructor prohibited */
106 AliEveEventBuffer(const AliEveEventBuffer&);
107
108 /** assignment operator prohibited */
109 AliEveEventBuffer& operator=(const AliEveEventBuffer&);
110
111
112 TObject * GetNextUnSeen();
113
114 void PrintIndeces();
115 void PrintBuffer();
116
117 TTimer * fTimer;
118
119 TThread * fThread;
120
121 //Current event id
122 Int_t * fEventId;
123
b088c0a1 124 Bool_t fBufferMonStarted;
125
126
30e7579c 127
128 ClassDef(AliEveEventBuffer, 0); // Manage connections to HLT data-sources.
129};
130
131#endif