3 #ifndef ALIHLTCOMPONENTHANDLER_H
4 #define ALIHLTCOMPONENTHANDLER_H
5 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
6 * See cxx source for full Copyright notice */
8 /** @file AliHLTComponentHandler.h
9 @author Matthias Richter, Timm Steinbeck
11 @brief Global handling of HLT processing components
12 @note The handler is part of the interface and both used in the
13 Online (PubSub) and Offline (AliRoot) context.
19 #include "AliHLTDataTypes.h"
20 #include "AliHLTLogging.h"
22 class AliHLTComponent;
23 struct AliHLTComponentEnvironment;
24 struct AliHLTComponentDataType;
26 typedef void* AliHLTLibHandle;
29 * @class AliHLTComponentHandler
30 * The component handler controls all the processing components available in
31 * the system. It also controls the component shared libraries.
32 * @ingroup alihlt_component
34 class AliHLTComponentHandler : public AliHLTLogging {
36 /** standard constructor */
37 AliHLTComponentHandler();
39 AliHLTComponentHandler(AliHLTComponentEnvironment* pEnv);
41 virtual ~AliHLTComponentHandler();
44 * Set the environment for the HLT framework.
45 * The environment mainly consists of function pointers for the integration
46 * of the HLT framework into a system like the PubSub online system or
47 * AliRoot offline system.
48 * @param pEnv pointer to @ref AliHLTComponentEnvironment structure
51 void SetEnvironment(AliHLTComponentEnvironment* pEnv);
54 * Load a component shared library.
55 * The component library needs to be loaded from the ComponentHanler in order
56 * to automatically register all components in the library.
57 * Registration is done by passing a sample object of the component to the
58 * handler. The object has to be valid during the whole runtime and should
59 * thus be a global object which is ONLY used for the purpose of registration.
60 * This also ensures automatically registration at library load time.
61 * @param libraryPath const char string containing the library name/path
62 * @return 0 if succeeded, neg. error code if failed
64 int LoadLibrary( const char* libraryPath );
67 * Unload a component shared library.
68 * All components will be de-registered.
69 * @param libraryPath library name as specified to @ref LoadLibrary
70 * @return 0 if succeeded, neg. error code if failed
72 int UnloadLibrary( const char* libraryPath );
75 * Schedule a component for registration.
76 * Full registration will be done after successfull loading of the shared
78 * @param pSample a sample object of the component
79 * @return neg. error code if failed
81 int ScheduleRegister(AliHLTComponent* pSample );
84 * Register a component.
85 * Registration is done by passing a sample object of the component to the
86 * handler. The object has to be valid during the whole runtime and should
87 * thus be a global object which is ONLY used for the purpose of registration.
88 * @param pSample a sample object of the component
89 * @return neg. error code if failed
91 int RegisterComponent(AliHLTComponent* pSample );
94 * Registers all scheduled components.
96 int RegisterScheduledComponents();
99 * Deregister a component.
100 * @param componentID ID of the component
101 * @return neg. error code if failed
103 int DeregisterComponent( const char* componentID );
106 * Add standard components
107 * The standard components are part of the libHLTbase library and
108 * need therefore a special handling.
110 int AddStandardComponents();
114 int DeleteStandardComponents();
117 * Find the ID of a component with the given output data.
118 * @param dtype data type descriptor
119 * @param prevType can be used to iterate if there are multiple components
120 * with the same output data type.
121 * @return component id
123 //const char* FindComponentType( AliHLTComponentDataType dtype,
124 // const char* prevType = NULL )
128 * Create a component of the given name (ID).
129 * The method tries to find a registerd component of id \em componentID and calls
130 * the \em Spawn method of the template component. After successful creation of
131 * a new object, the Init method is called in order to initialize the environment
132 * and the component arguments. <br>
133 * The environment is the same for all components, but each component can
134 * have an additional private parameter \em pEnvParam.<br>
135 * The component arguments consist of an array of strings and the array size in the
136 * usual manner of the main() function.
137 * @param componentID ID of the component to create
138 * @param pEnvParam environment parameter for the component
139 * @param argc number of arguments in argv
140 * @param argv argument array like in main()
141 * @param component reference to receive the create component instance
142 * @return component pointer in component, neg. error code if failed
144 int CreateComponent( const char* componentID, void* pEnvParam,
145 int argc, const char** argv, AliHLTComponent*& component );
148 * Create a component of the given name (ID).
149 * Introduced for backward compatibility.
150 * @param componentID ID of the component to create
151 * @param pEnvParam environment parameter for the component
152 * @param component reference to receive the create component instance
153 * @return component pointer in component, neg. error code if failed
155 int CreateComponent( const char* componentID, void* pEnvParam,
156 AliHLTComponent*& component )
158 return CreateComponent( componentID, pEnvParam, 0, NULL, component );
162 * Print registered components to stdout.
168 * Announce version and compilation info of the base library.
170 int AnnounceVersion();
177 * @param componentID ID of the component to find
178 * @return index, neg. error code if failed
180 int FindComponentIndex(const char* componentID);
184 * @param componentID ID of the component to find
187 AliHLTComponent* FindComponent(const char* componentID);
190 * Insert component to the list
191 * @param pSample sample object of the component
192 * @return neg. error code if failed
194 int InsertComponent(AliHLTComponent* pSample);
197 * Close all libraries.
198 * @return neg. error code if failed
200 int UnloadLibraries();
202 /** list of registered components */
203 vector<AliHLTComponent*> fComponentList;
204 /** list of scheduled components */
205 vector<AliHLTComponent*> fScheduleList;
206 /** list of libraries */
207 vector<AliHLTLibHandle> fLibraryList;
208 /** running environment for the component */
209 AliHLTComponentEnvironment fEnvironment;
210 /** list of standard components */
211 vector<AliHLTComponent*> fStandardList;
213 ClassDef(AliHLTComponentHandler, 0);