1 #include "artdaq-core/Data/Fragment.hh"
2 #include "artdaq-core/Data/detail/RawFragmentHeader.hh"
4 #define BOOST_TEST_MODULE(Fragment_t)
5 #include <cetlib/quiet_unit_test.hpp>
37 BOOST_AUTO_TEST_SUITE(Fragment_test)
39 BOOST_AUTO_TEST_CASE(Construct)
45 BOOST_REQUIRE_EQUAL(f1.
dataSize(), (size_t)0);
54 BOOST_REQUIRE_EQUAL(f2.dataSize(), (size_t)7);
60 BOOST_REQUIRE_EQUAL(f2.hasMetadata(),
false);
63 BOOST_REQUIRE_EQUAL(f3.dataSize(), (size_t)0);
69 BOOST_REQUIRE_EQUAL(f3.hasMetadata(),
false);
76 BOOST_REQUIRE(0 &&
"Should have thrown exception");
78 catch (cet::exception
const& excpt)
82 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
88 BOOST_REQUIRE(0 &&
"Should have thrown exception");
90 catch (cet::exception
const& excpt)
94 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
100 BOOST_REQUIRE(0 &&
"Should have thrown exception");
102 catch (cet::exception
const& excpt)
106 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
112 BOOST_REQUIRE(0 &&
"Should have thrown exception");
114 catch (cet::exception
const& excpt)
118 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
125 BOOST_REQUIRE(0 &&
"Should have thrown exception");
127 catch (cet::exception
const& excpt)
131 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
138 BOOST_REQUIRE(0 &&
"Should have thrown exception");
140 catch (cet::exception
const& excpt)
144 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
162 BOOST_REQUIRE(0 &&
"Should not have thrown exception");
166 BOOST_AUTO_TEST_CASE(FragmentType)
174 BOOST_REQUIRE(0 &&
"Should have thrown exception");
176 catch (cet::exception
const& excpt)
180 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
185 frag.setUserType(225);
186 BOOST_REQUIRE(0 &&
"Should have thrown exception");
188 catch (cet::exception
const& excpt)
192 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
197 frag.setUserType(255);
198 BOOST_REQUIRE(0 &&
"Should have thrown exception");
200 catch (cet::exception
const& excpt)
204 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
210 BOOST_REQUIRE(0 &&
"Should have thrown exception");
212 catch (cet::exception
const& excpt)
216 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
222 BOOST_REQUIRE(0 &&
"Should have thrown exception");
224 catch (cet::exception
const& excpt)
228 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
234 BOOST_REQUIRE(0 &&
"Should have thrown exception");
236 catch (cet::exception
const& excpt)
240 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
250 frag.setUserType(100);
251 frag.setUserType(200);
252 frag.setUserType(224);
256 BOOST_REQUIRE(0 &&
"Should not have thrown exception");
262 frag.setSystemType(0);
263 BOOST_REQUIRE(0 &&
"Should have thrown exception");
265 catch (cet::exception
const& excpt)
269 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
274 frag.setSystemType(1);
275 BOOST_REQUIRE(0 &&
"Should have thrown exception");
277 catch (cet::exception
const& excpt)
281 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
286 frag.setSystemType(224);
287 BOOST_REQUIRE(0 &&
"Should have thrown exception");
289 catch (cet::exception
const& excpt)
293 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
299 BOOST_REQUIRE(0 &&
"Should have thrown exception");
301 catch (cet::exception
const& excpt)
305 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
311 BOOST_REQUIRE(0 &&
"Should have thrown exception");
313 catch (cet::exception
const& excpt)
317 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
323 BOOST_REQUIRE(0 &&
"Should have thrown exception");
325 catch (cet::exception
const& excpt)
329 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
336 frag.setSystemType(225);
337 frag.setSystemType(230);
338 frag.setSystemType(240);
339 frag.setSystemType(250);
340 frag.setSystemType(255);
344 BOOST_REQUIRE(0 &&
"Should not have thrown exception");
348 BOOST_AUTO_TEST_CASE(SequenceID)
352 BOOST_REQUIRE_EQUAL(f1.
sequenceID(), (uint64_t)0);
354 BOOST_REQUIRE_EQUAL(f1.
sequenceID(), (uint64_t)1);
356 BOOST_REQUIRE_EQUAL(f1.
sequenceID(), (uint64_t)0xffff);
358 BOOST_REQUIRE_EQUAL(f1.
sequenceID(), (uint64_t)0x0000ffffffffffff);
361 BOOST_REQUIRE_EQUAL(f2.sequenceID(), (uint64_t)0x12345);
364 BOOST_REQUIRE_EQUAL(f3.sequenceID(), (uint64_t)0x0000567812345678);
367 BOOST_AUTO_TEST_CASE(FragmentID)
371 BOOST_REQUIRE_EQUAL(f1.
fragmentID(), (uint16_t)0);
373 BOOST_REQUIRE_EQUAL(f1.
fragmentID(), (uint16_t)1);
375 BOOST_REQUIRE_EQUAL(f1.
fragmentID(), (uint16_t)0xffff);
378 BOOST_REQUIRE_EQUAL(f2.fragmentID(), (uint16_t)0xab);
381 BOOST_REQUIRE_EQUAL(f3.fragmentID(), (uint16_t)0xffff);
384 BOOST_AUTO_TEST_CASE(Resize)
389 BOOST_REQUIRE_EQUAL(f1.
dataSize(), (size_t)1234);
390 BOOST_REQUIRE_EQUAL(f1.
size(), (size_t)1234 +
397 BOOST_REQUIRE_EQUAL(f2.dataSize(), (size_t)129);
398 BOOST_REQUIRE_EQUAL(f2.size(), (size_t)129 + 2 +
402 BOOST_AUTO_TEST_CASE(Empty)
405 BOOST_REQUIRE_EQUAL(f1.
empty(),
true);
407 BOOST_REQUIRE_EQUAL(f1.
empty(),
false);
411 BOOST_REQUIRE_EQUAL(f2.empty(),
false);
413 BOOST_REQUIRE_EQUAL(f2.empty(),
false);
415 BOOST_REQUIRE_EQUAL(f2.empty(),
true);
416 BOOST_REQUIRE_EQUAL(f2.dataSize(), (size_t)0);
417 BOOST_REQUIRE_EQUAL(f2.size(), (size_t)2 +
421 BOOST_REQUIRE_EQUAL(f3.empty(),
true);
423 BOOST_REQUIRE_EQUAL(f3.empty(),
true);
426 BOOST_REQUIRE_EQUAL(f4.empty(),
false);
427 f4.setMetadata(mdOneA);
428 BOOST_REQUIRE_EQUAL(f4.empty(),
false);
431 BOOST_AUTO_TEST_CASE(Clear)
434 BOOST_REQUIRE_EQUAL(f1.
empty(),
true);
436 BOOST_REQUIRE_EQUAL(f1.
empty(),
false);
438 BOOST_REQUIRE_EQUAL(f1.
empty(),
true);
442 BOOST_REQUIRE_EQUAL(f2.empty(),
false);
444 BOOST_REQUIRE_EQUAL(f2.empty(),
false);
446 BOOST_REQUIRE_EQUAL(f2.empty(),
true);
447 BOOST_REQUIRE_EQUAL(f2.dataSize(), (size_t)0);
448 BOOST_REQUIRE_EQUAL(f2.size(), (size_t)2 +
452 BOOST_REQUIRE_EQUAL(f3.empty(),
true);
453 BOOST_REQUIRE_EQUAL(f3.hasMetadata(),
false);
455 BOOST_REQUIRE_EQUAL(f3.empty(),
true);
456 BOOST_REQUIRE_EQUAL(f3.hasMetadata(),
true);
458 BOOST_REQUIRE_EQUAL(f3.empty(),
true);
459 BOOST_REQUIRE_EQUAL(f3.hasMetadata(),
true);
462 BOOST_REQUIRE_EQUAL(f4.empty(),
false);
463 BOOST_REQUIRE_EQUAL(f4.hasMetadata(),
false);
464 f4.setMetadata(mdOneA);
465 BOOST_REQUIRE_EQUAL(f4.empty(),
false);
466 BOOST_REQUIRE_EQUAL(f4.hasMetadata(),
true);
468 BOOST_REQUIRE_EQUAL(f4.empty(),
true);
469 BOOST_REQUIRE_EQUAL(f4.hasMetadata(),
true);
472 BOOST_AUTO_TEST_CASE(Addresses)
476 BOOST_REQUIRE_EQUAL(f1.
dataSize(), (size_t)200);
477 BOOST_REQUIRE_EQUAL(f1.
size(), (size_t)200 +
481 BOOST_REQUIRE_EQUAL(daddr,
486 BOOST_REQUIRE(0 &&
"Should have thrown exception");
488 catch (cet::exception
const& excpt)
492 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
494 BOOST_REQUIRE_EQUAL(haddr, &(*(f1.
headerBegin())));
495 BOOST_REQUIRE_EQUAL(daddr, &(*(f1.
dataBegin())));
496 BOOST_REQUIRE_EQUAL(daddr + 200, &(*(f1.
dataEnd())));
501 BOOST_REQUIRE_EQUAL(f2.dataSize(), (size_t)135);
502 BOOST_REQUIRE_EQUAL(f2.size(), (size_t)135 + 2 +
504 haddr = f2.headerAddress();
505 daddr = f2.dataAddress();
507 BOOST_REQUIRE_EQUAL(maddr, haddr +
509 BOOST_REQUIRE_EQUAL(daddr, maddr + 2);
510 BOOST_REQUIRE_EQUAL(haddr, &(*(f2.headerBegin())));
511 BOOST_REQUIRE_EQUAL(daddr, &(*(f2.dataBegin())));
512 BOOST_REQUIRE_EQUAL(daddr + 135, &(*(f2.dataEnd())));
517 BOOST_REQUIRE_EQUAL(f3.dataSize(), (size_t)77);
518 BOOST_REQUIRE_EQUAL(f3.size(), (size_t)77 + 4 +
520 haddr = f3.headerAddress();
521 daddr = f3.dataAddress();
522 maddr = f3.metadataAddress();
523 BOOST_REQUIRE_EQUAL(maddr, haddr +
525 BOOST_REQUIRE_EQUAL(daddr, maddr + 4);
526 BOOST_REQUIRE_EQUAL(haddr, &(*(f3.headerBegin())));
527 BOOST_REQUIRE_EQUAL(daddr, &(*(f3.dataBegin())));
528 BOOST_REQUIRE_EQUAL(daddr + 77, &(*(f3.dataEnd())));
531 BOOST_AUTO_TEST_CASE(Metadata)
538 BOOST_REQUIRE(0 &&
"Should have thrown exception");
540 catch (cet::exception
const& excpt)
544 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
555 BOOST_REQUIRE(0 &&
"Should have thrown exception");
557 catch (cet::exception
const& excpt)
561 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
566 BOOST_REQUIRE_EQUAL(mdOnePtr->field1, (uint64_t)5);
567 BOOST_REQUIRE_EQUAL(mdOnePtr->field2, (uint32_t)10);
568 BOOST_REQUIRE_EQUAL(mdOnePtr->field3, (uint32_t)15);
574 BOOST_REQUIRE(0 &&
"Should have thrown exception");
576 catch (cet::exception
const& excpt)
580 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
595 BOOST_REQUIRE(0 &&
"Should have thrown exception");
597 catch (cet::exception
const& excpt)
601 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
606 BOOST_REQUIRE_EQUAL(mdTwoPtr->field1, (uint64_t)10);
607 BOOST_REQUIRE_EQUAL(mdTwoPtr->field2, (uint32_t)20);
608 BOOST_REQUIRE_EQUAL(mdTwoPtr->field3, (uint32_t)30);
609 BOOST_REQUIRE_EQUAL(mdTwoPtr->field4, (uint32_t)40);
610 BOOST_REQUIRE_EQUAL(mdTwoPtr->field5, (uint32_t)50);
613 BOOST_REQUIRE_EQUAL(f3.sequenceID(), (uint32_t)0xabcdef);
614 BOOST_REQUIRE_EQUAL(f3.fragmentID(), (uint16_t)0xc3a5);
615 BOOST_REQUIRE_EQUAL(f3.type(), (uint16_t)123);
617 BOOST_REQUIRE_EQUAL(f3.sequenceID(), (uint32_t)0xabcdef);
618 BOOST_REQUIRE_EQUAL(f3.fragmentID(), (uint16_t)0xc3a5);
619 BOOST_REQUIRE_EQUAL(f3.type(), (uint8_t)123);
621 dataPtr[0] = 0x12345678;
623 dataPtr[2] = 0x456789ab;
624 dataPtr[3] = 0x3c3c3c3c;
625 dataPtr[4] = 0x5a5a5a5a;
626 BOOST_REQUIRE_EQUAL(dataPtr[0], (uint64_t)0x12345678);
627 BOOST_REQUIRE_EQUAL(dataPtr[1], (uint64_t)0xabcd);
628 BOOST_REQUIRE_EQUAL(dataPtr[2], (uint64_t)0x456789ab);
629 BOOST_REQUIRE_EQUAL(dataPtr[3], (uint64_t)0x3c3c3c3c);
630 BOOST_REQUIRE_EQUAL(dataPtr[4], (uint64_t)0x5a5a5a5a);
631 BOOST_REQUIRE_EQUAL(f3.sequenceID(), (uint32_t)0xabcdef);
632 BOOST_REQUIRE_EQUAL(f3.fragmentID(), (uint16_t)0xc3a5);
633 BOOST_REQUIRE_EQUAL(f3.type(), (uint8_t)123);
638 f3.setMetadata(mdOneC);
640 BOOST_REQUIRE_EQUAL(mdOnePtr->field1, (uint64_t)505);
641 BOOST_REQUIRE_EQUAL(mdOnePtr->field2, (uint32_t)510);
642 BOOST_REQUIRE_EQUAL(mdOnePtr->field3, (uint32_t)515);
643 BOOST_REQUIRE_EQUAL(f3.sequenceID(), (uint32_t)0xabcdef);
644 BOOST_REQUIRE_EQUAL(f3.fragmentID(), (uint16_t)0xc3a5);
645 BOOST_REQUIRE_EQUAL(f3.type(), (uint8_t)123);
646 dataPtr = f3.dataAddress();
647 dataPtr[0] = 0x12345678;
649 dataPtr[2] = 0x456789ab;
650 dataPtr[3] = 0x3c3c3c3c;
651 dataPtr[4] = 0x5a5a5a5a;
652 BOOST_REQUIRE_EQUAL(dataPtr[0], (uint64_t)0x12345678);
653 BOOST_REQUIRE_EQUAL(dataPtr[1], (uint64_t)0xabcd);
654 BOOST_REQUIRE_EQUAL(dataPtr[2], (uint64_t)0x456789ab);
655 BOOST_REQUIRE_EQUAL(dataPtr[3], (uint64_t)0x3c3c3c3c);
656 BOOST_REQUIRE_EQUAL(dataPtr[4], (uint64_t)0x5a5a5a5a);
660 BOOST_REQUIRE_EQUAL(f4.hasMetadata(),
false);
663 f4.setMetadata(mdHuge);
664 BOOST_REQUIRE(0 &&
"Should have thrown exception");
666 catch (cet::exception
const& excpt)
670 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
676 BOOST_REQUIRE(0 &&
"Should have thrown exception");
678 catch (cet::exception
const& excpt)
682 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
689 BOOST_AUTO_TEST_CASE(Bytes)
691 std::size_t payload_size = 5;
708 Metadata theMetadata;
724 BOOST_REQUIRE(f1->
size() == f1_factory->size());
725 BOOST_REQUIRE(f1->
sizeBytes() == f1_factory->sizeBytes());
727 std::unique_ptr<artdaq::Fragment> f2(
new artdaq::Fragment(payload_size, seqID, fragID, type, theMetadata));
733 BOOST_REQUIRE(f2->size() == f2_factory->size());
734 BOOST_REQUIRE(f2->sizeBytes() == f2_factory->sizeBytes());
739 std::size_t offset = 3;
745 BOOST_REQUIRE(f3_factory->size() == f2->size());
746 BOOST_REQUIRE(f3_factory->sizeBytes() == f2->sizeBytes());
753 &*f3_factory->dataBegin());
759 BOOST_REQUIRE_EQUAL(ptr1, ptr2);
760 BOOST_REQUIRE_EQUAL(ptr2, ptr3);
764 std::size_t
const metadata_size =
766 BOOST_REQUIRE(metadata_size ==
770 BOOST_REQUIRE(static_cast<std::size_t>(f3_factory->dataEndBytes() - f3_factory->dataBeginBytes()) == f3_factory->dataSizeBytes());
774 BOOST_REQUIRE_EQUAL(f4.dataSize(), payload_size);
776 f4.resize(payload_size + 1);
777 BOOST_REQUIRE_EQUAL(f4.dataSize(), (payload_size + 1));
778 BOOST_REQUIRE_EQUAL(f4.dataSizeBytes(), ((payload_size + 1) *
sizeof(
artdaq::RawDataType)));
779 f4.resizeBytes(f4.dataSizeBytes() + 2);
780 BOOST_REQUIRE_EQUAL(f4.dataSize(), (payload_size + 2));
781 BOOST_REQUIRE_EQUAL(f4.dataSizeBytes(), ((payload_size + 2) *
sizeof(
artdaq::RawDataType)));
782 f4.resizeBytes(f4.dataSizeBytes() + 1);
783 BOOST_REQUIRE_EQUAL(f4.dataSize(), (payload_size + 3));
784 BOOST_REQUIRE_EQUAL(f4.dataSizeBytes(), ((payload_size + 3) *
sizeof(
artdaq::RawDataType)));
785 f4.resizeBytes(f4.dataSizeBytes() + 1);
786 BOOST_REQUIRE_EQUAL(f4.dataSize(), (payload_size + 4));
787 BOOST_REQUIRE_EQUAL(f4.dataSizeBytes(), ((payload_size + 4) *
sizeof(
artdaq::RawDataType)));
791 f4.resizeBytes(targetSize);
792 BOOST_REQUIRE_EQUAL(f4.dataSize(), (payload_size + 5));
793 BOOST_REQUIRE_EQUAL(f4.dataSizeBytes(), ((payload_size + 5) *
sizeof(
artdaq::RawDataType)));
795 f4.resizeBytes(targetSize);
796 BOOST_REQUIRE_EQUAL(f4.dataSize(), (payload_size + 5));
797 BOOST_REQUIRE_EQUAL(f4.dataSizeBytes(), ((payload_size + 5) *
sizeof(
artdaq::RawDataType)));
799 f4.resizeBytes(targetSize);
800 BOOST_REQUIRE_EQUAL(f4.dataSize(), (payload_size + 5));
801 BOOST_REQUIRE_EQUAL(f4.dataSizeBytes(), ((payload_size + 5) *
sizeof(
artdaq::RawDataType)));
803 f4.resizeBytes(targetSize);
804 BOOST_REQUIRE_EQUAL(f4.dataSize(), (payload_size + 5));
805 BOOST_REQUIRE_EQUAL(f4.dataSizeBytes(), ((payload_size + 5) *
sizeof(
artdaq::RawDataType)));
807 f4.resizeBytes(targetSize);
808 BOOST_REQUIRE_EQUAL(f4.dataSize(), (payload_size + 5));
809 BOOST_REQUIRE_EQUAL(f4.dataSizeBytes(), ((payload_size + 5) *
sizeof(
artdaq::RawDataType)));
811 f4.resizeBytes(targetSize);
812 BOOST_REQUIRE_EQUAL(f4.dataSize(), (payload_size + 5));
813 BOOST_REQUIRE_EQUAL(f4.dataSizeBytes(), ((payload_size + 5) *
sizeof(
artdaq::RawDataType)));
815 f4.resizeBytes(targetSize);
816 BOOST_REQUIRE_EQUAL(f4.dataSize(), (payload_size + 5));
817 BOOST_REQUIRE_EQUAL(f4.dataSizeBytes(), ((payload_size + 5) *
sizeof(
artdaq::RawDataType)));
819 f4.resizeBytes(targetSize);
820 BOOST_REQUIRE_EQUAL(f4.dataSize(), (payload_size + 5));
821 BOOST_REQUIRE_EQUAL(f4.dataSizeBytes(), ((payload_size + 5) *
sizeof(
artdaq::RawDataType)));
823 f4.resizeBytes(targetSize);
824 BOOST_REQUIRE_EQUAL(f4.dataSize(), (payload_size + 6));
825 BOOST_REQUIRE_EQUAL(f4.dataSizeBytes(), ((payload_size + 6) *
sizeof(
artdaq::RawDataType)));
831 f5.setMetadata(theMetadata);
832 BOOST_REQUIRE_EQUAL(f5.dataSize(), payload_size);
838 BOOST_AUTO_TEST_CASE(Upgrade_V0)
855 memcpy(f.headerBeginBytes(), &hdr0,
sizeof(hdr0));
860 memcpy(f.headerBegin() + ii, &(++counter),
sizeof(counter));
863 BOOST_REQUIRE_EQUAL(f.version(), 0);
864 BOOST_REQUIRE_EQUAL(f.type(), 0xFE);
865 BOOST_REQUIRE_EQUAL(f.hasMetadata(),
false);
867 BOOST_REQUIRE_EQUAL(f.sequenceID(), 0xFEEDDEADBEEF);
868 BOOST_REQUIRE_EQUAL(f.fragmentID(), 0xBEE7);
869 BOOST_REQUIRE_EQUAL(f.timestamp(), 0xCAFEFECA);
871 for (
size_t jj = 0; jj < f.dataSize(); ++jj)
873 BOOST_REQUIRE_EQUAL(*(f.dataBegin() + jj), jj + 1);
877 BOOST_AUTO_TEST_CASE(Upgrade_V1)
891 memcpy(f.headerBeginBytes(), &hdr1,
sizeof(hdr1));
896 memcpy(f.headerBegin() + ii, &(++counter),
sizeof(counter));
899 BOOST_REQUIRE_EQUAL(f.version(), 1);
900 BOOST_REQUIRE_EQUAL(f.type(), 0xFE);
901 BOOST_REQUIRE_EQUAL(f.hasMetadata(),
false);
903 BOOST_REQUIRE_EQUAL(f.sequenceID(), 0xFEEDDEADBEEF);
904 BOOST_REQUIRE_EQUAL(f.fragmentID(), 0xBEE7);
905 BOOST_REQUIRE_EQUAL(f.timestamp(), 0xCAFEFECAAAAABBBB);
907 for (
size_t jj = 0; jj < f.dataSize(); ++jj)
909 BOOST_REQUIRE_EQUAL(*(f.dataBegin() + jj), jj + 1);
913 BOOST_AUTO_TEST_SUITE_END()
static constexpr type_t InvalidFragmentType
Copy InvalidFragmentType from RawFragmentHeader.
void setSequenceID(sequence_id_t sequence_id)
Sets the Sequence ID of the Fragment.
std::size_t size() const
Gets the size of the Fragment, from the Fragment header.
detail::RawFragmentHeader::fragment_id_t fragment_id_t
typedef for fragment_id_t from RawFragmentHeader
std::size_t sizeBytes() const
Size of vals_ vector ( header + (optional) metadata + payload) in bytes.
detail::RawFragmentHeader::type_t type_t
typedef for type_t from RawFragmentHeader
sequence_id_t sequenceID() const
Sequence ID of the Fragment, from the Fragment header.
static constexpr type_t DataFragmentType
Copy DataFragmentType from RawFragmentHeader.
uint8_t byte_t
For byte representation.
void resize(std::size_t sz)
Resize the data payload to hold sz RawDataType words.
static constexpr fragment_id_t InvalidFragmentID
Copy InvalidFragmentID from RawFragmentHeader.
void setMetadata(const T &metadata)
Set the metadata in the Fragment to the contents of the specified structure. This throws an exception...
detail::RawFragmentHeader::version_t version_t
typedef for version_t from RawFragmentHeader
iterator headerBegin()
Return an iterator to the beginning of the header (should be used for serialization only: use setters...
iterator dataBegin()
Return an iterator to the beginning of the data payload (after header and metadata) ...
bool empty()
Determines if the Fragment contains no data.
static constexpr sequence_id_t InvalidSequenceID
Copy InvalidSequenceID from RawFragmentHeader.
void updateMetadata(const T &metadata)
Updates existing metadata with a new metadata object.
type_t type() const
Type of the Fragment, from the Fragment header.
RawDataType * dataAddress()
Returns a RawDataType pointer to the beginning of the payload.
T * metadata()
Return a pointer to the metadata. This throws an exception if the Fragment contains no metadata...
iterator dataEnd()
Return an iterator to the end of the data payload.
static FragmentPtr FragmentBytes(std::size_t nbytes)
Create a Fragment using a static factory function rather than a constructor to allow for the function...
detail::RawFragmentHeader::RawDataType RawDataType
The RawDataType (currently a 64-bit integer) is the basic unit of data representation within artdaq ...
RawDataType * metadataAddress()
Get the address of the metadata. For internal use only, use metadata() instead.
void clear()
Removes all elements from the payload section of the Fragment.
bool hasMetadata() const
Test whether this Fragment has metadata.
void setFragmentID(fragment_id_t fragment_id)
Sets the Fragment ID of the Fragment.
A Fragment contains the data from one piece of the DAQ system for one event The artdaq::Fragment is t...
std::size_t dataSize() const
Return the number of RawDataType words in the data payload. This does not include the number of words...
detail::RawFragmentHeader::sequence_id_t sequence_id_t
typedef for sequence_id_t from RawFragmentHeader
fragment_id_t fragmentID() const
Fragment ID of the Fragment, from the Fragment header.
RawDataType * headerAddress()
Gets the address of the header.
version_t version() const
Version of the Fragment, from the Fragment header.