]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTHOMERManager.h
* Added new Handler Classes for HOMER Proxy
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTHOMERManager.h
1 //-*- Mode: C++ -*-
2
3 // $Id: AliHLTHOMERManager.h $
4
5 #ifndef ALIEVEHOMERMANGER_H
6 #define ALIEVEHOMERMANGER_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   AliHLTHOMERManager.h
14     @author Jochen Thaeder
15     @date
16     @brief  Manager for HOMER in aliroot
17 */
18
19
20 #include "TString.h"
21 #include "TList.h"
22
23 #include "AliHLTHOMERSourceDesc.h"
24 #include "AliHLTHOMERBlockDesc.h"
25 #include "AliHLTHOMERReader.h"
26 #include "AliHLTHOMERProxyHandler.h"
27
28 #include "AliHLTLogging.h"
29
30 class AliHLTHOMERLibManager;
31
32 /**
33  * @class AliHLTHOMERManager
34  * This Class should handle the communication
35  * from the HLT to aliroot. The HLT sends data via 
36  * the HOMER interface on several TCP ports of nodes 
37  * in the CERN GPN and DCS network.
38  * All this communication is hidden from the user.
39  * 
40  * Right now, a xml file ( SCC1 ) is used to get the
41  * configuration, this will/ has to change to a proxy
42  * running on dedicated nodes.
43  *
44  * @ingroup alihlt_homer
45  */
46
47 class AliHLTHOMERManager : public TObject, public AliHLTLogging {
48 public:
49   
50   /*
51    * ---------------------------------------------------------------------------------
52    *                            Constructor / Destructor
53    * ---------------------------------------------------------------------------------
54    */
55
56   /** default constructor */
57   AliHLTHOMERManager();
58
59   /** destructor */
60   virtual ~AliHLTHOMERManager();
61
62   /** Initialize 
63    *  @return 0 on success, <0 for failure
64    */
65   Int_t Initialize();
66
67   /*
68    * ---------------------------------------------------------------------------------
69    *                            Source Handling - public
70    * ---------------------------------------------------------------------------------
71    */
72
73   /** Create Sources List from HOMER-Proxy 
74    *  @return 0 on success, <0 for failure
75    */
76   virtual Int_t CreateSourcesList();
77
78   /** Set state of a source 
79    *  @param source      Pointer to AliHLTHOMERSourceDesc object.
80    *  @param state       New (selected/not selected) state.
81    */
82   void   SetSourceState( AliHLTHOMERSourceDesc* source, Bool_t state);
83
84   /** Get pointer to source List */
85   TList* GetSourceList() { return fSourceList; }
86
87   /*
88    * ---------------------------------------------------------------------------------
89    *                            Connection Handling - public
90    * ---------------------------------------------------------------------------------
91    */
92
93   /** Connect to HOMER sources, out of Readout List, 
94    *  which gets created when state has changed 
95    *  @return 0 on success, <0 for failure
96    */
97   Int_t ConnectHOMER();
98
99   /** Disconnect from HOMER sources */
100   void  DisconnectHOMER();
101
102   /** Reconnect from HOMER sources 
103    *  @return 0 on success, <0 for failure
104    */
105   Int_t ReconnectHOMER();
106
107   /*
108    * ---------------------------------------------------------------------------------
109    *                            Event Handling - public
110    * ---------------------------------------------------------------------------------
111    */
112
113   /** Loads the next Event, after being connected 
114    *  @return 0 on success, <0 for failure
115    */
116   virtual Int_t NextEvent();
117
118   /** Get event ID */
119   ULong_t GetEventID() { return fEventID; }    // Get event ID
120
121   /** Get pointer to block List */
122   TList* GetBlockList() { return fBlockList; } // Get pointer to block List
123   
124   ///////////////////////////////////////////////////////////////////////////////////
125
126 protected:
127
128   /** Dynamic loader manager for the HOMER library */
129   AliHLTHOMERLibManager* fLibManager;             //! transient
130
131   ///////////////////////////////////////////////////////////////////////////////////
132
133 private:
134
135   /** copy constructor prohibited */
136   AliHLTHOMERManager(const AliHLTHOMERManager&);
137
138   /** assignment operator prohibited */
139   AliHLTHOMERManager& operator=(const AliHLTHOMERManager&);
140
141   /*
142    * ---------------------------------------------------------------------------------
143    *                            Connection Handling - private
144    * ---------------------------------------------------------------------------------
145    */
146
147   /** Create a readout list for Hostname and ports 
148    *  @param socurceHostnames   Array of selected hostnames
149    *  @param socurcePorts       Array of selected ports
150    *  @param socurceCount       Number of selected hostname:port
151    */
152   void CreateReadoutList( const char** sourceHostnames, UShort_t* sourcePorts, 
153                           UInt_t &sourceCount);
154
155   /** Checks if already connected to HOMER sources */
156   Bool_t IsConnected() { return fConnected; }  
157   
158   /* ---------------------------------------------------------------------------------
159    *                            Event Handling - private
160    * ---------------------------------------------------------------------------------
161    */
162
163   /** Create a TList of blocks, which have been readout */
164   void CreateBlockList();
165
166   /*
167    * ---------------------------------------------------------------------------------
168    *                            Block Handling - private
169    * ---------------------------------------------------------------------------------
170    */
171
172   /** Get Number of blocks in current event */
173   ULong_t GetNBlks() { return fNBlks; }
174
175   // ----------------------------------------------------
176
177   /** Get pointer to block ndx in current event 
178    *  @param ndx        Block index
179    *  @return           returns pointer to blk, NULL if no block present
180    */
181   void* GetBlk( Int_t ndx );
182
183   /** Get pointer to current block in current event */
184   void* GetBlk() { return GetBlk(fCurrentBlk); }
185
186   /** Get first block in current event */
187   void* GetFirstBlk() { fCurrentBlk=0; return GetBlk(0); }
188
189   /** Get next block in current event */
190   void* GetNextBlk() { return GetBlk(++fCurrentBlk); }
191
192   // ----------------------------------------------------
193
194   /** Get size of block ndx 
195    *  @param ndx        Block index
196    *  @return           returns size blk, 0 otherwise
197    */
198   ULong_t GetBlkSize( Int_t ndx );
199
200   /** Get size of current block */ 
201   ULong_t GetBlkSize() { return GetBlkSize( fCurrentBlk ); }
202
203   // ---------------------------------------------------- 
204
205   /** Get origin of block ndx 
206    *  @param ndx        Block index
207    *  @return           origin of block
208    */
209   TString GetBlkOrigin( Int_t ndx );
210
211   /** Get origin of current block */
212   TString GetBlkOrigin(){ return GetBlkOrigin( fCurrentBlk ); }
213
214   // ----------------------------------------------------
215
216   /** Get type of block ndx 
217    *  @param ndx        Block index
218    *  @return           type of block
219    */
220   TString GetBlkType( Int_t ndx ); 
221
222   /** Get type of current block */
223   TString GetBlkType() { return GetBlkType( fCurrentBlk ); } 
224   
225   // ----------------------------------------------------
226   
227   /** Get specification of block ndx 
228    *  @param ndx        Block index
229    *  @return           specification of block
230    */
231   ULong_t GetBlkSpecification( Int_t ndx );
232
233   /** Get specification of current block */
234   ULong_t GetBlkSpecification() { return GetBlkSpecification( fCurrentBlk ); } 
235
236   // ----------------------------------------------------
237
238   /** Checks if current Block should was requested 
239    *  @return           returns kTRUE, if block should was requested
240    */
241   Bool_t CheckIfRequested( AliHLTHOMERBlockDesc* block );
242
243   /*
244    * ---------------------------------------------------------------------------------
245    *                            Members - private
246    * ---------------------------------------------------------------------------------
247    */
248
249   /** Proxy Handler to get the list of sources */
250   AliHLTHOMERProxyHandler *fProxyHandler;            //! transient 
251
252   // == connection ==
253
254   /** Pointer to HOMER reader */
255   AliHLTHOMERReader* fReader;                        //! transient 
256
257   // == sources ==
258
259   /** List to HOMER sources */
260   TList    *fSourceList;                             //! transient
261   
262   // == blocks ==
263
264   /** List to HOMER blocks */
265   TList    *fBlockList;                              //! transient
266
267   // == events ==
268
269   /** Number of blockes in current event */
270   ULong_t   fNBlks;                                  //  see above
271
272   /** EventID of current event */
273   ULong64_t fEventID;                                //  see above
274
275   /** Current block in current event */
276   ULong_t   fCurrentBlk;                             //  see above
277
278   // == states ==
279   
280   /** Shows connection status */
281   Bool_t    fConnected;                              //  see above
282
283   /** Indicates, if a sources have changes, 
284    *  so that one has to reconnect. */
285   Bool_t    fStateHasChanged;                        //  see above
286
287   ClassDef(AliHLTHOMERManager, 0); // Manage connections to HLT data-sources.
288 };
289
290 #endif