3 /**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
7 * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 * Timm Steinbeck <timm@kip.uni-heidelberg.de> *
9 * for The ALICE HLT Project. *
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 **************************************************************************/
20 /** @file AliHLT_C_Component_WrapperInterface.cxx
21 @author Matthias Richter, Timm Steinbeck
23 @brief Pure C interface to the AliRoot HLT component handler
30 #include "AliHLT_C_Component_WrapperInterface.h"
31 #include "AliHLTComponentHandler.h"
32 #include "AliHLTComponent.h"
35 static AliHLTComponentHandler *gComponentHandler_C = NULL;
37 int AliHLT_C_Component_InitSystem( AliHLTComponentEnvironment* comenv )
39 if ( gComponentHandler_C )
43 gComponentHandler_C = new AliHLTComponentHandler(comenv);
44 if ( !gComponentHandler_C )
46 gComponentHandler_C->InitAliLogTrap(gComponentHandler_C);
47 gComponentHandler_C->AnnounceVersion();
51 int AliHLT_C_Component_DeinitSystem()
53 if ( gComponentHandler_C )
55 delete gComponentHandler_C;
56 gComponentHandler_C = NULL;
61 int AliHLT_C_Component_LoadLibrary( const char* libraryPath )
63 if ( !gComponentHandler_C )
65 return gComponentHandler_C->LoadLibrary( libraryPath );
68 int AliHLT_C_Component_UnloadLibrary( const char* /*libraryPath*/ )
70 if ( !gComponentHandler_C )
72 // Matthias 26.10.2007
73 // Unloading of libraries has to be re-worked. It has been commented out here
74 // since the libraries will be unloaded at the destruction of the component
75 // handler instance anyway. So it has no effect to the operation in PubSub.
76 // With the introduction of the dynamic component registration via module
77 // agents we run into trouble when cleaning up the samples managed by the
78 // component handler. Destruction of the sample objects is done AFTER
79 // unloading of the library and thus the destructor is not present any
81 //return gComponentHandler_C->UnloadLibrary( libraryPath );
85 int AliHLT_C_CreateComponent( const char* componentType, void* environParam, int argc, const char** argv, AliHLTComponentHandle* handle )
87 if ( !gComponentHandler_C )
89 if ( !handle ) return EINVAL;
90 AliHLTComponent* comp=NULL;
91 const char* cdbPath = getenv("ALIHLT_HCDBDIR");
92 if (!cdbPath) cdbPath = getenv("ALICE_ROOT");
93 int ret = gComponentHandler_C->CreateComponent( componentType, environParam, argc, argv, comp, cdbPath);
94 *handle = reinterpret_cast<AliHLTComponentHandle>( comp );
99 void AliHLT_C_DestroyComponent( AliHLTComponentHandle handle )
104 AliHLTComponent* pComp=reinterpret_cast<AliHLTComponent*>( handle );
109 int AliHLT_C_SetRunDescription(const AliHLTRunDesc* desc, const char* runType)
111 if (!desc) return -EINVAL;
112 if (desc->fStructSize<sizeof(AliHLTUInt32_t)) return -EINVAL;
113 if (!gComponentHandler_C) return ENXIO;
115 AliHLTRunDesc internalDesc=kAliHLTVoidRunDesc;
116 memcpy(&internalDesc, desc, desc->fStructSize<sizeof(internalDesc)?desc->fStructSize:sizeof(internalDesc));
117 return gComponentHandler_C->SetRunDescription(&internalDesc, runType);
120 int AliHLT_C_ProcessEvent( AliHLTComponentHandle handle, const AliHLTComponentEventData* evtData, const AliHLTComponentBlockData* blocks,
121 AliHLTComponentTriggerData* trigData, AliHLTUInt8_t* outputPtr,
122 AliHLTUInt32_t* size, AliHLTUInt32_t* outputBlockCnt,
123 AliHLTComponentBlockData** outputBlocks,
124 AliHLTComponentEventDoneData** edd )
128 AliHLTComponent* comp = reinterpret_cast<AliHLTComponent*>( handle );
129 return comp->ProcessEvent( *evtData, blocks, *trigData, outputPtr, *size, *outputBlockCnt, *outputBlocks, *edd );
132 int AliHLT_C_GetOutputDataType( AliHLTComponentHandle handle, AliHLTComponentDataType* dataType )
136 AliHLTComponent* comp = reinterpret_cast<AliHLTComponent*>( handle );
137 *dataType = comp->GetOutputDataType();
141 int AliHLT_C_GetOutputSize( AliHLTComponentHandle handle, unsigned long* constBase, double* inputMultiplier )
145 AliHLTComponent* comp = reinterpret_cast<AliHLTComponent*>( handle );
146 comp->GetOutputDataSize( *constBase, *inputMultiplier );