]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx
bugfix AliHLTDataBuffer: correct handling of pointer and offset in block descriptor...
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLT_C_Component_WrapperInterface.cxx
1 // $Id$
2
3 /**************************************************************************
4  * This file is property of and copyright by the ALICE HLT Project        * 
5  * ALICE Experiment at CERN, All rights reserved.                         *
6  *                                                                        *
7  * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
8  *                  Timm Steinbeck <timm@kip.uni-heidelberg.de>           *
9  *                  for The ALICE HLT Project.                            *
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
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 */
25
26 #if __GNUC__>= 3
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
38 int AliHLT_C_Component_InitSystem( AliHLTComponentEnvironment* environ )
39 {
40   if ( gComponentHandler_C )
41     {
42       return EINPROGRESS;
43     }
44   gComponentHandler_C = new AliHLTComponentHandler(environ);
45   if ( !gComponentHandler_C )
46     return EFAULT;
47   gComponentHandler_C->InitAliLogTrap(gComponentHandler_C);
48   gComponentHandler_C->AnnounceVersion();
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
69 int AliHLT_C_Component_UnloadLibrary( const char* libraryPath )
70 {
71   if ( !gComponentHandler_C )
72     return ENXIO;
73   return gComponentHandler_C->UnloadLibrary( libraryPath );
74 }
75
76 int AliHLT_C_CreateComponent( const char* componentType, void* environ_param, int argc, const char** argv, AliHLTComponentHandle* handle )
77 {
78   if ( !gComponentHandler_C )
79     return ENXIO;
80   if ( !handle ) return EINVAL;
81   AliHLTComponent* comp;
82   int ret = gComponentHandler_C->CreateComponent( componentType, environ_param, argc, argv, comp );
83   *handle = reinterpret_cast<AliHLTComponentHandle>( comp );
84
85   return ret;
86 }
87
88 void AliHLT_C_DestroyComponent( AliHLTComponentHandle handle )
89 {
90   if ( !handle )
91     return;
92   
93   AliHLTComponent* pComp=reinterpret_cast<AliHLTComponent*>( handle );
94   pComp->Deinit();
95   delete pComp;
96 }
97
98 int AliHLT_C_ProcessEvent( AliHLTComponentHandle handle, const AliHLTComponent_EventData* evtData, const AliHLTComponent_BlockData* blocks, 
99                            AliHLTComponent_TriggerData* trigData, AliHLTUInt8_t* outputPtr,
100                            AliHLTUInt32_t* size, AliHLTUInt32_t* outputBlockCnt, 
101                            AliHLTComponent_BlockData** outputBlocks,
102                            AliHLTComponent_EventDoneData** edd )
103 {
104   if ( !handle )
105     return ENXIO;
106   AliHLTComponent* comp = reinterpret_cast<AliHLTComponent*>( handle );
107   return comp->ProcessEvent( *evtData, blocks, *trigData, outputPtr, *size, *outputBlockCnt, *outputBlocks, *edd );
108 }
109
110 int AliHLT_C_GetOutputDataType( AliHLTComponentHandle handle, AliHLTComponent_DataType* dataType )
111 {
112   if ( !handle )
113     return ENXIO;
114   AliHLTComponent* comp = reinterpret_cast<AliHLTComponent*>( handle );
115   *dataType = comp->GetOutputDataType();
116   return 0;
117 }
118
119 int AliHLT_C_GetOutputSize( AliHLTComponentHandle handle, unsigned long* constBase, double* inputMultiplier )
120 {
121   if ( !handle )
122     return ENXIO;
123   AliHLTComponent* comp = reinterpret_cast<AliHLTComponent*>( handle );
124   comp->GetOutputDataSize( *constBase, *inputMultiplier );
125   return 0;
126 }