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 #include "AliHLTDataTypes.h"
17 #include "TObject.h" // for ClassDef/Imp
19 class AliHLTHOMERReader;
20 class AliHLTHOMERWriter;
23 * @class AliHLTHOMERLibManager
24 * Dynamic manager of HOMER library.
25 * The class allows to generate objects of HOMER readers and writers
26 * dynamically and loads also the HOMER lib. In order to write HOMER library
27 * independent code it is important to use the AliHLTMonitoringWriter/
28 * AliHLTMonitoringReader classes when ever class methods are used. Those
29 * classes just define a virtual interface. <br>
31 * Instead of creating a reader or writer by \em new and deleting it with
32 * \em delete, one has to use the Open and Delete methods of this class.
35 * AliHLTHOMERLibManager manager;
37 * // open a HOMER reader listening at port 23000 of the localhost
38 * AliHLTMonitoringReader* pReader=manager.OpenReader(localhost, 23000);
40 * // read next event, timeout 5s
41 * while (pReader && pReader->ReadNextEvent(5000000)==0) {
42 * unsigned long count=pReader->GetBlockCnt();
48 * manager.DeleteReader(pReader);
51 * The manager does not provide methods to create a HOMER reader on
52 * basis of shared memory. This is most likely a depricated functionality,
53 * although kept for the sake of completeness. However, at some point it
54 * might become useful. Please notify the developers if you need that
57 * @ingroup alihlt_homer
59 class AliHLTHOMERLibManager {
61 /** standard constructor */
62 AliHLTHOMERLibManager();
64 virtual ~AliHLTHOMERLibManager();
67 * Open a homer reader working on a TCP port.
69 AliHLTHOMERReader* OpenReader(const char* hostname, unsigned short port );
72 * Open a homer reader working on multiple TCP ports.
74 AliHLTHOMERReader* OpenReader(unsigned int tcpCnt, const char** hostnames, unsigned short* ports);
77 * Open a HOMER reader for reading from a System V shared memory segment.
78 AliHLTHOMERReader* OpenReader(key_t shmKey, int shmSize );
82 * Open a HOMER reader for reading from multiple System V shared memory segments
83 AliHLTHOMERReader* OpenReader(unsigned int shmCnt, key_t* shmKey, int* shmSize );
87 * Open a HOMER reader for reading from multiple TCP ports and multiple System V shared memory segments
88 AliHLTHOMERReader* OpenReader(unsigned int tcpCnt, const char** hostnames, unsigned short* ports,
89 unsigned int shmCnt, key_t* shmKey, int* shmSize );
93 * Open a HOMER reader.
94 * Load HOMER library dynamically and create object working on the provided
97 AliHLTHOMERReader* OpenReaderBuffer(const AliHLTUInt8_t* pBuffer, int size);
100 * Delete a HOMER reader.
101 * Clean-up of the object is done inside the HOMER library.
103 int DeleteReader(AliHLTHOMERReader* pReader);
106 * Open a HOMER writer.
107 * Load HOMER library dynamically and create object working on the provided
110 AliHLTHOMERWriter* OpenWriter();
113 * Delete a HOMER writer.
114 * Clean-up of the object is done inside the HOMER library.
116 int DeleteWriter(AliHLTHOMERWriter* pWriter);
121 /** copy constructor prohibited */
122 AliHLTHOMERLibManager(const AliHLTHOMERLibManager&);
123 /** assignment operator prohibited */
124 AliHLTHOMERLibManager& operator=(const AliHLTHOMERLibManager&);
127 * Load the HOMER library.
129 int LoadHOMERLibrary();
132 * Unloads the HOMER library.
134 int UnloadHOMERLibrary();
136 /** status of the loading of the HOMER library */
137 static int fgLibraryStatus; //!transient
139 /** entry in the HOMER library */
140 void (*fFctCreateReaderFromTCPPort)(); //!transient
142 /** entry in the HOMER library */
143 void (*fFctCreateReaderFromTCPPorts)(); //!transient
145 /** entry in the HOMER library */
146 void (*fFctCreateReaderFromBuffer)(); //!transient
148 /** entry in the HOMER library */
149 void (*fFctDeleteReader)(); //!transient
151 /** entry in the HOMER library */
152 void (*fFctCreateWriter)(); //!transient
154 /** entry in the HOMER library */
155 void (*fFctDeleteWriter)(); //!transient
157 /** Indicates the library that was actually (and if) loaded in LoadHOMERLibrary(). */
158 const char* fLoadedLib; //!transient
160 static const char* fgkLibraries[]; /// List of libraries to try and load.
161 static int fgkLibRefCount[]; /// The library reference count to control when to unload the library.
163 ClassDef(AliHLTHOMERLibManager, 0)