]>
Commit | Line | Data |
---|---|---|
2ff24e4c | 1 | |
6580df1c | 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 | */ | |
cef34fbe | 22 | #include "AliHLTDataTypes.h" |
23 | #include "TObject.h" // for ClassDef/Imp | |
6580df1c | 24 | |
25 | class AliHLTHOMERReader; | |
26 | class AliHLTHOMERWriter; | |
27 | ||
28 | /** | |
29 | * @class AliHLTHOMERLibManager | |
a183f221 | 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 | |
80442f92 | 47 | * while (pReader && pReader->ReadNextEvent(5000000)==0) { |
a183f221 | 48 | * unsigned long count=pReader->GetBlockCnt(); |
80442f92 | 49 | * gSystem->Sleep(5); |
a183f221 | 50 | * ... |
51 | * } | |
52 | * | |
53 | * // delete reader | |
54 | * manager.DeleteReader(pReader); | |
55 | * </pre> | |
56 | * | |
abda8541 | 57 | * The manager does not provide methods to create a HOMER reader on |
a183f221 | 58 | * basis of shared memory. This is most likely a depricated functionality, |
abda8541 | 59 | * although kept for the sake of completeness. However, at some point it |
60 | * might become useful. Please notify the developers if you need that | |
61 | * functionality. | |
2ff24e4c | 62 | * |
63 | * @ingroup alihlt_homer | |
6580df1c | 64 | */ |
cef34fbe | 65 | class AliHLTHOMERLibManager { |
6580df1c | 66 | public: |
67 | /** standard constructor */ | |
68 | AliHLTHOMERLibManager(); | |
69 | /** destructor */ | |
70 | virtual ~AliHLTHOMERLibManager(); | |
71 | ||
a183f221 | 72 | /** |
73 | * Open a homer reader working on a TCP port. | |
74 | */ | |
75 | AliHLTHOMERReader* OpenReader(const char* hostname, unsigned short port ); | |
76 | ||
77 | /** | |
78 | * Open a homer reader working on multiple TCP ports. | |
79 | */ | |
80 | AliHLTHOMERReader* OpenReader(unsigned int tcpCnt, const char** hostnames, unsigned short* ports); | |
81 | ||
82 | /** | |
83 | * Open a HOMER reader for reading from a System V shared memory segment. | |
84 | AliHLTHOMERReader* OpenReader(key_t shmKey, int shmSize ); | |
85 | */ | |
86 | ||
87 | /** | |
88 | * Open a HOMER reader for reading from multiple System V shared memory segments | |
89 | AliHLTHOMERReader* OpenReader(unsigned int shmCnt, key_t* shmKey, int* shmSize ); | |
90 | */ | |
91 | ||
92 | /** | |
93 | * Open a HOMER reader for reading from multiple TCP ports and multiple System V shared memory segments | |
94 | AliHLTHOMERReader* OpenReader(unsigned int tcpCnt, const char** hostnames, unsigned short* ports, | |
95 | unsigned int shmCnt, key_t* shmKey, int* shmSize ); | |
96 | */ | |
97 | ||
6580df1c | 98 | /** |
99 | * Open a HOMER reader. | |
100 | * Load HOMER library dynamically and create object working on the provided | |
101 | * buffer. | |
102 | */ | |
18b56222 | 103 | AliHLTHOMERReader* OpenReaderBuffer(const AliHLTUInt8_t* pBuffer, int size); |
6580df1c | 104 | |
105 | /** | |
106 | * Delete a HOMER reader. | |
107 | * Clean-up of the object is done inside the HOMER library. | |
108 | */ | |
109 | int DeleteReader(AliHLTHOMERReader* pReader); | |
110 | ||
111 | /** | |
112 | * Open a HOMER writer. | |
113 | * Load HOMER library dynamically and create object working on the provided | |
114 | * buffer. | |
115 | */ | |
116 | AliHLTHOMERWriter* OpenWriter(); | |
117 | ||
118 | /** | |
119 | * Delete a HOMER writer. | |
120 | * Clean-up of the object is done inside the HOMER library. | |
121 | */ | |
122 | int DeleteWriter(AliHLTHOMERWriter* pWriter); | |
123 | ||
124 | protected: | |
125 | ||
126 | private: | |
127 | /** copy constructor prohibited */ | |
128 | AliHLTHOMERLibManager(const AliHLTHOMERLibManager&); | |
129 | /** assignment operator prohibited */ | |
130 | AliHLTHOMERLibManager& operator=(const AliHLTHOMERLibManager&); | |
131 | ||
132 | /** | |
133 | * Load the HOMER library. | |
134 | */ | |
135 | int LoadHOMERLibrary(); | |
136 | ||
1b820a65 | 137 | /** |
138 | * Unloads the HOMER library. | |
139 | */ | |
140 | int UnloadHOMERLibrary(); | |
141 | ||
6580df1c | 142 | /** status of the loading of the HOMER library */ |
143 | int fLibraryStatus; //!transient | |
144 | ||
a183f221 | 145 | /** entry in the HOMER library */ |
d93ec7ca | 146 | void (*fFctCreateReaderFromTCPPort)(); //!transient |
a183f221 | 147 | |
148 | /** entry in the HOMER library */ | |
d93ec7ca | 149 | void (*fFctCreateReaderFromTCPPorts)(); //!transient |
a183f221 | 150 | |
6580df1c | 151 | /** entry in the HOMER library */ |
d93ec7ca | 152 | void (*fFctCreateReaderFromBuffer)(); //!transient |
6580df1c | 153 | |
154 | /** entry in the HOMER library */ | |
d93ec7ca | 155 | void (*fFctDeleteReader)(); //!transient |
6580df1c | 156 | |
157 | /** entry in the HOMER library */ | |
d93ec7ca | 158 | void (*fFctCreateWriter)(); //!transient |
6580df1c | 159 | |
160 | /** entry in the HOMER library */ | |
d93ec7ca | 161 | void (*fFctDeleteWriter)(); //!transient |
6580df1c | 162 | |
1b820a65 | 163 | /** Indicates the library that was actually (and if) loaded in LoadHOMERLibrary(). */ |
164 | const char* fLoadedLib; //!transient | |
165 | ||
166 | static const char* fgkLibraries[]; /// List of libraries to try and load. | |
167 | static int fgkLibRefCount[]; /// The library reference count to control when to unload the library. | |
168 | ||
6580df1c | 169 | ClassDef(AliHLTHOMERLibManager, 0) |
170 | }; | |
171 | #endif |