PennMilliSliceWriter.hh
Go to the documentation of this file.
1 #ifndef dune_artdaq_Overlays_PennMilliSliceWriter_hh
2 #define dune_artdaq_Overlays_PennMilliSliceWriter_hh
3 
6 
7 namespace dune {
8  class PennMilliSliceWriter;
9 }
10 
12 
13 public:
14 
15  // This constructor creates an empty PennMilliSlice which can be filled
16  // with the appropriate data
17  PennMilliSliceWriter(uint8_t* address, uint32_t max_size_bytes);
18 
19  // Reserves the next MicroSlice in memory within this PennMilliSlice.
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  // PennMilliSlice).
25 #ifdef PENN_DONT_REBLOCK_USLICES
26  std::shared_ptr<PennMicroSliceWriter> reserveMicroSlice(uint32_t ms_max_bytes);
27 #endif
28 
29  // Finalizes the PennMilliSlice. This takes care of updating the
30  // PennMilliSlice so that all internal pointers and data are consistent
31  // with the MicroSlices that have been added. No more MicroSlices
32  // can be added once the PennMilliSlice has been finalized.
33  // This method returns the number of bytes that were reclaimed
34  // when the maximum size for this PennMilliSlice was reduced to match
35  // its actual current size.
36  int32_t finalize(bool override = false, uint32_t data_size_bytes = 0,
37 #ifdef PENN_DONT_REBLOCK_USLICES
38  uint32_t microslice_count = 0,
39 #endif
40  uint16_t sequence_id = 0,
41  uint16_t payload_count = 0, uint16_t payload_count_counter = 0,
42  uint16_t payload_count_trigger = 0, uint16_t payload_count_timestamp = 0,
43  uint64_t end_timestamp = 0, uint32_t width_in_ticks = 0, uint32_t overlap_in_ticks = 0);
44 
45 protected:
46 
47  // finalizes the MicroSlice that was most recently added and
48  // updates our size to reflect any memory that was reclaimed
49  // by finalizing the MicroSlice
51 
52  // returns a pointer to the header
53  Header* header_();
54 
55  // returns a pointer to the requested MicroSlice
56  uint8_t* data_(int index);
57 
58  uint32_t max_size_bytes_;
59  std::shared_ptr<PennMicroSliceWriter> latest_microslice_ptr_;
60 };
61 
62 #endif /* dune_artdaq_Overlays_PennMilliSliceWriter_hh */
PennMilliSliceWriter(uint8_t *address, uint32_t max_size_bytes)
int32_t finalize(bool override=false, uint32_t data_size_bytes=0, uint16_t sequence_id=0, uint16_t payload_count=0, uint16_t payload_count_counter=0, uint16_t payload_count_trigger=0, uint16_t payload_count_timestamp=0, uint64_t end_timestamp=0, uint32_t width_in_ticks=0, uint32_t overlap_in_ticks=0)
std::shared_ptr< PennMicroSliceWriter > latest_microslice_ptr_