]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTHOMERLibManager.h
change loading scheme of the HOMER library following Rubens suggestion in an attempt...
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTHOMERLibManager.h
CommitLineData
2ff24e4c 1
6580df1c 2//-*- Mode: C++ -*-
c012695e 3// $Id$
6580df1c 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
c012695e 11/// @file AliHLTHOMERLibManager.h
12/// @author Matthias Richter
13/// @date
14/// @brief dynamic HLT HOMER reader/writer generation and destruction
15
cef34fbe 16#include "AliHLTDataTypes.h"
17#include "TObject.h" // for ClassDef/Imp
6580df1c 18
19class AliHLTHOMERReader;
20class AliHLTHOMERWriter;
21
22/**
23 * @class AliHLTHOMERLibManager
a183f221 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>
30 *
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.
33 *
34 * <pre>
35 * AliHLTHOMERLibManager manager;
36 *
37 * // open a HOMER reader listening at port 23000 of the localhost
38 * AliHLTMonitoringReader* pReader=manager.OpenReader(localhost, 23000);
39 *
40 * // read next event, timeout 5s
80442f92 41 * while (pReader && pReader->ReadNextEvent(5000000)==0) {
a183f221 42 * unsigned long count=pReader->GetBlockCnt();
80442f92 43 * gSystem->Sleep(5);
a183f221 44 * ...
45 * }
46 *
47 * // delete reader
48 * manager.DeleteReader(pReader);
49 * </pre>
50 *
abda8541 51 * The manager does not provide methods to create a HOMER reader on
a183f221 52 * basis of shared memory. This is most likely a depricated functionality,
abda8541 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
55 * functionality.
2ff24e4c 56 *
57 * @ingroup alihlt_homer
6580df1c 58 */
cef34fbe 59class AliHLTHOMERLibManager {
6580df1c 60 public:
61 /** standard constructor */
62 AliHLTHOMERLibManager();
63 /** destructor */
64 virtual ~AliHLTHOMERLibManager();
65
a183f221 66 /**
67 * Open a homer reader working on a TCP port.
68 */
69 AliHLTHOMERReader* OpenReader(const char* hostname, unsigned short port );
70
71 /**
72 * Open a homer reader working on multiple TCP ports.
73 */
74 AliHLTHOMERReader* OpenReader(unsigned int tcpCnt, const char** hostnames, unsigned short* ports);
75
76 /**
77 * Open a HOMER reader for reading from a System V shared memory segment.
78 AliHLTHOMERReader* OpenReader(key_t shmKey, int shmSize );
79 */
80
81 /**
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 );
84 */
85
86 /**
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 );
90 */
91
6580df1c 92 /**
93 * Open a HOMER reader.
94 * Load HOMER library dynamically and create object working on the provided
95 * buffer.
96 */
18b56222 97 AliHLTHOMERReader* OpenReaderBuffer(const AliHLTUInt8_t* pBuffer, int size);
6580df1c 98
99 /**
100 * Delete a HOMER reader.
101 * Clean-up of the object is done inside the HOMER library.
102 */
103 int DeleteReader(AliHLTHOMERReader* pReader);
104
105 /**
106 * Open a HOMER writer.
107 * Load HOMER library dynamically and create object working on the provided
108 * buffer.
109 */
110 AliHLTHOMERWriter* OpenWriter();
111
112 /**
113 * Delete a HOMER writer.
114 * Clean-up of the object is done inside the HOMER library.
115 */
116 int DeleteWriter(AliHLTHOMERWriter* pWriter);
117
118 protected:
119
120 private:
121 /** copy constructor prohibited */
122 AliHLTHOMERLibManager(const AliHLTHOMERLibManager&);
123 /** assignment operator prohibited */
124 AliHLTHOMERLibManager& operator=(const AliHLTHOMERLibManager&);
125
126 /**
127 * Load the HOMER library.
128 */
129 int LoadHOMERLibrary();
130
1b820a65 131 /**
132 * Unloads the HOMER library.
133 */
134 int UnloadHOMERLibrary();
135
6580df1c 136 /** status of the loading of the HOMER library */
c012695e 137static int fgLibraryStatus; //!transient
6580df1c 138
a183f221 139 /** entry in the HOMER library */
d93ec7ca 140 void (*fFctCreateReaderFromTCPPort)(); //!transient
a183f221 141
142 /** entry in the HOMER library */
d93ec7ca 143 void (*fFctCreateReaderFromTCPPorts)(); //!transient
a183f221 144
6580df1c 145 /** entry in the HOMER library */
d93ec7ca 146 void (*fFctCreateReaderFromBuffer)(); //!transient
6580df1c 147
148 /** entry in the HOMER library */
d93ec7ca 149 void (*fFctDeleteReader)(); //!transient
6580df1c 150
151 /** entry in the HOMER library */
d93ec7ca 152 void (*fFctCreateWriter)(); //!transient
6580df1c 153
154 /** entry in the HOMER library */
d93ec7ca 155 void (*fFctDeleteWriter)(); //!transient
6580df1c 156
1b820a65 157 /** Indicates the library that was actually (and if) loaded in LoadHOMERLibrary(). */
158 const char* fLoadedLib; //!transient
159
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.
162
6580df1c 163 ClassDef(AliHLTHOMERLibManager, 0)
164};
165#endif