53 std::unique_ptr<MessagesPerRoute>
read(
fair::mq::Device* device,
const std::vector<o2f::OutputRoute>& outputRoutes,
const std::string& rawChannel,
size_t slice,
bool sup0xccdb,
int verbosity);
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;
81 typename = std::enable_if_t<std::is_pointer<pointer>::value>>
82 bool read_advance(
pointer pPtr, std::uint64_t pLen)
84 if (!mFileMap.is_open()) {
88 assert(mFileMapOffset <= mFileSize);
89 const std::uint64_t lToRead = std::min(pLen, mFileSize - mFileMapOffset);
91 if (lToRead != pLen) {
92 LOGP(error,
"FileReader: request to read beyond the file end. pos={} size={} len={}",
93 mFileMapOffset, mFileSize, pLen);
94 LOGP(error,
"Closing the file {}. The read data is invalid.", mFileName);
101 std::memcpy(
reinterpret_cast<char*
>(pPtr), mFileMap.data() + mFileMapOffset, lToRead);
102 mFileMapOffset += lToRead;
107 unsigned char* peek()
const
109 return const_cast<unsigned char*
>(
reinterpret_cast<const unsigned char*
>(mFileMap.data() + mFileMapOffset));
112 inline bool ignore_nbytes(
const std::size_t pLen)
114 const std::size_t lToIgnore = std::min(pLen, std::size_t(mFileSize - mFileMapOffset));
115 if (pLen != lToIgnore) {
116 LOGP(error,
"FileReader: request to ignore bytes beyond the file end. pos={} size={} len={}",
117 mFileMapOffset, mFileSize, pLen);
118 LOGP(error,
"Closing the file {}. The read data is invalid.", mFileName);
125 mFileMapOffset += lToIgnore;
126 assert(mFileMapOffset <= mFileSize);
130 std::size_t getHeaderStackSize();
134 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, bool sup0xccdb, int verbosity)
Read a single TF from the file.