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

#include <MicroSliceWriter.hh>

Inheritance diagram for dune::MicroSliceWriter:
dune::MicroSlice

Public Member Functions

 MicroSliceWriter (uint8_t *address, uint32_t max_size_bytes)
 
std::shared_ptr< NanoSliceWriterreserveNanoSlice (uint32_t ns_max_bytes)
 
int32_t finalize ()
 
- Public Member Functions inherited from dune::MicroSlice
 MicroSlice (uint8_t *address)
 
Header::microslice_size_t size () const
 
Header::nanoslice_count_t nanoSliceCount () const
 
std::unique_ptr< NanoSlicenanoSlice (uint32_t index) const
 

Protected Member Functions

void finalizeLatestNanoSlice_ ()
 
Headerheader_ ()
 
- Protected Member Functions inherited from dune::MicroSlice
Header const * header_ () const
 
uint8_t * data_ (uint32_t index) const
 

Protected Attributes

uint32_t max_size_bytes_
 
std::shared_ptr< NanoSliceWriterlatest_nanoslice_ptr_
 
- Protected Attributes inherited from dune::MicroSlice
uint8_t * buffer_
 

Detailed Description

Definition at line 11 of file MicroSliceWriter.hh.

Constructor & Destructor Documentation

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

Definition at line 4 of file MicroSliceWriter.cc.

4  :
5  MicroSlice(address), max_size_bytes_(max_size_bytes)
6 {
7  header_()->version = 1;
8  header_()->microslice_size = sizeof(Header);
10 }
MicroSlice(uint8_t *address)
Definition: MicroSlice.cc:3

Member Function Documentation

int32_t dune::MicroSliceWriter::finalize ( )

Definition at line 33 of file MicroSliceWriter.cc.

34 {
35  // first, we need to finalize the last NanoSlice, in case that
36  // hasn't already been done
38 
39  // next, we update our maximum size so that no more NanoSlices
40  // can be added
41  int32_t size_diff = max_size_bytes_ - header_()->microslice_size;
43  return size_diff;
44 }
void dune::MicroSliceWriter::finalizeLatestNanoSlice_ ( )
protected

Definition at line 46 of file MicroSliceWriter.cc.

47 {
48  if (header_()->nanoslice_count > 0 &&
49  latest_nanoslice_ptr_.get() != 0) {
50  int size_change = latest_nanoslice_ptr_->finalize();
51  header_()->microslice_size -= size_change;
52  }
53 }
std::shared_ptr< NanoSliceWriter > latest_nanoslice_ptr_
dune::MicroSlice::Header * dune::MicroSliceWriter::header_ ( )
protected

Definition at line 55 of file MicroSliceWriter.cc.

56 {
57  return reinterpret_cast<Header *>(buffer_);
58 }
uint8_t * buffer_
Definition: MicroSlice.hh:53
std::shared_ptr< dune::NanoSliceWriter > dune::MicroSliceWriter::reserveNanoSlice ( uint32_t  ns_max_bytes)

Definition at line 13 of file MicroSliceWriter.cc.

14 {
15  // finalize the most recent NanoSlice, in case that hasn't
16  // already been done
18 
19  // test if this new NanoSlice could overflow our maximum size
20  if ((size() + ns_max_bytes) > max_size_bytes_) {
21  throw cet::exception("MicroSliceWriter") << "Slice overflow error";
22  }
23 
24  // create the next NanoSlice in our buffer, and update our
25  // counters to include the new NanoSlice
26  uint8_t* ns_ptr = data_(header_()->nanoslice_count);
27  latest_nanoslice_ptr_.reset(new NanoSliceWriter(ns_ptr, ns_max_bytes));
28  ++(header_()->nanoslice_count);
29  header_()->microslice_size += ns_max_bytes;
30  return latest_nanoslice_ptr_;
31 }
uint8_t * data_(uint32_t index) const
Definition: MicroSlice.cc:32
std::shared_ptr< NanoSliceWriter > latest_nanoslice_ptr_
Header::microslice_size_t size() const
Definition: MicroSlice.cc:7
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33

Member Data Documentation

std::shared_ptr<NanoSliceWriter> dune::MicroSliceWriter::latest_nanoslice_ptr_
protected

Definition at line 46 of file MicroSliceWriter.hh.

uint32_t dune::MicroSliceWriter::max_size_bytes_
protected

Definition at line 45 of file MicroSliceWriter.hh.


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