]>
Commit | Line | Data |
---|---|---|
6235cd38 | 1 | // $Id$ |
2 | ||
3 | /************************************************************************** | |
9be2600f | 4 | * This file is property of and copyright by the ALICE HLT Project * |
5 | * ALICE Experiment at CERN, All rights reserved. * | |
6235cd38 | 6 | * * |
9be2600f | 7 | * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> * |
8 | * for The ALICE HLT Project. * | |
6235cd38 | 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 AliHLTConsumerDescriptor.cxx | |
20 | @author Matthias Richter | |
21 | @date | |
22 | @brief Helper class to describe a consumer component. | |
23 | */ | |
24 | ||
25 | #if __GNUC__>= 3 | |
26 | using namespace std; | |
27 | #endif | |
28 | ||
29 | #include "AliHLTConsumerDescriptor.h" | |
30 | ||
31 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
32 | ClassImp(AliHLTConsumerDescriptor) | |
33 | ||
34 | AliHLTConsumerDescriptor::AliHLTConsumerDescriptor() | |
35 | : | |
36 | fpConsumer(NULL), | |
37 | fSegments() | |
38 | { | |
39 | // see header file for class documentation | |
40 | // or | |
41 | // refer to README to build package | |
42 | // or | |
43 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
44 | fSegments.clear(); | |
45 | } | |
46 | ||
47 | AliHLTConsumerDescriptor::AliHLTConsumerDescriptor(AliHLTComponent* pConsumer) | |
48 | : | |
49 | fpConsumer(pConsumer), | |
50 | fSegments() | |
51 | { | |
52 | // see header file for function documentation | |
53 | fSegments.clear(); | |
54 | } | |
55 | ||
56 | AliHLTConsumerDescriptor::AliHLTConsumerDescriptor(const AliHLTConsumerDescriptor& desc) | |
57 | : | |
58 | TObject(), | |
59 | AliHLTLogging(), | |
60 | fpConsumer(desc.fpConsumer), | |
61 | fSegments() | |
62 | { | |
63 | // see header file for function documentation | |
64 | ||
65 | // we can simply transfer the pointer to th new object since there are no | |
66 | // release actions in the destructor | |
67 | } | |
68 | ||
69 | AliHLTConsumerDescriptor& AliHLTConsumerDescriptor::operator=(const AliHLTConsumerDescriptor& desc) | |
70 | { | |
71 | // see header file for function documentation | |
72 | ||
73 | // we can simply transfer the pointer to th new object since there are no | |
74 | // release actions in the destructor | |
75 | fpConsumer=desc.fpConsumer; | |
76 | return *this; | |
77 | } | |
78 | ||
79 | AliHLTConsumerDescriptor::~AliHLTConsumerDescriptor() | |
80 | { | |
81 | // see header file for function documentation | |
82 | if (fSegments.size()>0) { | |
83 | //HLTWarning("unreleased data segments found"); | |
84 | } | |
85 | } | |
86 | ||
87 | int AliHLTConsumerDescriptor::SetActiveDataSegment(AliHLTUInt32_t offset, AliHLTUInt32_t size) | |
88 | { | |
89 | // see header file for function documentation | |
90 | int iResult=0; | |
91 | AliHLTDataBuffer::AliHLTDataSegment segment(offset, size); | |
92 | fSegments.push_back(segment); | |
93 | //HLTDebug("set active segment (%d:%d) for consumer %p", offset, size, this); | |
94 | return iResult; | |
95 | } | |
96 | ||
97 | int AliHLTConsumerDescriptor::CheckActiveDataSegment(AliHLTUInt32_t offset, AliHLTUInt32_t size) | |
98 | { | |
99 | // see header file for function documentation | |
100 | int iResult=0; | |
101 | if (fSegments.size()>0) { | |
102 | vector<AliHLTDataBuffer::AliHLTDataSegment>::iterator segment=fSegments.begin(); | |
103 | while (segment!=fSegments.end()) { | |
104 | if ((iResult=((*segment).fSegmentOffset==offset && (*segment).fSegmentSize==size))>0) { | |
105 | break; | |
106 | } | |
107 | segment++; | |
108 | } | |
109 | } else { | |
110 | //HLTWarning("no data segment active for consumer %p", this); | |
111 | iResult=-ENODATA; | |
112 | } | |
113 | return iResult; | |
114 | } | |
115 | ||
116 | int AliHLTConsumerDescriptor::ReleaseActiveDataSegment(AliHLTUInt32_t offset, AliHLTUInt32_t size) | |
117 | { | |
118 | // see header file for function documentation | |
119 | int iResult=0; | |
120 | if (fSegments.size()>0) { | |
121 | vector<AliHLTDataBuffer::AliHLTDataSegment>::iterator segment=fSegments.begin(); | |
122 | while (segment!=fSegments.end()) { | |
123 | if ((iResult=((*segment).fSegmentOffset==offset && (*segment).fSegmentSize==size))>0) { | |
124 | fSegments.erase(segment); | |
125 | break; | |
126 | } | |
127 | segment++; | |
128 | } | |
129 | if (iResult==0) { | |
130 | //HLTWarning("no data segment (%d:%d) active for consumer %p", offset, size, this); | |
131 | iResult=-ENOENT; | |
132 | } | |
133 | } else { | |
134 | //HLTWarning("no data segment active for consumer %p", this); | |
135 | iResult=-ENODATA; | |
136 | } | |
137 | return iResult; | |
138 | } |