]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/Alieve/AliEVEHOMERManager.h
New class AliEVEHOMERManager; interface to HLT data sources.
[u/mrichter/AliRoot.git] / EVE / Alieve / AliEVEHOMERManager.h
1 //-*- Mode: C++ -*-
2 #ifndef ALIEVEHOMERMANGER_H
3 #define ALIEVEHOMERMANGER_H
4
5 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
6  * See cxx source for full Copyright notice                               */
7
8 /** @file   AliEVEHOMERManager.h
9     @author Jochen Thaeder
10     @date   
11     @brief  Manager for HOMER in offline
12 */
13
14 #include <Reve/RenderElement.h>
15
16 #include "TString.h"
17 #include "TDOMParser.h"
18 #include "TXMLNode.h"
19 #include "TList.h"
20
21 #include "AliHLTHOMERSourceDesc.h"
22 #include "AliHLTHOMERBlockDesc.h"
23 #include "AliHLTHOMERReader.h"
24 class AliHLTHOMERLibManager;
25
26 /**
27  * @class AliEVEHOMERManager
28  * 
29  * This class is the main class of the AliEVEHOMERManager
30  * ... more to come
31  *
32  * @ingroup alihlt_homer
33  */
34
35 class AliEVEHOMERManager : public Reve::RenderElementList
36 {
37 public:
38
39   /*
40    * ---------------------------------------------------------------------------------
41    *                            Constructor / Destructor 
42    * --------------------------------------------------------------------------------- 
43    */
44
45   /** constructor 
46    * @param argc    Number of command line arguments.
47    * @param argv    Array of command line arguments.
48    */
49   AliEVEHOMERManager(TString xmlFile="" );       
50   /** not a valid copy constructor, defined according to effective C++ style */
51   AliEVEHOMERManager( const AliEVEHOMERManager& );       
52   /** not a valid assignment op, but defined according to effective C++ style */
53   AliEVEHOMERManager& operator=( const AliEVEHOMERManager& );       
54   /** destructor */
55   virtual ~AliEVEHOMERManager();
56
57   /*
58    * ---------------------------------------------------------------------------------
59    *                            Source Handling - public
60    * --------------------------------------------------------------------------------- 
61    */
62   
63   /** Create Sources List from HOMER-Proxy */
64   Int_t CreateHOMERSourcesList();
65
66   /** Set state of a source
67    * @param source      Pointer to AliHLTHOMERSourceDesc object.
68    * @param state       New (selected/not selected) state.
69    */
70   void SetSourceState( AliHLTHOMERSourceDesc* source, Bool_t state); 
71
72   /** Get pointer to source List
73    * @return            returns pointer to TList of sources
74    */
75   TList* GetSourceList() { return fSourceList; }
76
77   /*
78    * ---------------------------------------------------------------------------------
79    *                            Connection Handling - public
80    * --------------------------------------------------------------------------------- 
81    */
82   
83   /** Connect to HOMER sources, out of Readout List, which gets created when state has changed
84    * @return            0 on sucess, "HOMER" errors on error      
85    */
86   Int_t ConnectHOMER();
87
88   /** Disconnect from HOMER sources */
89   void DisconnectHOMER();
90
91   /** Reconnect from HOMER sources
92    * @return            0 on sucess, "ConnectHOMER()" errors on error
93    */
94   Int_t ReconnectHOMER();
95
96   /*
97    * ---------------------------------------------------------------------------------
98    *                            Event Handling - public
99    * --------------------------------------------------------------------------------- 
100    */
101
102   /** Loads the next Event, after being connected 
103    * @return            0 on sucess, "HOMER" errors on error   
104    */
105   Int_t NextEvent();
106   
107   /** Get event ID
108    * @return            Returns eventID
109    */
110   ULong_t GetEventID() { return fEventID; }
111
112   /** Get pointer to block List
113    * @return            returns pointer to TList of blocks
114    */
115   TList* GetBlockList() { return fBlockList; }
116
117
118   ///////////////////////////////////////////////////////////////////////////////////
119
120   void TestSelect();
121
122   ///////////////////////////////////////////////////////////////////////////////////
123
124 protected:
125
126   /** Dynamic loader manager for the HOMER library */
127   AliHLTHOMERLibManager* fLibManager;             //! transient
128   
129
130 private:
131
132   /*
133    * ---------------------------------------------------------------------------------
134    *                            Source Handling - private
135    * --------------------------------------------------------------------------------- 
136    */
137   
138   /** Get Information out of a TDS process in XML file
139    * @param xmlNode   Pointer to childs of TDS node
140    * @return          0 on sucess, > 0 on error 
141    */
142   Int_t GetTDSAttributes( TXMLNode * xmlNode );
143
144   /** Resolve Information of hostname and port for source which has to be used by HOMER
145    * ( due to port mapping inside the HLT )
146    * @param xmlHostname  Hostname out of the XML
147    * @param xmlPort      Port out of the XML
148    * @param hostname     Return of the hostname
149    * @param port         Return of the port
150    * @return             0 on sucess, 1 if hostname couldn't be resolved, 2 if port couldn't be resolved, 
151    */
152   Int_t ResolveHostPortInformation( TString xmlHostname, TString xmlPort, TString &hostname, Int_t &port );
153
154   /** Resolve information of source 
155    * @param xmlParent   ParentString out of the XML
156    * @param source      Return the filled AliHLTHOMERSourceDesc object
157    * @return            0 on sucess, 1 on error
158    */
159   Int_t ResolveSourceInformation( TString xmlParent, AliHLTHOMERSourceDesc * source );
160
161   /*
162    * ---------------------------------------------------------------------------------
163    *                            Connection Handling - private
164    * --------------------------------------------------------------------------------- 
165    */
166   
167   /** Create a readout list for Hostname and ports   
168    * @param socurceHostnames   Array of selected hostnames
169    * @param socurcePorts       Array of selected ports
170    * @param socurceCount       Number of selected hostname:port
171    */
172   void CreateReadoutList( const char** socurceHostnames, UShort_t* sourcePorts, UInt_t &sourceCount);
173
174   /** Checks if already connected to HOMER sources
175    * @return             kTRUE or kFALSE, depending on connection state
176    */
177   Bool_t IsConnected() { return fConnected; }
178
179   /* ---------------------------------------------------------------------------------
180    *                            Event Handling - private
181    * --------------------------------------------------------------------------------- 
182    */
183   
184   /** Create a TList of blocks, which have been readout */
185   Int_t CreateBlockList();
186
187   /*
188    * ---------------------------------------------------------------------------------
189    *                            Block Handling - private
190    * --------------------------------------------------------------------------------- 
191    */
192
193   /** Get Number of blocks in current event
194    * @return           returns number of blocks in current event
195    */
196   ULong_t GetNBlks() { return fNBlks; }
197
198   /** Get pointer to block ndx in current event
199    * @param ndx        Block index
200    * @return           returns pointer to blk, NULL if no block present
201    */
202   void* GetBlk( Int_t ndx );
203
204   /** Get pointer to current block in current event
205    * @param ndx        Block index
206    * @return           returns pointer to blk, NULL if no block present
207    */
208   void* GetBlk() { return GetBlk( fCurrentBlk ); }
209
210   /** Get first block in current event
211    * @return           returns pointer to blk, NULL if no block present
212    */
213   void* GetFirstBlk() { return GetBlk( 0 ); }
214
215   /** Get next block in current event
216    * @return           returns pointer to blk, NULL if no block present
217    */
218   void* GetNextBlk() { return GetBlk( ++fCurrentBlk ); }
219
220   /** Get size of block ndx
221    * @param ndx        Block index
222    * @return           returns pointer to blk, 0 if no block present
223    */
224   ULong_t GetBlkSize( Int_t ndx );
225
226   /** Get size of current block
227    * @param ndx        Block index
228    * @return           returns pointer to blk, 0 if no block present
229    */
230   ULong_t GetBlkSize() { return GetBlkSize( fCurrentBlk ); }
231   
232   /** Get origin of block ndx
233    * @param ndx        Block index
234    * @return           origin of block
235    */
236   TString GetBlkOrigin( Int_t ndx );  
237   
238   /** Get origin of current block
239    * @param ndx        Block index
240    * @return           origin of block
241    */
242   TString GetBlkOrigin(){ return GetBlkOrigin( fCurrentBlk ); }
243
244   /** Get type of block ndx
245    * @param ndx        Block index
246    * @return           type of block
247    */
248   TString GetBlkType( Int_t ndx );
249
250   /** Get type of current block
251    * @param ndx        Block index
252    * @return           type of block
253    */
254   TString GetBlkType() { return GetBlkType( fCurrentBlk ); }
255
256   /** Get specification of block ndx
257    * @param ndx        Block index
258    * @return           specification of block
259    */
260   ULong_t GetBlkSpecification( Int_t ndx );
261
262   /** Get specification of current block
263    * @param ndx        Block index
264    * @return           specification of block
265    */ 
266   ULong_t GetBlkSpecification(){ return GetBlkSpecification( fCurrentBlk ); }
267
268   /** Checks if current Block should was requested
269    * @return           returns kTRUE, if block should was requested
270    */
271   Bool_t CheckIfRequested( AliHLTHOMERBlockDesc* block );
272
273   /*
274    * ---------------------------------------------------------------------------------
275    *                            Members - private
276    * --------------------------------------------------------------------------------- 
277    */
278
279   // == XML parser ==
280
281   /** XML input file */
282   TString fXMLFile;                               // see above
283
284   /** XML parser into DOM model */
285   TDOMParser* fXMLParser;                         //! transient  
286   
287   /** Root node of parsed config file */
288   TXMLNode * fRootNode;                           //! transient  
289
290   // == sources ==
291
292   /** List to HOMER sources */
293   TList * fSourceList;                            //! transient  
294
295   // == connection ==
296   
297
298   /** Pointer to HOMER reader */
299   AliHLTHOMERReader* fReader;                     //! transient  
300
301   // == blocks ==
302
303   /** List to HOMER blocks */
304   TList * fBlockList;                             //! transient  
305
306   // == events ==
307   
308   /** Number of blockes in current event */
309   ULong_t fNBlks;                                 // see above
310
311   /** EventID of current event */
312   ULong64_t fEventID;                             // see above
313
314   /** Current block in current event */
315   ULong_t fCurrentBlk;                            // see above
316   
317   // == states ==
318
319   /** Shows connection status */
320   Bool_t fConnected;                              // see above
321
322   /** Indicates, if a sources have changes, 
323    *  so that one has to reconnect .
324    */
325   Bool_t fStateHasChanged;                        // see above
326
327   ClassDef( AliEVEHOMERManager, 0 )
328 };
329
330 #endif