Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
dune::MilliSliceWriter Class Reference

#include <MilliSliceWriter.hh>

Inheritance diagram for dune::MilliSliceWriter:
dune::MilliSlice

Public Member Functions

 MilliSliceWriter (uint8_t *address, uint32_t max_size_bytes)
 
std::shared_ptr< MicroSliceWriterreserveMicroSlice (uint32_t ms_max_bytes)
 
int32_t finalize ()
 
- Public Member Functions inherited from dune::MilliSlice
 MilliSlice (uint8_t *address)
 
Header::millislice_size_t size () const
 
Header::microslice_count_t microSliceCount () const
 
std::unique_ptr< MicroSlicemicroSlice (uint32_t index) const
 

Protected Member Functions

void finalizeLatestMicroSlice_ ()
 
Headerheader_ ()
 
uint8_t * data_ (int index)
 
- Protected Member Functions inherited from dune::MilliSlice
Header const * header_ () const
 
uint8_t * data_ (int index) const
 

Protected Attributes

uint32_t max_size_bytes_
 
std::shared_ptr< MicroSliceWriterlatest_microslice_ptr_
 
- Protected Attributes inherited from dune::MilliSlice
uint8_t * buffer_
 

Detailed Description

Definition at line 11 of file MilliSliceWriter.hh.

Constructor & Destructor Documentation

dune::MilliSliceWriter::MilliSliceWriter ( uint8_t *  address,
uint32_t  max_size_bytes 
)

Definition at line 5 of file MilliSliceWriter.cc.

5  :
6  MilliSlice(address), max_size_bytes_(max_size_bytes)
7 {
8  header_()->version = 1;
9  header_()->millislice_size = sizeof(Header);
11 }
MilliSlice(uint8_t *address)
Definition: MilliSlice.cc:3

Member Function Documentation

uint8_t * dune::MilliSliceWriter::data_ ( int  index)
protected

Definition at line 61 of file MilliSliceWriter.cc.

62 {
63  uint8_t* ms_ptr = buffer_ + sizeof(Header);
64  for (int idx = 0; idx < index; ++idx) {
65  MicroSlice tmp_ms(ms_ptr);
66  ms_ptr += tmp_ms.size();
67  }
68  return ms_ptr;
69 }
uint8_t * buffer_
Definition: MilliSlice.hh:56
int32_t dune::MilliSliceWriter::finalize ( )

Definition at line 34 of file MilliSliceWriter.cc.

35 {
36  // first, we need to finalize the last MicroSlice, in case that
37  // hasn't already been done
39 
40  // next, we update our maximum size so that no more MicroSlices
41  // can be added
42  int32_t size_diff = max_size_bytes_ - header_()->millislice_size;
44  return size_diff;
45 }
void dune::MilliSliceWriter::finalizeLatestMicroSlice_ ( )
protected

Definition at line 47 of file MilliSliceWriter.cc.

48 {
49  if (header_()->microslice_count > 0 &&
50  latest_microslice_ptr_.get() != 0) {
51  int size_change = latest_microslice_ptr_->finalize();
52  header_()->millislice_size -= size_change;
53  }
54 }
std::shared_ptr< MicroSliceWriter > latest_microslice_ptr_
dune::MilliSliceWriter::Header * dune::MilliSliceWriter::header_ ( )
protected

Definition at line 56 of file MilliSliceWriter.cc.

57 {
58  return reinterpret_cast<Header *>(buffer_);
59 }
uint8_t * buffer_
Definition: MilliSlice.hh:56
std::shared_ptr< dune::MicroSliceWriter > dune::MilliSliceWriter::reserveMicroSlice ( uint32_t  ms_max_bytes)

Definition at line 14 of file MilliSliceWriter.cc.

15 {
16  // finalize the most recent MicroSlice, in case that hasn't
17  // already been done
19 
20  // test if this new MicroSlice could overflow our maximum size
21  if ((size() + ms_max_bytes) > max_size_bytes_) {
22  throw cet::exception("MilliSliceWriter") << "Slice overflow error";
23  }
24 
25  // create the next MicroSlice in our buffer, and update our
26  // counters to include the new MicroSlice
27  uint8_t* ms_ptr = data_(header_()->microslice_count);
28  latest_microslice_ptr_.reset(new MicroSliceWriter(ms_ptr, ms_max_bytes));
30  header_()->millislice_size += ms_max_bytes;
32 }
uint8_t * data_(int index)
std::shared_ptr< MicroSliceWriter > latest_microslice_ptr_
Header::millislice_size_t size() const
Definition: MilliSlice.cc:7
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33

Member Data Documentation

std::shared_ptr<MicroSliceWriter> dune::MilliSliceWriter::latest_microslice_ptr_
protected

Definition at line 50 of file MilliSliceWriter.hh.

uint32_t dune::MilliSliceWriter::max_size_bytes_
protected

Definition at line 49 of file MilliSliceWriter.hh.


The documentation for this class was generated from the following files: