]>
Commit | Line | Data |
---|---|---|
a3c9b745 | 1 | // $Id$ |
d098ebd4 | 2 | |
3 | #ifndef ALIHLT_EXTERNALINTERFACE_H | |
4 | #define ALIHLT_EXTERNALINTERFACE_H | |
a3c9b745 | 5 | //* This file is property of and copyright by the ALICE HLT Project * |
6 | //* ALICE Experiment at CERN, All rights reserved. * | |
7 | //* See cxx source for full Copyright notice * | |
d098ebd4 | 8 | |
02d01bbf | 9 | /** @file AliHLTExternalInterface.h |
d098ebd4 | 10 | @author Matthias Richter, Timm Steinbeck |
11 | @date | |
a3c9b745 | 12 | @brief Pure and dynamic C interface to the AliRoot HLT analysis |
d098ebd4 | 13 | @note Utilized by the HLT Online (PubSub) framework |
14 | */ | |
15 | ||
a3c9b745 | 16 | /** |
17 | * @defgroup alihlt_wrapper_interface The HLT wrapper interface | |
18 | * The wrapper interface is a pure C interface which allows to use the | |
19 | * analysis components in external applications. The interface is utilized | |
20 | * to bind the analysis code to the PubSub framework. | |
21 | * | |
22 | * \image html PubSub_WrapperComponent.png "Wrapper interface" | |
23 | * | |
24 | * @section alihlt_wrapper_interface_general Interface functions | |
25 | * The interface is based on function signatures. The function | |
26 | * AliHLTAnalysisGetInterfaceCall(const char* signature) of type | |
27 | * AliHLTAnalysisFctGetInterfaceCall looks for a matching interface | |
28 | * function and returns the pointer if it is found. | |
29 | * @ref ALIHLTANALYSIS_FCT_GETINTERFACECALL defines the function name. | |
30 | * | |
31 | * @section alihlt_wrapper_interface_usage Usage | |
32 | * @subsection alihlt_wrapper_interface_usage_systemcalls Getting the interface functions | |
33 | * <pre> | |
34 | * string libraryPath=ALIHLTANALYSIS_INTERFACE_LIBRARY; | |
35 | * | |
36 | * string libraryPath=gBasePath; | |
37 | * libraryPath+="/"; | |
38 | * libraryPath+=ALIHLTANALYSIS_INTERFACE_LIBRARY; | |
39 | * | |
40 | * void* libHandle=dlopen(libraryPath.c_str(), RTLD_NOW); | |
41 | * if (!libHandle) { | |
42 | * cerr << "error: can not load library " << libraryPath.c_str() << endl; | |
43 | * return -1; | |
44 | * } | |
45 | * | |
46 | * AliHLTAnalysisFctGetInterfaceCall fctGetSystemCall=(AliHLTAnalysisFctGetInterfaceCall)dlsym(libHandle, ALIHLTANALYSIS_FCT_GETINTERFACECALL); | |
47 | * if (!fctGetSystemCall) { | |
48 | * cerr << "error: can not find function '" << ALIHLTANALYSIS_FCT_GETINTERFACECALL << "' in " << libraryPath.c_str() << endl; | |
49 | * return -1; | |
50 | * } | |
51 | * | |
52 | * </pre> | |
53 | * | |
54 | * @subsection alihlt_wrapper_interface_usage_init System initialization | |
55 | * <pre> | |
56 | * AliHLTAnalysisEnvironment environment; | |
57 | * memset(&environment, 0, sizeof(environment)); | |
58 | * | |
59 | * // setting function pointers | |
60 | * environment.fStructSize=sizeof(environment); | |
61 | * environment.fAllocMemoryFunc=AllocMemory; | |
62 | * environment.fLoggingFunc=Logging; | |
63 | * | |
64 | * AliHLTExtFctInitSystem fctInitSystem=(AliHLTExtFctInitSystem)fctGetSystemCall("int AliHLTAnalysisInitSystem(unsigned long,AliHLTAnalysisEnvironment*,unsigned long,const char*)"); | |
65 | * if (!fctInitSystem) { | |
66 | * cerr << "error: missing AliHLTAnalysisInitSystem call" << endl; | |
67 | * return -1; | |
68 | * } | |
69 | * | |
70 | * if ((iResult=fctInitSystem( ALIHLT_DATA_TYPES_VERSION, &environment, 0xbeef, "dummy-run" ))<0) { | |
71 | * cerr << "InitSystem failed with " << iResult << endl; | |
72 | * return iResult; | |
73 | * } | |
74 | * | |
75 | * </pre> | |
76 | * | |
77 | * @subsection alihlt_wrapper_interface_usage_create Load library and create component | |
78 | * <pre> | |
79 | * AliHLTExtFctLoadLibrary fctLoadLibrary=(AliHLTExtFctLoadLibrary)fctGetSystemCall("int AliHLTAnalysisLoadLibrary(const char*)"); | |
80 | * if (!fctLoadLibrary) { | |
81 | * cerr << "error: missing LoadLibrary call" << endl; | |
82 | * return -1; | |
83 | * } | |
84 | * | |
85 | * if ((iResult=fctLoadLibrary(moduleLibrary))<0) { | |
86 | * cerr << "error: AliHLTAnalysisLoadLibrary failed with " << iResult << endl; | |
87 | * return iResult; | |
88 | * } | |
89 | * | |
90 | * AliHLTExtFctCreateComponent fctCreateComponent=(AliHLTExtFctCreateComponent)fctGetSystemCall("int AliHLTAnalysisCreateComponent(const char*,void*,int,const char**,AliHLTComponentHandle*,const char*)"); | |
91 | * if (!fctCreateComponent) { | |
92 | * cerr << "error: missing CreateComponent call" << endl; | |
93 | * return -1; | |
94 | * } | |
95 | * | |
96 | * AliHLTComponentHandle handle; | |
97 | * if ((iResult=fctCreateComponent("TestProcessor", &gDummy, 0, NULL, &handle, "-chainid=test" ))<0) { | |
98 | * cerr << "error: AliHLTAnalysisCreateComponent failed with " << iResult << endl; | |
99 | * return iResult; | |
100 | * } | |
101 | * | |
102 | * </pre> | |
c043fa2c | 103 | * |
a3c9b745 | 104 | * @section alihlt_wrapper_interface_cdb CDB handling |
105 | * The interface initializes the CDB from the path found | |
106 | * in the environment variable ALIHLT_HCDBDIR. If this is empty, path is | |
107 | * set from <tt>$ALICE_ROOT</tt>. | |
c043fa2c | 108 | */ |
d098ebd4 | 109 | |
a3c9b745 | 110 | #include <AliHLTDataTypes.h> |
d098ebd4 | 111 | |
a3c9b745 | 112 | ///////////////////////////////////////////////////////////////////////////////////// |
113 | // | |
114 | // AliHLT external interface functions | |
115 | // | |
d098ebd4 | 116 | |
a3c9b745 | 117 | #ifdef __cplusplus |
118 | extern "C" { | |
119 | #endif | |
d098ebd4 | 120 | |
a3c9b745 | 121 | /** |
122 | * Get a system call of the interface. | |
123 | * @param function signature | |
124 | * @return pointer to system call | |
125 | * @ingroup alihlt_wrapper_interface | |
126 | */ | |
127 | void* AliHLTAnalysisGetInterfaceCall(const char*); | |
d098ebd4 | 128 | |
a3c9b745 | 129 | #ifdef __cplusplus |
130 | } | |
131 | #endif | |
d098ebd4 | 132 | |
d098ebd4 | 133 | |
a3c9b745 | 134 | ///////////////////////////////////////////////////////////////////////////////////// |
135 | // | |
136 | // AliHLTSystem interface functions | |
137 | // | |
d098ebd4 | 138 | |
a3c9b745 | 139 | class AliHLTSystem; |
140 | class AliHLTOUT; | |
141 | class AliESDEvent; | |
d098ebd4 | 142 | |
a3c9b745 | 143 | #ifdef __cplusplus |
144 | extern "C" { | |
145 | #endif | |
d098ebd4 | 146 | |
c043fa2c | 147 | /** |
148 | * Set options for an AliHLTSystem instance. | |
149 | * The function is introduced for the sake of backward compatibility. | |
150 | * Called from AliHLTReconstructor, which loads the function dynamically. | |
151 | * @return neg. error code if failed <br> | |
152 | * -EFAULT type cast failed <br> | |
153 | * -EINVAL invalid parameter | |
154 | * @ingroup alihlt_system_interface | |
155 | */ | |
156 | int AliHLTSystemSetOptions(AliHLTSystem*, const char*); | |
157 | ||
c5123824 | 158 | /** |
159 | * Process the HLTOUT data with the specified system instance. | |
160 | * The function is introduced for the sake of backward compatibility. | |
161 | * Called from AliHLTReconstructor, which loads the function dynamically. | |
162 | * @return neg. error code if failed <br> | |
163 | * -EFAULT type cast failed <br> | |
164 | * -EINVAL invalid parameter | |
165 | * @ingroup alihlt_system_interface | |
166 | */ | |
167 | int AliHLTSystemProcessHLTOUT(AliHLTSystem* pInstance, AliHLTOUT* pHLTOUT, AliESDEvent* esd); | |
168 | ||
d098ebd4 | 169 | #ifdef __cplusplus |
170 | } | |
171 | #endif | |
172 | ||
173 | #endif //ALIHLT_EXTERNALINTERFACE_H |