]>
Commit | Line | Data |
---|---|---|
6235cd38 | 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 | * for The ALICE Off-line Project. * | |
8 | * * | |
9 | * Permission to use, copy, modify and distribute this software and its * | |
10 | * documentation strictly for non-commercial purposes is hereby granted * | |
11 | * without fee, provided that the above copyright notice appears in all * | |
12 | * copies and that both the copyright notice and this permission notice * | |
13 | * appear in the supporting documentation. The authors make no claims * | |
14 | * about the suitability of this software for any purpose. It is * | |
15 | * provided "as is" without express or implied warranty. * | |
16 | **************************************************************************/ | |
17 | ||
18 | /** @file AliHLTConsumerDescriptor.cxx | |
19 | @author Matthias Richter | |
20 | @date | |
21 | @brief Helper class to describe a consumer component. | |
22 | */ | |
23 | ||
24 | #if __GNUC__>= 3 | |
25 | using namespace std; | |
26 | #endif | |
27 | ||
28 | #include "AliHLTConsumerDescriptor.h" | |
29 | ||
30 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
31 | ClassImp(AliHLTConsumerDescriptor) | |
32 | ||
33 | AliHLTConsumerDescriptor::AliHLTConsumerDescriptor() | |
34 | : | |
35 | fpConsumer(NULL), | |
36 | fSegments() | |
37 | { | |
38 | // see header file for class documentation | |
39 | // or | |
40 | // refer to README to build package | |
41 | // or | |
42 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
43 | fSegments.clear(); | |
44 | } | |
45 | ||
46 | AliHLTConsumerDescriptor::AliHLTConsumerDescriptor(AliHLTComponent* pConsumer) | |
47 | : | |
48 | fpConsumer(pConsumer), | |
49 | fSegments() | |
50 | { | |
51 | // see header file for function documentation | |
52 | fSegments.clear(); | |
53 | } | |
54 | ||
55 | AliHLTConsumerDescriptor::AliHLTConsumerDescriptor(const AliHLTConsumerDescriptor& desc) | |
56 | : | |
57 | TObject(), | |
58 | AliHLTLogging(), | |
59 | fpConsumer(desc.fpConsumer), | |
60 | fSegments() | |
61 | { | |
62 | // see header file for function documentation | |
63 | ||
64 | // we can simply transfer the pointer to th new object since there are no | |
65 | // release actions in the destructor | |
66 | } | |
67 | ||
68 | AliHLTConsumerDescriptor& AliHLTConsumerDescriptor::operator=(const AliHLTConsumerDescriptor& desc) | |
69 | { | |
70 | // see header file for function documentation | |
71 | ||
72 | // we can simply transfer the pointer to th new object since there are no | |
73 | // release actions in the destructor | |
74 | fpConsumer=desc.fpConsumer; | |
75 | return *this; | |
76 | } | |
77 | ||
78 | AliHLTConsumerDescriptor::~AliHLTConsumerDescriptor() | |
79 | { | |
80 | // see header file for function documentation | |
81 | if (fSegments.size()>0) { | |
82 | //HLTWarning("unreleased data segments found"); | |
83 | } | |
84 | } | |
85 | ||
86 | int AliHLTConsumerDescriptor::SetActiveDataSegment(AliHLTUInt32_t offset, AliHLTUInt32_t size) | |
87 | { | |
88 | // see header file for function documentation | |
89 | int iResult=0; | |
90 | AliHLTDataBuffer::AliHLTDataSegment segment(offset, size); | |
91 | fSegments.push_back(segment); | |
92 | //HLTDebug("set active segment (%d:%d) for consumer %p", offset, size, this); | |
93 | return iResult; | |
94 | } | |
95 | ||
96 | int AliHLTConsumerDescriptor::CheckActiveDataSegment(AliHLTUInt32_t offset, AliHLTUInt32_t size) | |
97 | { | |
98 | // see header file for function documentation | |
99 | int iResult=0; | |
100 | if (fSegments.size()>0) { | |
101 | vector<AliHLTDataBuffer::AliHLTDataSegment>::iterator segment=fSegments.begin(); | |
102 | while (segment!=fSegments.end()) { | |
103 | if ((iResult=((*segment).fSegmentOffset==offset && (*segment).fSegmentSize==size))>0) { | |
104 | break; | |
105 | } | |
106 | segment++; | |
107 | } | |
108 | } else { | |
109 | //HLTWarning("no data segment active for consumer %p", this); | |
110 | iResult=-ENODATA; | |
111 | } | |
112 | return iResult; | |
113 | } | |
114 | ||
115 | int AliHLTConsumerDescriptor::ReleaseActiveDataSegment(AliHLTUInt32_t offset, AliHLTUInt32_t size) | |
116 | { | |
117 | // see header file for function documentation | |
118 | int iResult=0; | |
119 | if (fSegments.size()>0) { | |
120 | vector<AliHLTDataBuffer::AliHLTDataSegment>::iterator segment=fSegments.begin(); | |
121 | while (segment!=fSegments.end()) { | |
122 | if ((iResult=((*segment).fSegmentOffset==offset && (*segment).fSegmentSize==size))>0) { | |
123 | fSegments.erase(segment); | |
124 | break; | |
125 | } | |
126 | segment++; | |
127 | } | |
128 | if (iResult==0) { | |
129 | //HLTWarning("no data segment (%d:%d) active for consumer %p", offset, size, this); | |
130 | iResult=-ENOENT; | |
131 | } | |
132 | } else { | |
133 | //HLTWarning("no data segment active for consumer %p", this); | |
134 | iResult=-ENODATA; | |
135 | } | |
136 | return iResult; | |
137 | } |