]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTComponent.cxx
added code documentation for BASE, SampleLib, TPCLib and build system
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTComponent.cxx
1 // $Id$
2
3 /**************************************************************************
4  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5  *                                                                        *
6  * Authors: Matthias Richter <Matthias.Richter@ift.uib.no>                *
7  *          Timm Steinbeck <timm@kip.uni-heidelberg.de>                   *
8  *          for The ALICE Off-line Project.                               *
9  *                                                                        *
10  * Permission to use, copy, modify and distribute this software and its   *
11  * documentation strictly for non-commercial purposes is hereby granted   *
12  * without fee, provided that the above copyright notice appears in all   *
13  * copies and that both the copyright notice and this permission notice   *
14  * appear in the supporting documentation. The authors make no claims     *
15  * about the suitability of this software for any purpose. It is          *
16  * provided "as is" without express or implied warranty.                  *
17  **************************************************************************/
18
19 /** @file   AliHLTComponent.cxx
20     @author Matthias Richter, Timm Steinbeck
21     @date   
22     @brief  Base class implementation for HLT components. */
23
24 #if __GNUC__>= 3
25 using namespace std;
26 #endif
27
28 #include "AliHLTComponent.h"
29 #include "AliHLTComponentHandler.h"
30 #include <string>
31 #include "AliHLTSystem.h"
32
33 /** ROOT macro for the implementation of ROOT specific class methods */
34 ClassImp(AliHLTComponent)
35
36 AliHLTComponent::AliHLTComponent()
37
38   memset(&fEnvironment, 0, sizeof(AliHLTComponentEnvironment));
39   if (fpComponentHandler)
40     fpComponentHandler->ScheduleRegister(this);
41 }
42
43 AliHLTComponent::~AliHLTComponent()
44 {
45 }
46
47 AliHLTComponentHandler* AliHLTComponent::fpComponentHandler=NULL;
48
49 int AliHLTComponent::Init( AliHLTComponentEnvironment* environ, void* environ_param, int argc, const char** argv )
50 {
51   int iResult=0;
52   if (environ) {
53     memcpy(&fEnvironment, environ, sizeof(AliHLTComponentEnvironment));
54     fEnvironment.fParam=environ_param;
55   }
56   iResult=DoInit(argc, argv);
57   return iResult;
58 }
59
60 int AliHLTComponent::Deinit()
61 {
62   int iResult=0;
63   iResult=DoDeinit();
64   return iResult;
65 }
66
67 void AliHLTComponent::DataType2Text( const AliHLTComponent_DataType& type, char output[14] ) {
68 memset( output, 0, 14 );
69 strncat( output, type.fOrigin, 4 );
70 strcat( output, ":" );
71 strncat( output, type.fID, 8 );
72 }
73
74 int AliHLTComponent::MakeOutputDataBlockList( const vector<AliHLTComponent_BlockData>& blocks, AliHLTUInt32_t* blockCount,
75                                               AliHLTComponent_BlockData** outputBlocks ) {
76     if ( !blockCount || !outputBlocks )
77         return EFAULT;
78     AliHLTUInt32_t count = blocks.size();
79     if ( !count )
80         {
81         *blockCount = 0;
82         *outputBlocks = NULL;
83         return 0;
84         }
85     *outputBlocks = reinterpret_cast<AliHLTComponent_BlockData*>( AllocMemory( sizeof(AliHLTComponent_BlockData)*count ) );
86     if ( !*outputBlocks )
87         return ENOMEM;
88     for ( unsigned long i = 0; i < count; i++ )
89         (*outputBlocks)[i] = blocks[i];
90     *blockCount = count;
91     return 0;
92
93 }
94
95 int AliHLTComponent::FindMatchingDataTypes(AliHLTComponent* pConsumer, vector<AliHLTComponent_DataType>* tgtList) 
96 {
97   int iResult=0;
98   if (pConsumer) {
99     vector<AliHLTComponent_DataType> ctlist;
100     ((AliHLTComponent*)pConsumer)->GetInputDataTypes(ctlist);
101     vector<AliHLTComponent_DataType>::iterator type=ctlist.begin();
102     while (type!=ctlist.end() && iResult==0) {
103       if ((*type)==GetOutputDataType()) {
104         if (tgtList) tgtList->push_back(*type);
105         iResult++;
106         break;
107       }
108       type++;
109     }
110   } else {
111     iResult=-EINVAL;
112   }
113   return iResult;
114 }