]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTComponentHandler.h
corrected compilation warnings
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTComponentHandler.h
CommitLineData
30338a30 1//-*- Mode: C++ -*-
f23a6e1a 2// @(#) $Id$
3
4#ifndef ALIHLTCOMPONENTHANDLER_H
5#define ALIHLTCOMPONENTHANDLER_H
6/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
7 * See cxx source for full Copyright notice */
8
b22e91eb 9/** @file AliHLTComponentHandler.h
10 @author Matthias Richter, Timm Steinbeck
11 @date
12 @brief Global handling of HLT processing components
13 @note The handler is part of the interface and both used in the
14 Online (PubSub) and Offline (AliRoot) context.
15 */
30338a30 16
17// see below for class documentation
18// or
19// refer to README to build package
20// or
21// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
f23a6e1a 22
8ede8717 23#include <vector>
5df0cbb9 24//#include "TObject.h"
f23a6e1a 25#include "AliHLTDataTypes.h"
5ec8e281 26#include "AliHLTLogging.h"
f23a6e1a 27
28class AliHLTComponent;
29struct AliHLTComponentEnvironment;
8ede8717 30struct AliHLTComponentDataType;
f23a6e1a 31
fa760045 32/**
33 * @class AliHLTComponentHandler
34 * The component handler controls all the processing components available in
35 * the system. It also controls the component shared libraries.
36 * @ingroup alihlt_component
37 */
5ec8e281 38class AliHLTComponentHandler : public AliHLTLogging {
f23a6e1a 39 public:
fa760045 40 /** standard constructor */
f23a6e1a 41 AliHLTComponentHandler();
3cde846d 42 /** constructor */
43 AliHLTComponentHandler(AliHLTComponentEnvironment* pEnv);
fa760045 44 /** destructor */
f23a6e1a 45 virtual ~AliHLTComponentHandler();
46
fa760045 47 /**
48 * Set the environment for the HLT framework.
49 * The environment mainly consists of function pointers for the integration
50 * of the HLT framework into a system like the PubSub online system or
51 * AliRoot offline system.
52 * @param pEnv pointer to @ref AliHLTComponentEnvironment structure
53 * @return none
54 */
f23a6e1a 55 void SetEnvironment(AliHLTComponentEnvironment* pEnv);
56
fa760045 57 /**
58 * Load a component shared library.
59 * The component library needs to be loaded from the ComponentHanler in order
60 * to automatically register all components in the library.
61 * Registration is done by passing a sample object of the component to the
62 * handler. The object has to be valid during the whole runtime and should
63 * thus be a global object which is ONLY used for the purpose of registration.
64 * This also ensures automatically registration at library load time.
65 * @param libraryPath const char string containing the library name/path
66 * @return 0 if succeeded, neg. error code if failed
67 */
f23a6e1a 68 int LoadLibrary( const char* libraryPath );
fa760045 69
85f0cede 70 /**
71 * Find a symbol in a dynamically loaded library.
72 * @param library library
73 * @param symbol the symbol to find
74 * @return void pointer to function
75 */
76 void* FindSymbol(const char* library, const char* symbol);
77
fa760045 78 /**
79 * Unload a component shared library.
a742f6f8 80 * All components will be de-registered when the last instance of the
81 * library was unloaded.
fa760045 82 * @param libraryPath library name as specified to @ref LoadLibrary
83 * @return 0 if succeeded, neg. error code if failed
84 */
f23a6e1a 85 int UnloadLibrary( const char* libraryPath );
86
fa760045 87 /**
88 * Schedule a component for registration.
89 * Full registration will be done after successfull loading of the shared
90 * library.
91 * @param pSample a sample object of the component
92 * @return neg. error code if failed
f23a6e1a 93 */
f23a6e1a 94 int ScheduleRegister(AliHLTComponent* pSample );
95
fa760045 96 /**
97 * Register a component.
98 * Registration is done by passing a sample object of the component to the
99 * handler. The object has to be valid during the whole runtime and should
100 * thus be a global object which is ONLY used for the purpose of registration.
101 * @param pSample a sample object of the component
102 * @return neg. error code if failed
103 */
f23a6e1a 104 int RegisterComponent(AliHLTComponent* pSample );
f23a6e1a 105
9ce4bf4a 106 /**
107 * Registers all scheduled components.
108 */
109 int RegisterScheduledComponents();
110
fa760045 111 /**
112 * Deregister a component.
113 * @param componentID ID of the component
114 * @return neg. error code if failed
115 */
116 int DeregisterComponent( const char* componentID );
f23a6e1a 117
9ce4bf4a 118 /**
119 * Add standard components
120 * The standard components are part of the libHLTbase library and
121 * need therefore a special handling.
122 */
123 int AddStandardComponents();
124
125 /**
126 */
127 int DeleteStandardComponents();
128
fa760045 129 /**
130 * Find the ID of a component with the given output data.
131 * @param dtype data type descriptor
132 * @param prevType can be used to iterate if there are multiple components
133 * with the same output data type.
134 * @return component id
135 */
8ede8717 136 //const char* FindComponentType( AliHLTComponentDataType dtype,
fa760045 137 // const char* prevType = NULL )
138 // { return NULL;}
139
140 /**
141 * Create a component of the given name (ID).
c215072c 142 * The method tries to find a registerd component of id \em componentID and
143 * calls the \em Spawn method of the template component. After successful
144 * creation of a new object, the Init method is called in order to initialize
145 * the environment and the component arguments. <br>
2d7ff710 146 * The environment is the same for all components, but each component can
147 * have an additional private parameter \em pEnvParam.<br>
c215072c 148 * The component arguments consist of an array of strings and the array size
149 * in the usual manner of the main() function.
fa760045 150 * @param componentID ID of the component to create
2d7ff710 151 * @param pEnvParam environment parameter for the component
db16520a 152 * @param argc number of arguments in argv
fa760045 153 * @param argv argument array like in main()
154 * @param component reference to receive the create component instance
db16520a 155 * @return component pointer in component, neg. error code if failed
fa760045 156 */
2d7ff710 157 int CreateComponent( const char* componentID, void* pEnvParam,
fa760045 158 int argc, const char** argv, AliHLTComponent*& component );
159
160 /**
161 * Create a component of the given name (ID).
162 * Introduced for backward compatibility.
163 * @param componentID ID of the component to create
2d7ff710 164 * @param pEnvParam environment parameter for the component
fa760045 165 * @param component reference to receive the create component instance
db16520a 166 * @return component pointer in component, neg. error code if failed
fa760045 167 */
2d7ff710 168 int CreateComponent( const char* componentID, void* pEnvParam,
fa760045 169 AliHLTComponent*& component )
170 {
2d7ff710 171 return CreateComponent( componentID, pEnvParam, 0, NULL, component );
fa760045 172 }
173
174 /**
175 * Print registered components to stdout.
176 * @return none
f23a6e1a 177 */
178 void List();
fa760045 179
180 /**
181 * Announce version and compilation info of the base library.
182 */
183 int AnnounceVersion();
184
f23a6e1a 185 protected:
f23a6e1a 186
187 private:
298ef463 188 /** copy constructor prohibited */
189 AliHLTComponentHandler(const AliHLTComponentHandler&);
190 /** assignment operator prohibited */
191 AliHLTComponentHandler& operator=(const AliHLTComponentHandler&);
192
fa760045 193 /**
194 * Find a component.
195 * @param componentID ID of the component to find
196 * @return index, neg. error code if failed
197 */
f23a6e1a 198 int FindComponentIndex(const char* componentID);
199
fa760045 200 /**
201 * Find a component.
202 * @param componentID ID of the component to find
203 * @return descriptor
204 */
f23a6e1a 205 AliHLTComponent* FindComponent(const char* componentID);
206
fa760045 207 /**
208 * Insert component to the list
209 * @param pSample sample object of the component
210 * @return neg. error code if failed
211 */
f23a6e1a 212 int InsertComponent(AliHLTComponent* pSample);
213
fa760045 214 /**
215 * Close all libraries.
216 * @return neg. error code if failed
217 */
f23a6e1a 218 int UnloadLibraries();
219
c215072c 220 /**
221 * Compount descriptor for component libraries
222 */
223 struct AliHLTLibHandle {
5df0cbb9 224 AliHLTLibHandle() : fHandle(NULL), fName(NULL) {}
c215072c 225 /** dlopen handle */
5df0cbb9 226 void* fHandle; //! transient
c215072c 227 /** name of the library, casted to TString* before use */
5df0cbb9 228 void* fName; //! transient
c215072c 229 };
230
85f0cede 231 /**
232 * Find a specific library among the loaded libraries.
233 * @param library library name/path
234 * @return pointer to AliHLTLibHandle
235 */
236 AliHLTLibHandle* FindLibrary(const char* library);
237
a742f6f8 238 /**
239 * Unload a component shared library.
240 * All components will be de-registered when the last instance of the
241 * library was unloaded.
242 * @param handle handle to the library to unload
243 * @return 0 if succeeded, neg. error code if failed
244 */
245 int UnloadLibrary(AliHLTComponentHandler::AliHLTLibHandle &handle);
246
fa760045 247 /** list of registered components */
70ed7d01 248 vector<AliHLTComponent*> fComponentList; // see above
fa760045 249 /** list of scheduled components */
70ed7d01 250 vector<AliHLTComponent*> fScheduleList; // see above
fa760045 251 /** list of libraries */
70ed7d01 252 vector<AliHLTLibHandle> fLibraryList; // see above
fa760045 253 /** running environment for the component */
70ed7d01 254 AliHLTComponentEnvironment fEnvironment; // see above
9ce4bf4a 255 /** list of standard components */
70ed7d01 256 vector<AliHLTComponent*> fStandardList; // see above
f23a6e1a 257
fa760045 258 ClassDef(AliHLTComponentHandler, 0);
fa2e9b7c 259
fa760045 260};
f23a6e1a 261#endif
262