]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTHOMERLibManager.h
Various contributions by Jochen
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTHOMERLibManager.h
1
2 //-*- Mode: C++ -*-
3 // @(#) $Id$
4
5 #ifndef ALIHLTHOMERLIBMANAGER_H
6 #define ALIHLTHOMERLIBMANAGER_H
7 /* This file is property of and copyright by the ALICE HLT Project        * 
8  * ALICE Experiment at CERN, All rights reserved.                         *
9  * See cxx source for full Copyright notice                               */
10
11 /** @file   AliHLTHOMERLibManager.h
12     @author Matthias Richter
13     @date   
14     @brief  dynamic HLT HOMER reader/writer generation and destruction
15
16 // see below for class documentation
17 // or
18 // refer to README to build package
19 // or
20 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
21                                                                           */
22 #include "AliHLTDataTypes.h"
23 #include "TObject.h" // for ClassDef/Imp
24
25 class AliHLTHOMERReader;
26 class AliHLTHOMERWriter;
27
28 /**
29  * @class AliHLTHOMERLibManager
30  * Dynamic manager of HOMER library.
31  * The class allows to generate objects of HOMER readers and writers
32  * dynamically and loads also the HOMER lib. In order to write HOMER library
33  * independent code it is important to use the AliHLTMonitoringWriter/
34  * AliHLTMonitoringReader classes when ever class methods are used. Those
35  * classes just define a virtual interface. <br>
36  *
37  * Instead of creating a reader or writer by \em new and deleting it with
38  * \em delete, one has to use the Open and Delete methods of this class.
39  *
40  * <pre>
41  * AliHLTHOMERLibManager manager;
42  *
43  * // open a HOMER reader listening at port 23000 of the localhost
44  * AliHLTMonitoringReader* pReader=manager.OpenReader(localhost, 23000);
45  *
46  * // read next event, timeout 5s
47  * while (pReader && pReader->ReadNextEvent(5000000)==0) {
48  *   unsigned long count=pReader->GetBlockCnt();
49  *   gSystem->Sleep(5);
50  *   ...
51  * }
52  *
53  * // delete reader
54  * manager.DeleteReader(pReader);
55  * </pre>
56  *
57  * The manager does not not provide methods to create a HOMER reader on
58  * basis of shared memory. This is most likely a depricated functionality,
59  * although kept for the sake of completeness.
60  *
61  * @ingroup alihlt_homer
62  */
63 class AliHLTHOMERLibManager {
64  public:
65   /** standard constructor */
66   AliHLTHOMERLibManager();
67   /** destructor */
68   virtual ~AliHLTHOMERLibManager();
69
70   /**
71    * Open a homer reader working on a TCP port.
72    */
73   AliHLTHOMERReader* OpenReader(const char* hostname, unsigned short port );
74   
75   /**
76    * Open a homer reader working on multiple TCP ports.
77    */
78   AliHLTHOMERReader* OpenReader(unsigned int tcpCnt, const char** hostnames, unsigned short* ports);
79         
80   /**
81    * Open a HOMER reader for reading from a System V shared memory segment.
82   AliHLTHOMERReader* OpenReader(key_t shmKey, int shmSize );
83    */
84         
85   /**
86    * Open a HOMER reader for reading from multiple System V shared memory segments
87   AliHLTHOMERReader* OpenReader(unsigned int shmCnt, key_t* shmKey, int* shmSize );
88    */
89         
90   /**
91    * Open a HOMER reader for reading from multiple TCP ports and multiple System V shared memory segments
92   AliHLTHOMERReader* OpenReader(unsigned int tcpCnt, const char** hostnames, unsigned short* ports, 
93                                     unsigned int shmCnt, key_t* shmKey, int* shmSize );
94    */
95
96   /**
97    * Open a HOMER reader.
98    * Load HOMER library dynamically and create object working on the provided
99    * buffer.
100    */
101   AliHLTHOMERReader* OpenReaderBuffer(const AliHLTUInt8_t* pBuffer, int size);
102
103   /**
104    * Delete a HOMER reader.
105    * Clean-up of the object is done inside the HOMER library.
106    */
107   int DeleteReader(AliHLTHOMERReader* pReader);
108
109   /**
110    * Open a HOMER writer.
111    * Load HOMER library dynamically and create object working on the provided
112    * buffer.
113    */
114   AliHLTHOMERWriter* OpenWriter();
115
116   /**
117    * Delete a HOMER writer.
118    * Clean-up of the object is done inside the HOMER library.
119    */
120   int DeleteWriter(AliHLTHOMERWriter* pWriter);
121
122  protected:
123
124  private:
125   /** copy constructor prohibited */
126   AliHLTHOMERLibManager(const AliHLTHOMERLibManager&);
127   /** assignment operator prohibited */
128   AliHLTHOMERLibManager& operator=(const AliHLTHOMERLibManager&);
129
130   /**
131    * Load the HOMER library.
132    */
133   int LoadHOMERLibrary();
134
135   /** status of the loading of the HOMER library */
136   int fLibraryStatus; //!transient
137
138   /** entry in the HOMER library */
139   void* fFctCreateReaderFromTCPPort; //!transient
140
141   /** entry in the HOMER library */
142   void* fFctCreateReaderFromTCPPorts; //!transient
143
144   /** entry in the HOMER library */
145   void* fFctCreateReaderFromBuffer; //!transient
146
147   /** entry in the HOMER library */
148   void* fFctDeleteReader; //!transient
149
150   /** entry in the HOMER library */
151   void* fFctCreateWriter; //!transient
152
153   /** entry in the HOMER library */
154   void* fFctDeleteWriter; //!transient
155
156   ClassDef(AliHLTHOMERLibManager, 0)
157 };
158 #endif