further work on HLTOUT treatment
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTOUT.cxx
CommitLineData
62bb3cd4 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 * for The ALICE HLT 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 AliHLTOUT.cxx
20 @author Matthias Richter
21 @date
22 @brief The control class for HLTOUT data. */
23
4de7334f 24// see header file for class documentation
25// or
26// refer to README to build package
27// or
28// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
62bb3cd4 29
4de7334f 30#include <cerrno>
62bb3cd4 31#include "AliHLTOUT.h"
32
33/** ROOT macro for the implementation of ROOT specific class methods */
34ClassImp(AliHLTOUT)
35
36AliHLTOUT::AliHLTOUT()
4de7334f 37 :
38 fSearchDataType(kAliHLTVoidDataType),
39 fSearchSpecification(kAliHLTVoidDataSpec),
049b43b2 40 fFlags(0),
4de7334f 41 fBlockDescList(),
42 fCurrent(fBlockDescList.begin()),
43 fpBuffer(NULL)
44{
62bb3cd4 45 // see header file for class documentation
46 // or
47 // refer to README to build package
48 // or
49 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
50}
51
52AliHLTOUT::~AliHLTOUT()
4de7334f 53{
54 // see header file for class documentation
55}
56
57int AliHLTOUT::GetNofDataBlocks()
58{
59 // see header file for class documentation
60 return fBlockDescList.size();
61}
62
63int AliHLTOUT::SelectFirstDataBlock(AliHLTComponentDataType dt, AliHLTUInt32_t spec)
64{
65 // see header file for class documentation
049b43b2 66 if (CheckStatusFlag(kLocked)) return -EPERM;
4de7334f 67 fCurrent=fBlockDescList.begin();
68 fSearchDataType=dt;
69 fSearchSpecification=spec;
049b43b2 70 return FindAndSelectDataBlock();
4de7334f 71}
72
73int AliHLTOUT::SelectNextDataBlock()
74{
75 // see header file for class documentation
049b43b2 76 if (CheckStatusFlag(kLocked)) return -EPERM;
77 fCurrent++;
78 return FindAndSelectDataBlock();
79}
80
81int AliHLTOUT::FindAndSelectDataBlock()
82{
83 // see header file for class documentation
84 if (CheckStatusFlag(kLocked)) return -EPERM;
4de7334f 85 int iResult=-ENOENT;
86 while (fCurrent!=fBlockDescList.end() && iResult==-ENOENT) {
87 if ((fSearchDataType==kAliHLTAnyDataType || (*fCurrent)==fSearchDataType) &&
88 fSearchSpecification==kAliHLTVoidDataSpec || (*fCurrent)==fSearchSpecification) {
89 iResult=0;
049b43b2 90 // TODO: check the byte order on the current system and the byte order of the
91 // data block, print warning when missmatch and user did not check
92 AliHLTOUTByteOrder_t blockBO=CheckByteOrder();
93 /*
94 if (blockBO!=fByteOrder) {
95 SetStatusFlag(kByteOrderWarning);
96
97 }
98 */
99 ClearStatusFlag(kByteOrderChecked);
100
101 // TODO: check the alignment on the current system and the alignment of the
102 // data block, print warning when missmatch and user did not check
103 ClearStatusFlag(kAlignmentChecked);
4de7334f 104 }
049b43b2 105 fCurrent++;
4de7334f 106 }
107 return iResult;
108}
109
110int AliHLTOUT::GetDataBlockDescription(AliHLTComponentDataType& dt, AliHLTUInt32_t& spec)
111{
112 // see header file for class documentation
113 int iResult=-ENOENT;
114 if (fCurrent!=fBlockDescList.end()) {
115 iResult=0;
116 dt=(*fCurrent);
117 spec=(*fCurrent);
118 }
119 return iResult;
120}
121
122int AliHLTOUT::GetDataBuffer(const AliHLTUInt8_t* &pBuffer, AliHLTUInt32_t& size)
123{
124 // see header file for class documentation
125 int iResult=-ENOENT;
126 pBuffer=NULL;
127 size=0;
128 if (fCurrent!=fBlockDescList.end()) {
129 if ((iResult=GetDataBuffer((*fCurrent).GetIndex(), pBuffer, size))>=0) {
130 fpBuffer=pBuffer;
131 }
132 }
133 return iResult;
134}
135
136int AliHLTOUT::ReleaseDataBuffer(const AliHLTUInt8_t* pBuffer)
137{
138 // see header file for class documentation
139 int iResult=0;
140 if (pBuffer==fpBuffer) {
141 fpBuffer=NULL;
142 } else {
143 HLTWarning("buffer %p does not match the provided one %p", pBuffer, fpBuffer);
144 }
145 return iResult;
146}
147
148int AliHLTOUT::AddBlockDescriptor(const AliHLTOUTBlockDescriptor desc)
149{
62bb3cd4 150 // see header file for class documentation
049b43b2 151 if (!CheckStatusFlag(kCollecting)) return -EPERM;
4de7334f 152 int iResult=0;
153 fBlockDescList.push_back(desc);
154 return iResult;
62bb3cd4 155}
049b43b2 156
157AliHLTOUT::AliHLTOUTByteOrder_t AliHLTOUT::CheckByteOrder()
158{
159 if (fCurrent!=fBlockDescList.end()) {
160 SetStatusFlag(kByteOrderChecked);
161 AliHLTOUT::AliHLTOUTByteOrder_t order=CheckBlockByteOrder((*fCurrent).GetIndex());
162 return order;
163 }
164 return kInvalidByteOrder;
165}
166
167int AliHLTOUT::CheckAlignment(AliHLTOUT::AliHLTOUTDataType_t type)
168{
169 if (fCurrent!=fBlockDescList.end()) {
170 SetStatusFlag(kAlignmentChecked);
171 int alignment=CheckBlockAlignment((*fCurrent).GetIndex(), type);
172 return alignment;
173 }
174 return -ENOENT;
175}