38 fFirstEvent(src.fFirstEvent),
59 if (buf.
null())
return false;
62 EOUT(
"Only buffer format mbt_MbsEvents is supported");
82 if (fEvPtr.null())
return true;
84 return fEvPtr.fullsize() <= evnt()->FullSize();
90 if (fEvPtr.null())
return false;
95 fEvPtr.shift(evnt()->FullSize());
97 if (fEvPtr.fullsize() <
sizeof(EventHeader)) {
102 if (fEvPtr.rawsize() <
sizeof(EventHeader)) {
103 EOUT(
"Raw size less than event header - not supported !!!!");
109 if (fEvPtr.fullsize() < evnt()->FullSize()) {
110 EOUT(
"Error in MBS format - declared event size %u bigger than actual portion in the buffer %u",
111 (
unsigned) evnt()->FullSize(), (
unsigned) fEvPtr.fullsize());
124 if (evnt()==0)
return 0;
125 unsigned res = evnt()->FullSize();
126 return res < fEvPtr.fullsize() ? res : fEvPtr.fullsize();
133 AssignEventPointer(res);
140 AssignEventPointer(res);
152 ptr.
reset(fEvPtr, 0, evnt()->FullSize());
159 if (fSubPtr.null()) {
160 if (fEvPtr.null())
return false;
162 EOUT(
"Mbs format error - event fullsize %u too small", evnt()->FullSize());
165 fSubPtr.reset(fEvPtr, 0, evnt()->FullSize());
166 fSubPtr.shift(
sizeof(EventHeader));
168 fSubPtr.shift(subevnt()->FullSize());
170 if (fSubPtr.fullsize() <
sizeof(SubeventHeader)) {
175 if (subevnt()->FullSize() <
sizeof(SubeventHeader)) {
176 EOUT(
"Mbs format error - subevent fullsize too small");
181 fRawPtr.reset(fSubPtr, 0, subevnt()->FullSize());
182 fRawPtr.shift(
sizeof(SubeventHeader));
227 EOUT(
"Buffer too small for just empty MBS event");
239 if (!fSubData.null()) FinishSubEvent();
240 if (!fSubPtr.null()) FinishEvent();
241 unsigned full_size = fEvPtr.distance_to_ownbuf();
242 if (full_size != fFullSize)
243 EOUT(
"Sizes mismatch");
247 if ((fFullSize>0) && (fBuffer.GetTotalSize() >= fFullSize))
248 fBuffer.SetTotalSize(fFullSize);
258 if (newbuf.
null())
return Close();
260 if (!IsAnyIncompleteData()) {
267 if (!fEvPtr.is_same_buf(fSubPtr))
EOUT(
"Place 111");
269 unsigned subptr_shift = fEvPtr.distance_to(fSubPtr);
270 unsigned copy_size = subptr_shift;
271 unsigned subdata_shift(0);
273 if (!fSubData.null()) {
274 if (!fSubData.is_same_buf(fSubPtr))
EOUT(
"Place 222");
275 subdata_shift = fSubPtr.distance_to(fSubData);
276 copy_size += subdata_shift;
289 fSubPtr.reset(fEvPtr, subptr_shift);
290 if (subdata_shift>0) fSubData.reset(fSubPtr, subdata_shift);
307 if (!fSubPtr.null()) {
308 EOUT(
"Previous event not closed");
313 EOUT(
"No any place for new event");
317 if (fEvPtr.fullsize() < (
sizeof(EventHeader) + minsubeventssize)) {
318 EOUT(
"Too few place for the new event");
322 fSubPtr.reset(fEvPtr,
sizeof(EventHeader));
324 evnt()->Init(event_number);
331 if (fSubPtr.null())
return false;
333 if (!fSubData.null()) {
334 EOUT(
"Previous subevent not yet finished!!!");
338 if (fSubPtr.fullsize() < (
sizeof(SubeventHeader) + minrawsize))
return false;
340 subevnt()->Init(crate, procid, control);
342 fSubData.reset(fSubPtr,
sizeof(SubeventHeader));
349 if (fSubPtr.null())
return false;
351 if (!fSubData.null()) {
352 EOUT(
"Previous subevent not yet finished!!!");
356 subevnt()->InitFull(
fullid);
358 fSubData.reset(fSubPtr,
sizeof(SubeventHeader));
367 return len <= fSubData.fullsize();
373 if (fSubData.null() || (len > fSubPtr.fullsize()))
return false;
374 fSubData.copyfrom_shift(src, len);
382 if (fSubPtr.null())
return false;
384 unsigned filled_rawsize = 0;
385 if (fSubData.null()) {
387 filled_rawsize = maxrawdatasize();
389 if (!fSubData.is_same_buf(fSubPtr))
EOUT(
"Place 333");
390 filled_rawsize = fSubPtr.distance_to(fSubData) -
sizeof(SubeventHeader);
393 if (rawdatasz==0) rawdatasz = filled_rawsize;
395 if (rawdatasz > maxrawdatasize()) {
396 EOUT(
"So big raw data size %u not possible, maximum is %u", rawdatasz, maxrawdatasize());
397 rawdatasz = maxrawdatasize();
400 subevnt()->SetRawDataSize(rawdatasz);
402 fSubPtr.shift(subevnt()->FullSize());
411 if (fSubPtr.null())
return false;
413 if (fSubPtr.fullsize() < source.
fullsize())
return false;
415 fSubPtr.copyfrom(source);
430 if (fEvPtr.null())
return false;
435 if (!fSubPtr.null()) {
436 if (!fEvPtr.is_same_buf(fSubPtr))
EOUT(
"Place 444");
437 fullsize = fEvPtr.distance_to(fSubPtr);
440 evnt()->SetFullSize(fullsize);
441 fEvPtr.shift(fullsize);
444 fFullSize += fullsize;
458 if (!fSubPtr.null()) {
459 EOUT(
"Previous event not closed");
464 EOUT(
"No any place for new event");
468 if (fEvPtr.fullsize() < ptr.
fullsize()) {
469 EOUT(
"Too few place for the new event");
473 fEvPtr.copyfrom(ptr);
475 fSubPtr.reset(fEvPtr, ptr.
fullsize());
477 if (finish)
return FinishEvent();
Reference on memory from memory pool.
unsigned GetTypeId() const
BufferSize_t GetTotalSize() const
Return total size of all buffer segments.
void SetTypeId(unsigned tid)
Manipulator with dabc::Buffer class.
BufferSize_t shift(BufferSize_t sz)
void reset(void *buf, BufferSize_t sz)
BufferSize_t copyfrom(const Pointer &src, BufferSize_t sz=0)
Returns actual size copied.
BufferSize_t fullsize() const
bool null() const
Returns true if reference contains nullptr.
Read iterator for HADAQ events/subevents.
bool NextEvent()
Used for ready HLD events.
Read iterator for MBS events/subevents.
unsigned GetEventSize() const
bool Reset()
Reset iterator - forget pointer on buffer.
dabc::Pointer GetSubeventsPointer()
Returns pointer, which assign only on subevents.
static unsigned NumEvents(const dabc::Buffer &buf)
bool AssignEventPointer(dabc::Pointer &ptr)
ReadIterator & operator=(const ReadIterator &src)
bool IsLastEvent() const
Returns true if it is last event in the buffer.
dabc::Pointer GetEventPointer()
Returns pointer, which assign on complete event, including header.
bool Reset(dabc::Buffer &buf)
bool AddSubevent(const dabc::Pointer &source)
bool FinishSubEvent(uint32_t rawdatasz=0)
bool AddRawData(const void *src, unsigned len)
dabc::Buffer CloseAndTransfer(dabc::Buffer &newbuf)
Method could be used to close current buffer and transfer all uncompleted parts to new buffer.
bool NewSubevent(uint32_t minrawsize=0, uint8_t crate=0, uint16_t procid=0, uint8_t control=0)
void DiscardEvent()
Ignore all data, which were add with last NewEvent call.
bool IsPlaceForRawData(unsigned len) const
bool NewSubevent2(uint32_t fullid)
bool CopyEventFrom(const dabc::Pointer &ptr, bool finish=true)
Method to copy full event from the other place.
bool NewEvent(EventNumType event_number=0, uint32_t subeventsize=0)
bool IsPlaceForEvent(uint32_t subeventsize, bool add_subev_header=false)