40 fFirstEvent(src.fFirstEvent),
44 fBufType(src.fBufType)
63 if (buf.
null())
return false;
68 EOUT(
"Buffer format %u not supported", (
unsigned) fBufType);
91 EOUT(
"NextHadTu only allowed for buffer type mbt_HadaqTransportUnit. Check your code!");
95 if (fEvPtr.null())
return false;
100 fEvPtr.shift(hadtu()->GetPaddedSize());
108 EOUT(
"Raw size less than transport unit header - not supported !!!!");
113 if (fEvPtr.fullsize() < hadtu()->GetSize()) {
114 EOUT(
"Error in HADAQ format - declared event size %u smaller than actual portion in buffer %u",
115 (
unsigned) hadtu()->GetSize(), (
unsigned) fEvPtr.fullsize());
129 if (fEvPtr.null())
return false;
132 EOUT(
"NextEvent only allowed for buffer type mbt_HadaqEvents. Check your code!");
139 fEvPtr.shift(evnt()->GetPaddedSize());
147 EOUT(
"Raw size less than event header - not supported !!!!");
153 if (fEvPtr.fullsize() < evnt()->GetSize()) {
154 EOUT(
"Error in HADAQ format - declared event size %u bigger than actual portion in buffer %u",
155 (
unsigned) evnt()->GetSize(), (
unsigned) fEvPtr.fullsize());
176 if (!fFirstEvent) fEvPtr.reset();
177 if (fEvPtr.null())
return false;
194 ptr.
reset(fEvPtr, 0, evnt()->GetPaddedSize());
201 if (fSubPtr.null()) {
202 if (fEvPtr.null())
return false;
207 containersize = evnt()->GetPaddedSize();
210 containersize = hadtu()->GetPaddedSize();
213 containersize = fEvPtr.fullsize();
215 EOUT(
"NextSubEvent not allowed for buffer type %u. Check your code!", (
unsigned) fBufType);
219 if (containersize == 0)
return false;
221 if (containersize < headsize) {
222 EOUT(
"Hadaq format error - tu container fullsize %u too small", (
unsigned) containersize);
225 fSubPtr.reset(fEvPtr, 0, containersize);
226 fSubPtr.shift(headsize);
228 fSubPtr.shift(subevnt()->GetPaddedSize());
237 EOUT(
"Hadaq format error - subevent fullsize %u too small", subevnt()->GetSize());
246 fRawPtr.reset(fSubPtr, 0, subevnt()->GetPaddedSize());
254 unsigned sz0 = fEvPtr.rawsize(), sz1 = 0;
255 if (!fSubPtr.null()) sz1 = fEvPtr.distance_to(fSubPtr);
256 return sz0>sz1 ? sz0-sz1 : 0;
261 ReadIterator iter(buf);
263 while (iter.NextEvent()) cnt++;
299 EOUT(
"Buffer too small for just empty HADAQ event");
313 if ((fFullSize>0) && (fBuffer.GetTotalSize() >= fFullSize))
326 if (!fEvPtr.null()) availible = fEvPtr.fullsize();
327 else availible = fBuffer.GetTotalSize();
337 if (fBuffer.null())
return false;
339 if (fEvPtr.null()) fEvPtr = fBuffer;
343 if (fEvPtr.fullsize() < (
sizeof(
hadaq::RawEvent) + minsubeventssize)) {
348 evnt()->Init(evtSeqNr, runNr);
355 if (fEvPtr.null())
return false;
362 subevnt()->Init(trigger);
369 if (fSubPtr.null())
return false;
371 if (rawdatasz > maxrawdatasize())
return false;
375 fSubPtr.shift(subevnt()->GetPaddedSize());
382 if (fEvPtr.null())
return false;
387 if (fSubPtr.fullsize() < source.
fullsize())
return false;
389 fSubPtr.copyfrom(source);
398 if (fEvPtr.null())
return false;
403 if (fSubPtr.fullsize() < len)
return false;
405 fSubPtr.copyfrom(ptr, len);
415 if (fEvPtr.null())
return false;
418 if (!fSubPtr.null()) dist = fEvPtr.distance_to(fSubPtr);
419 evnt()->SetSize(dist);
421 fFullSize += paddeddist;
422 fEvPtr.shift(paddeddist);
Reference on memory from memory pool.
void SetTotalSize(BufferSize_t len)
Set total length of the buffer to specified value Size cannot be bigger than original size of the buf...
unsigned GetTypeId() const
BufferSize_t GetTotalSize() const
Return total size of all buffer segments.
void SetTypeId(unsigned tid)
Manipulator with dabc::Buffer class.
void reset(void *buf, BufferSize_t sz)
BufferSize_t fullsize() const
bool null() const
Returns true if reference contains nullptr.
Read iterator for HADAQ events/subevents.
static unsigned NumEvents(const dabc::Buffer &buf)
bool Reset()
Reset iterator - forget pointer on buffer.
bool NextEvent()
Used for ready HLD events.
unsigned rawdata_maxsize() const
Try to define maximal length for the raw data.
bool AssignEventPointer(dabc::Pointer &ptr)
bool NextSubEvent()
Used for sub-events iteration inside current block.
bool NextHadTu()
Used for raw data from TRBs.
bool NextSubeventsBlock()
Depending from buffer type calls NextHadTu() or NextEvent()
ReadIterator & operator=(const ReadIterator &src)
bool NewEvent(uint32_t evtSeqNr=0, uint32_t runNr=0, uint32_t minsubeventsize=0)
bool IsPlaceForEvent(uint32_t subeventsize)
bool FinishSubEvent(uint32_t rawdatasz)
bool NewSubevent(uint32_t minrawsize=0, uint32_t trigger=0)
bool AddSubevent(const dabc::Pointer &source)
bool Reset(const dabc::Buffer &buf)
HADES transport unit header.
Hadaq subevent structure.