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 */
11 /** @file AliHLTHOMERLibManager.h
12 @author Matthias Richter
14 @brief dynamic HLT HOMER reader/writer generation and destruction
16 // see below for class documentation
18 // refer to README to build package
20 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
22 #include "AliHLTDataTypes.h"
23 #include "TObject.h" // for ClassDef/Imp
25 class AliHLTHOMERReader;
26 class AliHLTHOMERWriter;
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>
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.
41 * AliHLTHOMERLibManager manager;
43 * // open a HOMER reader listening at port 23000 of the localhost
44 * AliHLTMonitoringReader* pReader=manager.OpenReader(localhost, 23000);
46 * // read next event, timeout 5s
47 * while (pReader && pReader->ReadNextEvent(5000000)==0) {
48 * unsigned long count=pReader->GetBlockCnt();
54 * manager.DeleteReader(pReader);
57 * The manager does 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. However, at some point it
60 * might become useful. Please notify the developers if you need that
63 * @ingroup alihlt_homer
65 class AliHLTHOMERLibManager {
67 /** standard constructor */
68 AliHLTHOMERLibManager();
70 virtual ~AliHLTHOMERLibManager();
73 * Open a homer reader working on a TCP port.
75 AliHLTHOMERReader* OpenReader(const char* hostname, unsigned short port );
78 * Open a homer reader working on multiple TCP ports.
80 AliHLTHOMERReader* OpenReader(unsigned int tcpCnt, const char** hostnames, unsigned short* ports);
83 * Open a HOMER reader for reading from a System V shared memory segment.
84 AliHLTHOMERReader* OpenReader(key_t shmKey, int shmSize );
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 );
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 );
99 * Open a HOMER reader.
100 * Load HOMER library dynamically and create object working on the provided
103 AliHLTHOMERReader* OpenReaderBuffer(const AliHLTUInt8_t* pBuffer, int size);
106 * Delete a HOMER reader.
107 * Clean-up of the object is done inside the HOMER library.
109 int DeleteReader(AliHLTHOMERReader* pReader);
112 * Open a HOMER writer.
113 * Load HOMER library dynamically and create object working on the provided
116 AliHLTHOMERWriter* OpenWriter();
119 * Delete a HOMER writer.
120 * Clean-up of the object is done inside the HOMER library.
122 int DeleteWriter(AliHLTHOMERWriter* pWriter);
127 /** copy constructor prohibited */
128 AliHLTHOMERLibManager(const AliHLTHOMERLibManager&);
129 /** assignment operator prohibited */
130 AliHLTHOMERLibManager& operator=(const AliHLTHOMERLibManager&);
133 * Load the HOMER library.
135 int LoadHOMERLibrary();
138 * Unloads the HOMER library.
140 int UnloadHOMERLibrary();
142 /** status of the loading of the HOMER library */
143 int fLibraryStatus; //!transient
145 /** entry in the HOMER library */
146 void (*fFctCreateReaderFromTCPPort)(); //!transient
148 /** entry in the HOMER library */
149 void (*fFctCreateReaderFromTCPPorts)(); //!transient
151 /** entry in the HOMER library */
152 void (*fFctCreateReaderFromBuffer)(); //!transient
154 /** entry in the HOMER library */
155 void (*fFctDeleteReader)(); //!transient
157 /** entry in the HOMER library */
158 void (*fFctCreateWriter)(); //!transient
160 /** entry in the HOMER library */
161 void (*fFctDeleteWriter)(); //!transient
163 /** Indicates the library that was actually (and if) loaded in LoadHOMERLibrary(). */
164 const char* fLoadedLib; //!transient
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.
169 ClassDef(AliHLTHOMERLibManager, 0)