3 /**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
7 * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 * for The ALICE HLT Project. *
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 **************************************************************************/
19 /** @file AliHLTOUT.cxx
20 @author Matthias Richter
22 @brief The control class for HLTOUT data. */
24 // see header file for class documentation
26 // refer to README to build package
28 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
31 #include "AliHLTOUT.h"
33 /** ROOT macro for the implementation of ROOT specific class methods */
36 AliHLTOUT::AliHLTOUT()
38 fSearchDataType(kAliHLTVoidDataType),
39 fSearchSpecification(kAliHLTVoidDataSpec),
42 fCurrent(fBlockDescList.begin()),
45 // see header file for class documentation
47 // refer to README to build package
49 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
52 // definitions from ALICE internal note ALICE-INT-2002-010
53 const unsigned char AliHLTOUT::fgkCDHStatusWord=4;
54 const unsigned char AliHLTOUT::fgkCDHStatusFlagsOffset=12;
56 // definitions from ALICE internal note ALICE-INT-2006-XXX
57 const unsigned char AliHLTOUT::fgkCDHFlagsHLTDecision=6;
58 const unsigned char AliHLTOUT::fgkCDHFlagsHLTPayload=7;
60 AliHLTOUT::~AliHLTOUT()
62 // see header file for class documentation
65 int AliHLTOUT::GetNofDataBlocks()
67 // see header file for class documentation
68 return fBlockDescList.size();
71 int AliHLTOUT::SelectFirstDataBlock(AliHLTComponentDataType dt, AliHLTUInt32_t spec)
73 // see header file for class documentation
74 if (CheckStatusFlag(kLocked)) return -EPERM;
75 fCurrent=fBlockDescList.begin();
77 fSearchSpecification=spec;
78 return FindAndSelectDataBlock();
81 int AliHLTOUT::SelectNextDataBlock()
83 // see header file for class documentation
84 if (CheckStatusFlag(kLocked)) return -EPERM;
86 return FindAndSelectDataBlock();
89 int AliHLTOUT::FindAndSelectDataBlock()
91 // see header file for class documentation
92 if (CheckStatusFlag(kLocked)) return -EPERM;
94 while (fCurrent!=fBlockDescList.end() && iResult==-ENOENT) {
95 if ((fSearchDataType==kAliHLTAnyDataType || (*fCurrent)==fSearchDataType) &&
96 fSearchSpecification==kAliHLTVoidDataSpec || (*fCurrent)==fSearchSpecification) {
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
100 //AliHLTOUTByteOrder_t blockBO=CheckByteOrder();
103 if (blockBO!=fByteOrder) {
104 SetStatusFlag(kByteOrderWarning);
108 ClearStatusFlag(kByteOrderChecked);
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);
119 int AliHLTOUT::GetDataBlockDescription(AliHLTComponentDataType& dt, AliHLTUInt32_t& spec)
121 // see header file for class documentation
123 if (fCurrent!=fBlockDescList.end()) {
131 int AliHLTOUT::GetDataBuffer(const AliHLTUInt8_t* &pBuffer, AliHLTUInt32_t& size)
133 // see header file for class documentation
137 if (fCurrent!=fBlockDescList.end()) {
138 if ((iResult=GetDataBuffer((*fCurrent).GetIndex(), pBuffer, size))>=0) {
145 int AliHLTOUT::ReleaseDataBuffer(const AliHLTUInt8_t* pBuffer)
147 // see header file for class documentation
149 if (pBuffer==fpBuffer) {
152 HLTWarning("buffer %p does not match the provided one %p", pBuffer, fpBuffer);
157 int AliHLTOUT::AddBlockDescriptor(const AliHLTOUTBlockDescriptor desc)
159 // see header file for class documentation
160 if (!CheckStatusFlag(kCollecting)) return -EPERM;
162 fBlockDescList.push_back(desc);
166 AliHLTOUT::AliHLTOUTByteOrder_t AliHLTOUT::CheckByteOrder()
168 if (fCurrent!=fBlockDescList.end()) {
169 SetStatusFlag(kByteOrderChecked);
170 AliHLTOUT::AliHLTOUTByteOrder_t order=CheckBlockByteOrder((*fCurrent).GetIndex());
173 return kInvalidByteOrder;
176 int AliHLTOUT::CheckAlignment(AliHLTOUT::AliHLTOUTDataType_t type)
178 if (fCurrent!=fBlockDescList.end()) {
179 SetStatusFlag(kAlignmentChecked);
180 int alignment=CheckBlockAlignment((*fCurrent).GetIndex(), type);