MicroSliceWriter.hh
Go to the documentation of this file.
1 #ifndef dune_artdaq_Overlays_MicroSliceWriter_hh
2 #define dune_artdaq_Overlays_MicroSliceWriter_hh
3 
6 
7 namespace dune {
8  class MicroSliceWriter;
9 }
10 
12 
13 public:
14 
15  // This constructor creates an empty MicroSlice which can be filled
16  // with the appropriate data
17  MicroSliceWriter(uint8_t* address, uint32_t max_size_bytes);
18 
19  // Reserves the next NanoSlice in memory within this MicroSlice.
20  // The NanoSliceWriter that is returned is initialized to an empty
21  // state and is ready to be populated with data. If an additional
22  // NanoSlice cannot be reserved (for example if it would overflow
23  // the MicroSlice buffer), an empty shared_ptr is returned.
24  std::shared_ptr<NanoSliceWriter> reserveNanoSlice(uint32_t ns_max_bytes);
25 
26  // Finalizes the MicroSlice. This takes care of updating the
27  // MicroSlice so that all internal pointers and data are consistent
28  // with the NanoSlices that have been added. No more NanoSlices
29  // can be added once the MicroSlice has been finalized.
30  // This method returns the number of bytes that were reclaimed
31  // when the maximum size for this MicroSlice was reduced to match
32  // its actual current size.
33  int32_t finalize();
34 
35 protected:
36 
37  // finalizes the NanoSlice that was most recently added and
38  // updates our size to reflect any memory that was reclaimed
39  // by finalizing the NanoSlice
41 
42  // returns a pointer to the header
43  Header* header_();
44 
45  uint32_t max_size_bytes_;
46  std::shared_ptr<NanoSliceWriter> latest_nanoslice_ptr_;
47 };
48 
49 #endif /* dune_artdaq_Overlays_MicroSliceWriter_hh */
MicroSliceWriter(uint8_t *address, uint32_t max_size_bytes)
std::shared_ptr< NanoSliceWriter > latest_nanoslice_ptr_
std::shared_ptr< NanoSliceWriter > reserveNanoSlice(uint32_t ns_max_bytes)