53 std::unique_ptr<MessagesPerRoute>
read(
fair::mq::Device* device,
const std::vector<o2f::OutputRoute>& outputRoutes,
const std::string& rawChannel,
size_t slice);
56 inline std::uint64_t
position()
const {
return mFileMapOffset; }
61 const std::uint64_t lPos = std::min(pPos, mFileSize);
63 mFileMapOffset = lPos;
67 inline bool eof()
const {
return mFileMapOffset == mFileSize; }
70 inline std::uint64_t
size()
const {
return mFileSize; }
73 std::string mFileName;
74 std::unordered_map<o2::header::DataOrigin, bool> mDetOrigMap;
75 boost::iostreams::mapped_file_source mFileMap;
76 std::uint64_t mFileMapOffset = 0;
77 std::uint64_t mFileSize = 0;
80 bool mSup0xccdb =
true;
81 bool mRepaireHeaders =
true;
82 bool mRejectDistSTF =
true;
88 typename = std::enable_if_t<std::is_pointer<pointer>::value>>
89 bool read_advance(
pointer pPtr, std::uint64_t pLen)
91 if (!mFileMap.is_open()) {
95 assert(mFileMapOffset <= mFileSize);
96 const std::uint64_t lToRead = std::min(pLen, mFileSize - mFileMapOffset);
98 if (lToRead != pLen) {
99 LOGP(error,
"FileReader: request to read beyond the file end. pos={} size={} len={}",
100 mFileMapOffset, mFileSize, pLen);
101 LOGP(error,
"Closing the file {}. The read data is invalid.", mFileName);
108 std::memcpy(
reinterpret_cast<char*
>(pPtr), mFileMap.data() + mFileMapOffset, lToRead);
109 mFileMapOffset += lToRead;
114 unsigned char* peek()
const
116 return const_cast<unsigned char*
>(
reinterpret_cast<const unsigned char*
>(mFileMap.data() + mFileMapOffset));
119 inline bool ignore_nbytes(
const std::size_t pLen)
121 const std::size_t lToIgnore = std::min(pLen, std::size_t(mFileSize - mFileMapOffset));
122 if (pLen != lToIgnore) {
123 LOGP(error,
"FileReader: request to ignore bytes beyond the file end. pos={} size={} len={}",
124 mFileMapOffset, mFileSize, pLen);
125 LOGP(error,
"Closing the file {}. The read data is invalid.", mFileName);
132 mFileMapOffset += lToIgnore;
133 assert(mFileMapOffset <= mFileSize);
137 std::size_t getHeaderStackSize();
141 static std::uint64_t sStfId;
std::unique_ptr< MessagesPerRoute > read(fair::mq::Device *device, const std::vector< o2f::OutputRoute > &outputRoutes, const std::string &rawChannel, size_t slice)
Read a single TF from the file.