]>
Commit | Line | Data |
---|---|---|
f23a6e1a | 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. * | |
f23a6e1a | 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. * | |
f23a6e1a | 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 | ||
b22e91eb | 20 | /** @file AliHLT_C_Component_WrapperInterface.cxx |
21 | @author Matthias Richter, Timm Steinbeck | |
22 | @date | |
23 | @brief Pure C interface to the AliRoot HLT component handler | |
24 | */ | |
f23a6e1a | 25 | |
0c0c9d99 | 26 | #if __GNUC__>= 3 |
f23a6e1a | 27 | using namespace std; |
28 | #endif | |
29 | ||
30 | #include "AliHLT_C_Component_WrapperInterface.h" | |
31 | #include "AliHLTComponentHandler.h" | |
32 | #include "AliHLTComponent.h" | |
33 | #include <errno.h> | |
34 | ||
35 | static AliHLTComponentHandler *gComponentHandler_C = NULL; | |
36 | ||
37 | ||
f7561f8d | 38 | int AliHLT_C_Component_InitSystem( AliHLTComponentEnvironment* comenv ) |
f23a6e1a | 39 | { |
40 | if ( gComponentHandler_C ) | |
41 | { | |
42 | return EINPROGRESS; | |
43 | } | |
f7561f8d | 44 | gComponentHandler_C = new AliHLTComponentHandler(comenv); |
f23a6e1a | 45 | if ( !gComponentHandler_C ) |
46 | return EFAULT; | |
a742f6f8 | 47 | gComponentHandler_C->InitAliLogTrap(gComponentHandler_C); |
fa760045 | 48 | gComponentHandler_C->AnnounceVersion(); |
f23a6e1a | 49 | return 0; |
50 | } | |
51 | ||
52 | int AliHLT_C_Component_DeinitSystem() | |
53 | { | |
54 | if ( gComponentHandler_C ) | |
55 | { | |
56 | delete gComponentHandler_C; | |
57 | gComponentHandler_C = NULL; | |
58 | } | |
59 | return 0; | |
60 | } | |
61 | ||
62 | int AliHLT_C_Component_LoadLibrary( const char* libraryPath ) | |
63 | { | |
64 | if ( !gComponentHandler_C ) | |
65 | return ENXIO; | |
66 | return gComponentHandler_C->LoadLibrary( libraryPath ); | |
67 | } | |
68 | ||
d76bc02a | 69 | int AliHLT_C_Component_UnloadLibrary( const char* /*libraryPath*/ ) |
f23a6e1a | 70 | { |
71 | if ( !gComponentHandler_C ) | |
72 | return ENXIO; | |
cbd84228 | 73 | // Matthias 26.10.2007 |
74 | // Unloading of libraries has to be re-worked. It has been commented out here | |
75 | // since the libraries will be unloaded at the destruction of the component | |
76 | // handler instance anyway. So it has no effect to the operation in PubSub. | |
77 | // With the introduction of the dynamic component registration via module | |
78 | // agents we run into trouble when cleaning up the samples managed by the | |
79 | // component handler. Destruction of the sample objects is done AFTER | |
80 | // unloading of the library and thus the destructor is not present any | |
81 | // more. | |
82 | //return gComponentHandler_C->UnloadLibrary( libraryPath ); | |
83 | return 0; | |
f23a6e1a | 84 | } |
85 | ||
f7561f8d | 86 | int AliHLT_C_CreateComponent( const char* componentType, void* environParam, int argc, const char** argv, AliHLTComponentHandle* handle ) |
f23a6e1a | 87 | { |
88 | if ( !gComponentHandler_C ) | |
89 | return ENXIO; | |
3294f81a | 90 | if ( !handle ) return EINVAL; |
b2065764 | 91 | AliHLTComponent* comp=NULL; |
92 | const char* cdbPath = getenv("ALIHLT_HCDBDIR"); | |
93 | if (!cdbPath) cdbPath = getenv("ALICE_ROOT"); | |
f7561f8d | 94 | int ret = gComponentHandler_C->CreateComponent( componentType, environParam, argc, argv, comp, cdbPath); |
f23a6e1a | 95 | *handle = reinterpret_cast<AliHLTComponentHandle>( comp ); |
3294f81a | 96 | |
f23a6e1a | 97 | return ret; |
98 | } | |
99 | ||
100 | void AliHLT_C_DestroyComponent( AliHLTComponentHandle handle ) | |
101 | { | |
102 | if ( !handle ) | |
103 | return; | |
3cde846d | 104 | |
105 | AliHLTComponent* pComp=reinterpret_cast<AliHLTComponent*>( handle ); | |
106 | pComp->Deinit(); | |
107 | delete pComp; | |
f23a6e1a | 108 | } |
109 | ||
f7561f8d | 110 | int AliHLT_C_ProcessEvent( AliHLTComponentHandle handle, const AliHLTComponentEventData* evtData, const AliHLTComponentBlockData* blocks, |
111 | AliHLTComponentTriggerData* trigData, AliHLTUInt8_t* outputPtr, | |
f23a6e1a | 112 | AliHLTUInt32_t* size, AliHLTUInt32_t* outputBlockCnt, |
f7561f8d | 113 | AliHLTComponentBlockData** outputBlocks, |
114 | AliHLTComponentEventDoneData** edd ) | |
f23a6e1a | 115 | { |
116 | if ( !handle ) | |
117 | return ENXIO; | |
118 | AliHLTComponent* comp = reinterpret_cast<AliHLTComponent*>( handle ); | |
71d7c760 | 119 | return comp->ProcessEvent( *evtData, blocks, *trigData, outputPtr, *size, *outputBlockCnt, *outputBlocks, *edd ); |
120 | } | |
121 | ||
f7561f8d | 122 | int AliHLT_C_GetOutputDataType( AliHLTComponentHandle handle, AliHLTComponentDataType* dataType ) |
71d7c760 | 123 | { |
124 | if ( !handle ) | |
125 | return ENXIO; | |
126 | AliHLTComponent* comp = reinterpret_cast<AliHLTComponent*>( handle ); | |
127 | *dataType = comp->GetOutputDataType(); | |
128 | return 0; | |
129 | } | |
130 | ||
131 | int AliHLT_C_GetOutputSize( AliHLTComponentHandle handle, unsigned long* constBase, double* inputMultiplier ) | |
132 | { | |
133 | if ( !handle ) | |
134 | return ENXIO; | |
135 | AliHLTComponent* comp = reinterpret_cast<AliHLTComponent*>( handle ); | |
136 | comp->GetOutputDataSize( *constBase, *inputMultiplier ); | |
137 | return 0; | |
f23a6e1a | 138 | } |