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();
102 if (blockBO!=fByteOrder) {
103 SetStatusFlag(kByteOrderWarning);
107 ClearStatusFlag(kByteOrderChecked);
109 // TODO: check the alignment on the current system and the alignment of the
110 // data block, print warning when missmatch and user did not check
111 ClearStatusFlag(kAlignmentChecked);
118 int AliHLTOUT::GetDataBlockDescription(AliHLTComponentDataType& dt, AliHLTUInt32_t& spec)
120 // see header file for class documentation
122 if (fCurrent!=fBlockDescList.end()) {
130 int AliHLTOUT::GetDataBuffer(const AliHLTUInt8_t* &pBuffer, AliHLTUInt32_t& size)
132 // see header file for class documentation
136 if (fCurrent!=fBlockDescList.end()) {
137 if ((iResult=GetDataBuffer((*fCurrent).GetIndex(), pBuffer, size))>=0) {
144 int AliHLTOUT::ReleaseDataBuffer(const AliHLTUInt8_t* pBuffer)
146 // see header file for class documentation
148 if (pBuffer==fpBuffer) {
151 HLTWarning("buffer %p does not match the provided one %p", pBuffer, fpBuffer);
156 int AliHLTOUT::AddBlockDescriptor(const AliHLTOUTBlockDescriptor desc)
158 // see header file for class documentation
159 if (!CheckStatusFlag(kCollecting)) return -EPERM;
161 fBlockDescList.push_back(desc);
165 AliHLTOUT::AliHLTOUTByteOrder_t AliHLTOUT::CheckByteOrder()
167 if (fCurrent!=fBlockDescList.end()) {
168 SetStatusFlag(kByteOrderChecked);
169 AliHLTOUT::AliHLTOUTByteOrder_t order=CheckBlockByteOrder((*fCurrent).GetIndex());
172 return kInvalidByteOrder;
175 int AliHLTOUT::CheckAlignment(AliHLTOUT::AliHLTOUTDataType_t type)
177 if (fCurrent!=fBlockDescList.end()) {
178 SetStatusFlag(kAlignmentChecked);
179 int alignment=CheckBlockAlignment((*fCurrent).GetIndex(), type);