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