]>
Commit | Line | Data |
---|---|---|
d098ebd4 | 1 | // $Id$ |
2 | ||
3 | /************************************************************************** | |
9be2600f | 4 | * This file is property of and copyright by the ALICE HLT Project * |
5 | * ALICE Experiment at CERN, All rights reserved. * | |
d098ebd4 | 6 | * * |
9be2600f | 7 | * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> * |
8 | * Timm Steinbeck <timm@kip.uni-heidelberg.de> * | |
9 | * for The ALICE HLT Project. * | |
d098ebd4 | 10 | * * |
11 | * Permission to use, copy, modify and distribute this software and its * | |
12 | * documentation strictly for non-commercial purposes is hereby granted * | |
13 | * without fee, provided that the above copyright notice appears in all * | |
14 | * copies and that both the copyright notice and this permission notice * | |
15 | * appear in the supporting documentation. The authors make no claims * | |
16 | * about the suitability of this software for any purpose. It is * | |
17 | * provided "as is" without express or implied warranty. * | |
18 | **************************************************************************/ | |
19 | ||
02d01bbf | 20 | /** @file AliHLTExternalInterface.cxx |
d098ebd4 | 21 | @author Matthias Richter, Timm Steinbeck |
22 | @date | |
23 | @brief Pure C interface to the AliRoot HLT component handler | |
24 | */ | |
25 | ||
26 | #if __GNUC__>= 3 | |
27 | using namespace std; | |
28 | #endif | |
29 | ||
c043fa2c | 30 | #include "AliHLTExternalInterface.h" |
d098ebd4 | 31 | #include "AliHLTComponentHandler.h" |
32 | #include "AliHLTComponent.h" | |
c043fa2c | 33 | #include "AliHLTSystem.h" |
34 | #include <cerrno> | |
d098ebd4 | 35 | |
36 | static AliHLTComponentHandler *gComponentHandler_C = NULL; | |
37 | ||
38 | ||
39 | int AliHLT_C_Component_InitSystem( AliHLTComponentEnvironment* environ ) | |
40 | { | |
41 | if ( gComponentHandler_C ) | |
42 | { | |
43 | return EINPROGRESS; | |
44 | } | |
45 | gComponentHandler_C = new AliHLTComponentHandler(environ); | |
46 | if ( !gComponentHandler_C ) | |
47 | return EFAULT; | |
48 | gComponentHandler_C->InitAliLogTrap(gComponentHandler_C); | |
49 | gComponentHandler_C->AnnounceVersion(); | |
50 | return 0; | |
51 | } | |
52 | ||
53 | int AliHLT_C_Component_DeinitSystem() | |
54 | { | |
55 | if ( gComponentHandler_C ) | |
56 | { | |
57 | delete gComponentHandler_C; | |
58 | gComponentHandler_C = NULL; | |
59 | } | |
60 | return 0; | |
61 | } | |
62 | ||
63 | int AliHLT_C_Component_LoadLibrary( const char* libraryPath ) | |
64 | { | |
65 | if ( !gComponentHandler_C ) | |
66 | return ENXIO; | |
67 | return gComponentHandler_C->LoadLibrary( libraryPath ); | |
68 | } | |
69 | ||
70 | int AliHLT_C_Component_UnloadLibrary( const char* libraryPath ) | |
71 | { | |
72 | if ( !gComponentHandler_C ) | |
73 | return ENXIO; | |
74 | return gComponentHandler_C->UnloadLibrary( libraryPath ); | |
75 | } | |
76 | ||
77 | int AliHLT_C_CreateComponent( const char* componentType, void* environ_param, int argc, const char** argv, AliHLTComponentHandle* handle ) | |
78 | { | |
79 | if ( !gComponentHandler_C ) | |
80 | return ENXIO; | |
81 | AliHLTComponent* comp; | |
82 | int ret = gComponentHandler_C->CreateComponent( componentType, environ_param, argc, argv, comp ); | |
83 | *handle = reinterpret_cast<AliHLTComponentHandle>( comp ); | |
84 | return ret; | |
85 | } | |
86 | ||
87 | void AliHLT_C_DestroyComponent( AliHLTComponentHandle handle ) | |
88 | { | |
89 | if ( !handle ) | |
90 | return; | |
91 | ||
92 | AliHLTComponent* pComp=reinterpret_cast<AliHLTComponent*>( handle ); | |
93 | pComp->Deinit(); | |
94 | delete pComp; | |
95 | } | |
96 | ||
97 | int AliHLT_C_ProcessEvent( AliHLTComponentHandle handle, const AliHLTComponent_EventData* evtData, const AliHLTComponent_BlockData* blocks, | |
98 | AliHLTComponent_TriggerData* trigData, AliHLTUInt8_t* outputPtr, | |
99 | AliHLTUInt32_t* size, AliHLTUInt32_t* outputBlockCnt, | |
100 | AliHLTComponent_BlockData** outputBlocks, | |
101 | AliHLTComponent_EventDoneData** edd ) | |
102 | { | |
103 | if ( !handle ) | |
104 | return ENXIO; | |
105 | AliHLTComponent* comp = reinterpret_cast<AliHLTComponent*>( handle ); | |
106 | return comp->ProcessEvent( *evtData, blocks, *trigData, outputPtr, *size, *outputBlockCnt, *outputBlocks, *edd ); | |
107 | } | |
108 | ||
109 | int AliHLT_C_GetOutputDataType( AliHLTComponentHandle handle, AliHLTComponent_DataType* dataType ) | |
110 | { | |
111 | if ( !handle ) | |
112 | return ENXIO; | |
113 | AliHLTComponent* comp = reinterpret_cast<AliHLTComponent*>( handle ); | |
114 | *dataType = comp->GetOutputDataType(); | |
115 | return 0; | |
116 | } | |
117 | ||
118 | int AliHLT_C_GetOutputSize( AliHLTComponentHandle handle, unsigned long* constBase, double* inputMultiplier ) | |
119 | { | |
120 | if ( !handle ) | |
121 | return ENXIO; | |
122 | AliHLTComponent* comp = reinterpret_cast<AliHLTComponent*>( handle ); | |
123 | comp->GetOutputDataSize( *constBase, *inputMultiplier ); | |
124 | return 0; | |
125 | } | |
c043fa2c | 126 | |
127 | ||
128 | int AliHLTSystemSetOptions(AliHLTSystem* pInstance, const char* options) | |
129 | { | |
130 | int iResult=0; | |
131 | if (pInstance) { | |
132 | AliHLTSystem* pSystem=reinterpret_cast<AliHLTSystem*>(pInstance); | |
133 | if (pSystem) { | |
134 | iResult=pSystem->ScanOptions(options); | |
135 | } else { | |
136 | iResult=-EFAULT; | |
137 | } | |
138 | } else { | |
139 | iResult=-EINVAL; | |
140 | } | |
141 | return iResult; | |
142 | } | |
c5123824 | 143 | |
144 | int AliHLTSystemProcessHLTOUT(AliHLTSystem* pInstance, AliHLTOUT* pHLTOUT, AliESDEvent* esd) | |
145 | { | |
146 | int iResult=0; | |
147 | if (pInstance) { | |
148 | AliHLTSystem* pSystem=reinterpret_cast<AliHLTSystem*>(pInstance); | |
149 | if (pSystem) { | |
150 | iResult=pSystem->ProcessHLTOUT(pHLTOUT, esd); | |
151 | } else { | |
152 | iResult=-EFAULT; | |
153 | } | |
154 | } else { | |
155 | iResult=-EINVAL; | |
156 | } | |
157 | return iResult; | |
158 | } |