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(); }
54 artdaq::Fragment& artdaq_Fragment_;
61 ots::DataGenFragmentWriter::DataGenFragmentWriter(artdaq::Fragment& f)
64 if(!f.hasMetadata() || f.dataSizeBytes() > 0)
67 "Error in DataGenFragmentWriter: Raw artdaq::Fragment "
68 "object does not appear to consist of (and only of) "
69 "its own header + the DataGenFragment::Metadata "
74 artdaq_Fragment_.resizeBytes(
sizeof(Header));
80 assert(artdaq_Fragment_.dataSizeBytes() >=
81 sizeof(Header) +
sizeof(artdaq::Fragment::value_type));
82 return reinterpret_cast<DataBlob*
>(header_() + 1);
87 return dataBegin() + artdaq_Fragment_.dataSize() /
sizeof(DataBlob);
90 inline void ots::DataGenFragmentWriter::resize(
size_t nBytes)
92 artdaq_Fragment_.resizeBytes(nBytes);