]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/BASE/AliHLTComponentHandler.h
Adding the AliRunTagCuts class in the repository.
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTComponentHandler.h
CommitLineData
f23a6e1a 1// @(#) $Id$
2
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 */
7
b22e91eb 8/** @file AliHLTComponentHandler.h
9 @author Matthias Richter, Timm Steinbeck
10 @date
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.
14 */
15
f23a6e1a 16
17#include "TObject.h"
18#include "AliHLTDataTypes.h"
5ec8e281 19#include "AliHLTLogging.h"
f23a6e1a 20
21class AliHLTComponent;
22struct AliHLTComponentEnvironment;
23struct AliHLTComponent_DataType;
24
25typedef void* AliHLTLibHandle;
26
fa760045 27/**
28 * @class AliHLTComponentHandler
29 * The component handler controls all the processing components available in
30 * the system. It also controls the component shared libraries.
31 * @ingroup alihlt_component
32 */
5ec8e281 33class AliHLTComponentHandler : public AliHLTLogging {
f23a6e1a 34 public:
fa760045 35 /** standard constructor */
f23a6e1a 36 AliHLTComponentHandler();
fa760045 37 /** destructor */
f23a6e1a 38 virtual ~AliHLTComponentHandler();
39
fa760045 40 /**
41 * Set the environment for the HLT framework.
42 * The environment mainly consists of function pointers for the integration
43 * of the HLT framework into a system like the PubSub online system or
44 * AliRoot offline system.
45 * @param pEnv pointer to @ref AliHLTComponentEnvironment structure
46 * @return none
47 */
f23a6e1a 48 void SetEnvironment(AliHLTComponentEnvironment* pEnv);
49
fa760045 50 /**
51 * Load a component shared library.
52 * The component library needs to be loaded from the ComponentHanler in order
53 * to automatically register all components in the library.
54 * Registration is done by passing a sample object of the component to the
55 * handler. The object has to be valid during the whole runtime and should
56 * thus be a global object which is ONLY used for the purpose of registration.
57 * This also ensures automatically registration at library load time.
58 * @param libraryPath const char string containing the library name/path
59 * @return 0 if succeeded, neg. error code if failed
60 */
f23a6e1a 61 int LoadLibrary( const char* libraryPath );
fa760045 62
63 /**
64 * Unload a component shared library.
65 * All components will be de-registered.
66 * @param libraryPath library name as specified to @ref LoadLibrary
67 * @return 0 if succeeded, neg. error code if failed
68 */
f23a6e1a 69 int UnloadLibrary( const char* libraryPath );
70
fa760045 71 /**
72 * Schedule a component for registration.
73 * Full registration will be done after successfull loading of the shared
74 * library.
75 * @param pSample a sample object of the component
76 * @return neg. error code if failed
f23a6e1a 77 */
f23a6e1a 78 int ScheduleRegister(AliHLTComponent* pSample );
79
fa760045 80 /**
81 * Register a component.
82 * Registration is done by passing a sample object of the component to the
83 * handler. The object has to be valid during the whole runtime and should
84 * thus be a global object which is ONLY used for the purpose of registration.
85 * @param pSample a sample object of the component
86 * @return neg. error code if failed
87 */
f23a6e1a 88 int RegisterComponent(AliHLTComponent* pSample );
f23a6e1a 89
fa760045 90 /**
91 * Deregister a component.
92 * @param componentID ID of the component
93 * @return neg. error code if failed
94 */
95 int DeregisterComponent( const char* componentID );
f23a6e1a 96
fa760045 97 /**
98 * Find the ID of a component with the given output data.
99 * @param dtype data type descriptor
100 * @param prevType can be used to iterate if there are multiple components
101 * with the same output data type.
102 * @return component id
103 */
104 //const char* FindComponentType( AliHLTComponent_DataType dtype,
105 // const char* prevType = NULL )
106 // { return NULL;}
107
108 /**
109 * Create a component of the given name (ID).
110 * @param componentID ID of the component to create
111 * @param pEnv environment for the component
112 * @param argc number of arguments in @ref argv
113 * @param argv argument array like in main()
114 * @param component reference to receive the create component instance
115 * @return component pointer in @ref component, neg. error code if failed
116 */
117 int CreateComponent( const char* componentID, void* pEnv,
118 int argc, const char** argv, AliHLTComponent*& component );
119
120 /**
121 * Create a component of the given name (ID).
122 * Introduced for backward compatibility.
123 * @param componentID ID of the component to create
124 * @param pEnv environment for the component
125 * @param component reference to receive the create component instance
126 * @return component pointer in @ref component, neg. error code if failed
127 */
128 int CreateComponent( const char* componentID, void* pEnv,
129 AliHLTComponent*& component )
130 {
131 return CreateComponent( componentID, pEnv, 0, NULL, component );
132 }
133
134 /**
135 * Print registered components to stdout.
136 * @return none
f23a6e1a 137 */
138 void List();
fa760045 139
140 /**
141 * Announce version and compilation info of the base library.
142 */
143 int AnnounceVersion();
144
f23a6e1a 145 protected:
f23a6e1a 146
147 private:
fa760045 148 /**
149 * Find a component.
150 * @param componentID ID of the component to find
151 * @return index, neg. error code if failed
152 */
f23a6e1a 153 int FindComponentIndex(const char* componentID);
154
fa760045 155 /**
156 * Find a component.
157 * @param componentID ID of the component to find
158 * @return descriptor
159 */
f23a6e1a 160 AliHLTComponent* FindComponent(const char* componentID);
161
fa760045 162 /**
163 * Insert component to the list
164 * @param pSample sample object of the component
165 * @return neg. error code if failed
166 */
f23a6e1a 167 int InsertComponent(AliHLTComponent* pSample);
168
fa760045 169 /**
170 * Close all libraries.
171 * @return neg. error code if failed
172 */
f23a6e1a 173 int UnloadLibraries();
174
fa760045 175 /** list of registered components */
f23a6e1a 176 vector<AliHLTComponent*> fComponentList;
fa760045 177 /** list of scheduled components */
f23a6e1a 178 vector<AliHLTComponent*> fScheduleList;
fa760045 179 /** list of libraries */
f23a6e1a 180 vector<AliHLTLibHandle> fLibraryList;
fa760045 181 /** running environment for the component */
f23a6e1a 182 AliHLTComponentEnvironment fEnvironment;
183
fa760045 184 ClassDef(AliHLTComponentHandler, 0);
fa2e9b7c 185
fa760045 186};
f23a6e1a 187#endif
188