documentation and cleanup
[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
4b113031 52// definitions from ALICE internal note ALICE-INT-2002-010
53const unsigned char AliHLTOUT::fgkCDHStatusWord=4;
54const unsigned char AliHLTOUT::fgkCDHStatusFlagsOffset=12;
55
56// definitions from ALICE internal note ALICE-INT-2006-XXX
57const unsigned char AliHLTOUT::fgkCDHFlagsHLTDecision=6;
58const unsigned char AliHLTOUT::fgkCDHFlagsHLTPayload=7;
59
62bb3cd4 60AliHLTOUT::~AliHLTOUT()
4de7334f 61{
62 // see header file for class documentation
63}
64
65int AliHLTOUT::GetNofDataBlocks()
66{
67 // see header file for class documentation
68 return fBlockDescList.size();
69}
70
71int AliHLTOUT::SelectFirstDataBlock(AliHLTComponentDataType dt, AliHLTUInt32_t spec)
72{
73 // see header file for class documentation
049b43b2 74 if (CheckStatusFlag(kLocked)) return -EPERM;
4de7334f 75 fCurrent=fBlockDescList.begin();
76 fSearchDataType=dt;
77 fSearchSpecification=spec;
049b43b2 78 return FindAndSelectDataBlock();
4de7334f 79}
80
81int AliHLTOUT::SelectNextDataBlock()
82{
83 // see header file for class documentation
049b43b2 84 if (CheckStatusFlag(kLocked)) return -EPERM;
85 fCurrent++;
86 return FindAndSelectDataBlock();
87}
88
89int AliHLTOUT::FindAndSelectDataBlock()
90{
91 // see header file for class documentation
92 if (CheckStatusFlag(kLocked)) return -EPERM;
4de7334f 93 int iResult=-ENOENT;
94 while (fCurrent!=fBlockDescList.end() && iResult==-ENOENT) {
95 if ((fSearchDataType==kAliHLTAnyDataType || (*fCurrent)==fSearchDataType) &&
96 fSearchSpecification==kAliHLTVoidDataSpec || (*fCurrent)==fSearchSpecification) {
97 iResult=0;
049b43b2 98 // TODO: check the byte order on the current system and the byte order of the
99 // data block, print warning when missmatch and user did not check
d76bc02a 100 //AliHLTOUTByteOrder_t blockBO=CheckByteOrder();
06f53caf 101 CheckByteOrder();
049b43b2 102 /*
103 if (blockBO!=fByteOrder) {
104 SetStatusFlag(kByteOrderWarning);
105
106 }
107 */
108 ClearStatusFlag(kByteOrderChecked);
109
110 // TODO: check the alignment on the current system and the alignment of the
111 // data block, print warning when missmatch and user did not check
112 ClearStatusFlag(kAlignmentChecked);
4de7334f 113 }
049b43b2 114 fCurrent++;
4de7334f 115 }
116 return iResult;
117}
118
119int AliHLTOUT::GetDataBlockDescription(AliHLTComponentDataType& dt, AliHLTUInt32_t& spec)
120{
121 // see header file for class documentation
122 int iResult=-ENOENT;
123 if (fCurrent!=fBlockDescList.end()) {
124 iResult=0;
125 dt=(*fCurrent);
126 spec=(*fCurrent);
127 }
128 return iResult;
129}
130
131int AliHLTOUT::GetDataBuffer(const AliHLTUInt8_t* &pBuffer, AliHLTUInt32_t& size)
132{
133 // see header file for class documentation
134 int iResult=-ENOENT;
135 pBuffer=NULL;
136 size=0;
137 if (fCurrent!=fBlockDescList.end()) {
138 if ((iResult=GetDataBuffer((*fCurrent).GetIndex(), pBuffer, size))>=0) {
139 fpBuffer=pBuffer;
140 }
141 }
142 return iResult;
143}
144
145int AliHLTOUT::ReleaseDataBuffer(const AliHLTUInt8_t* pBuffer)
146{
147 // see header file for class documentation
148 int iResult=0;
149 if (pBuffer==fpBuffer) {
150 fpBuffer=NULL;
151 } else {
152 HLTWarning("buffer %p does not match the provided one %p", pBuffer, fpBuffer);
153 }
154 return iResult;
155}
156
157int AliHLTOUT::AddBlockDescriptor(const AliHLTOUTBlockDescriptor desc)
158{
62bb3cd4 159 // see header file for class documentation
049b43b2 160 if (!CheckStatusFlag(kCollecting)) return -EPERM;
4de7334f 161 int iResult=0;
162 fBlockDescList.push_back(desc);
163 return iResult;
62bb3cd4 164}
049b43b2 165
166AliHLTOUT::AliHLTOUTByteOrder_t AliHLTOUT::CheckByteOrder()
167{
168 if (fCurrent!=fBlockDescList.end()) {
169 SetStatusFlag(kByteOrderChecked);
170 AliHLTOUT::AliHLTOUTByteOrder_t order=CheckBlockByteOrder((*fCurrent).GetIndex());
171 return order;
172 }
173 return kInvalidByteOrder;
174}
175
176int AliHLTOUT::CheckAlignment(AliHLTOUT::AliHLTOUTDataType_t type)
177{
178 if (fCurrent!=fBlockDescList.end()) {
179 SetStatusFlag(kAlignmentChecked);
180 int alignment=CheckBlockAlignment((*fCurrent).GetIndex(), type);
181 return alignment;
182 }
183 return -ENOENT;
184}