1 #ifndef artdaq_ots_Overlays_DataGenFragmentWriter_hh
2 #define artdaq_ots_Overlays_DataGenFragmentWriter_hh
17 #include "artdaq-core/Data/Fragment.hh"
18 #include "otsdaq-demo/Overlays/DataGenFragment.hh"
24 class DataGenFragmentWriter;
43 assert(artdaq_Fragment_.dataSizeBytes() >=
sizeof(
Header));
44 return reinterpret_cast<Header*
>(artdaq_Fragment_.dataBeginBytes());
47 void resize(
size_t nBytes);
49 int asksize() {
return artdaq_Fragment_.dataSizeBytes(); }
53 artdaq::Fragment& artdaq_Fragment_;
60 ots::DataGenFragmentWriter::DataGenFragmentWriter(artdaq::Fragment& f)
63 if(!f.hasMetadata() || f.dataSizeBytes() > 0)
66 "Error in DataGenFragmentWriter: Raw artdaq::Fragment object does not appear "
67 "to consist of (and only of) its own header + the DataGenFragment::Metadata "
72 artdaq_Fragment_.resizeBytes(
sizeof(Header));
78 assert(artdaq_Fragment_.dataSizeBytes() >=
79 sizeof(Header) +
sizeof(artdaq::Fragment::value_type));
80 return reinterpret_cast<DataBlob*
>(header_() + 1);
85 return dataBegin() + artdaq_Fragment_.dataSize() /
sizeof(DataBlob);
88 inline void ots::DataGenFragmentWriter::resize(
size_t nBytes)
90 artdaq_Fragment_.resizeBytes(nBytes);