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;
38 int AliHLT_C_Component_InitSystem( AliHLTComponentEnvironment* comenv )
40 if ( gComponentHandler_C )
44 gComponentHandler_C = new AliHLTComponentHandler(comenv);
45 if ( !gComponentHandler_C )
47 gComponentHandler_C->InitAliLogTrap(gComponentHandler_C);
48 gComponentHandler_C->AnnounceVersion();
52 int AliHLT_C_Component_DeinitSystem()
54 if ( gComponentHandler_C )
56 delete gComponentHandler_C;
57 gComponentHandler_C = NULL;
62 int AliHLT_C_Component_LoadLibrary( const char* libraryPath )
64 if ( !gComponentHandler_C )
66 return gComponentHandler_C->LoadLibrary( libraryPath );
69 int AliHLT_C_Component_UnloadLibrary( const char* /*libraryPath*/ )
71 if ( !gComponentHandler_C )
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
82 //return gComponentHandler_C->UnloadLibrary( libraryPath );
86 int AliHLT_C_CreateComponent( const char* componentType, void* environParam, int argc, const char** argv, AliHLTComponentHandle* handle )
88 if ( !gComponentHandler_C )
90 if ( !handle ) return EINVAL;
91 AliHLTComponent* comp=NULL;
92 const char* cdbPath = getenv("ALIHLT_HCDBDIR");
93 if (!cdbPath) cdbPath = getenv("ALICE_ROOT");
94 int ret = gComponentHandler_C->CreateComponent( componentType, environParam, argc, argv, comp, cdbPath);
95 *handle = reinterpret_cast<AliHLTComponentHandle>( comp );
100 void AliHLT_C_DestroyComponent( AliHLTComponentHandle handle )
105 AliHLTComponent* pComp=reinterpret_cast<AliHLTComponent*>( handle );
110 int AliHLT_C_ProcessEvent( AliHLTComponentHandle handle, const AliHLTComponentEventData* evtData, const AliHLTComponentBlockData* blocks,
111 AliHLTComponentTriggerData* trigData, AliHLTUInt8_t* outputPtr,
112 AliHLTUInt32_t* size, AliHLTUInt32_t* outputBlockCnt,
113 AliHLTComponentBlockData** outputBlocks,
114 AliHLTComponentEventDoneData** edd )
118 AliHLTComponent* comp = reinterpret_cast<AliHLTComponent*>( handle );
119 return comp->ProcessEvent( *evtData, blocks, *trigData, outputPtr, *size, *outputBlockCnt, *outputBlocks, *edd );
122 int AliHLT_C_GetOutputDataType( AliHLTComponentHandle handle, AliHLTComponentDataType* dataType )
126 AliHLTComponent* comp = reinterpret_cast<AliHLTComponent*>( handle );
127 *dataType = comp->GetOutputDataType();
131 int AliHLT_C_GetOutputSize( AliHLTComponentHandle handle, unsigned long* constBase, double* inputMultiplier )
135 AliHLTComponent* comp = reinterpret_cast<AliHLTComponent*>( handle );
136 comp->GetOutputDataSize( *constBase, *inputMultiplier );