]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/AliHLTOUT.cxx
- abandon TPCLib backward compatibility check for AliRoot releases < v4-03
[u/mrichter/AliRoot.git] / HLT / BASE / AliHLTOUT.cxx
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
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
29
30 #include <cerrno>
31 #include "AliHLTOUT.h"
32
33 /** ROOT macro for the implementation of ROOT specific class methods */
34 ClassImp(AliHLTOUT)
35
36 AliHLTOUT::AliHLTOUT()
37   :
38   fSearchDataType(kAliHLTVoidDataType),
39   fSearchSpecification(kAliHLTVoidDataSpec),
40   fFlags(0),
41   fBlockDescList(),
42   fCurrent(fBlockDescList.begin()),
43   fpBuffer(NULL)
44 {
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
52 // definitions from ALICE internal note ALICE-INT-2002-010
53 const unsigned char AliHLTOUT::fgkCDHStatusWord=4;
54 const unsigned char AliHLTOUT::fgkCDHStatusFlagsOffset=12;
55
56 // definitions from ALICE internal note ALICE-INT-2006-XXX
57 const unsigned char AliHLTOUT::fgkCDHFlagsHLTDecision=6;
58 const unsigned char AliHLTOUT::fgkCDHFlagsHLTPayload=7;
59
60 AliHLTOUT::~AliHLTOUT()
61 {
62   // see header file for class documentation
63 }
64
65 int AliHLTOUT::GetNofDataBlocks()
66 {
67   // see header file for class documentation
68   return fBlockDescList.size();
69 }
70
71 int AliHLTOUT::SelectFirstDataBlock(AliHLTComponentDataType dt, AliHLTUInt32_t spec)
72 {
73   // see header file for class documentation
74   if (CheckStatusFlag(kLocked)) return -EPERM;
75   fCurrent=fBlockDescList.begin();
76   fSearchDataType=dt;
77   fSearchSpecification=spec;
78   return FindAndSelectDataBlock();
79 }
80
81 int AliHLTOUT::SelectNextDataBlock()
82 {
83   // see header file for class documentation
84   if (CheckStatusFlag(kLocked)) return -EPERM;
85   fCurrent++;
86   return FindAndSelectDataBlock();
87 }
88
89 int AliHLTOUT::FindAndSelectDataBlock()
90 {
91   // see header file for class documentation
92   if (CheckStatusFlag(kLocked)) return -EPERM;
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;
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();
101       CheckByteOrder();
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);
113     }
114     fCurrent++;
115   }
116   return iResult;
117 }
118
119 int 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
131 int 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
145 int 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
157 int AliHLTOUT::AddBlockDescriptor(const AliHLTOUTBlockDescriptor desc)
158 {
159   // see header file for class documentation
160   if (!CheckStatusFlag(kCollecting)) return -EPERM;
161   int iResult=0;
162   fBlockDescList.push_back(desc);
163   return iResult;  
164 }
165
166 AliHLTOUT::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
176 int 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 }