Copy constructor and assignment operator are added
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTComponent.cxx
CommitLineData
f23a6e1a 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> *
f23a6e1a 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
bfccbf68 19/** @file AliHLTComponent.cxx
20 @author Matthias Richter, Timm Steinbeck
21 @date
22 @brief Base class implementation for HLT components. */
f23a6e1a 23
0c0c9d99 24#if __GNUC__>= 3
f23a6e1a 25using namespace std;
26#endif
27
28#include "AliHLTComponent.h"
29#include "AliHLTComponentHandler.h"
a5854ddd 30#include <string>
f23a6e1a 31#include "AliHLTSystem.h"
32
b22e91eb 33/** ROOT macro for the implementation of ROOT specific class methods */
f23a6e1a 34ClassImp(AliHLTComponent)
35
f23a6e1a 36AliHLTComponent::AliHLTComponent()
37{
38 memset(&fEnvironment, 0, sizeof(AliHLTComponentEnvironment));
39 if (fpComponentHandler)
40 fpComponentHandler->ScheduleRegister(this);
41}
42
43AliHLTComponent::~AliHLTComponent()
44{
45}
46
b22e91eb 47AliHLTComponentHandler* AliHLTComponent::fpComponentHandler=NULL;
48
f23a6e1a 49int 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
60int AliHLTComponent::Deinit()
61{
62 int iResult=0;
63 iResult=DoDeinit();
64 return iResult;
65}
fa2e9b7c 66
67void AliHLTComponent::DataType2Text( const AliHLTComponent_DataType& type, char output[14] ) {
68memset( output, 0, 14 );
69strncat( output, type.fOrigin, 4 );
70strcat( output, ":" );
71strncat( output, type.fID, 8 );
72}
73
74int 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}
0c0c9d99 94
95int 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}