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

#include <NanoSliceWriter.hh>

Inheritance diagram for dune::NanoSliceWriter:
dune::NanoSlice

Public Member Functions

 NanoSliceWriter (uint8_t *address, uint32_t max_size_bytes, uint16_t channel_number=0)
 
void setChannelNumber (uint16_t channel)
 
bool addSample (uint16_t value)
 
int32_t finalize ()
 
- Public Member Functions inherited from dune::NanoSlice
 NanoSlice (uint8_t *address)
 
Header::nanoslice_size_t size () const
 
Header::channel_number_t channelNumber () const
 
Header::sample_count_t sampleCount () const
 
bool sampleValue (uint32_t index, uint16_t &value) const
 

Protected Member Functions

Headerheader_ ()
 
uint16_t * data_ ()
 
- Protected Member Functions inherited from dune::NanoSlice
Header const * header_ () const
 
uint16_t const * data_ () const
 

Protected Attributes

uint32_t max_size_bytes_
 
- Protected Attributes inherited from dune::NanoSlice
uint8_t * buffer_
 

Detailed Description

Definition at line 10 of file NanoSliceWriter.hh.

Constructor & Destructor Documentation

dune::NanoSliceWriter::NanoSliceWriter ( uint8_t *  address,
uint32_t  max_size_bytes,
uint16_t  channel_number = 0 
)

Definition at line 4 of file NanoSliceWriter.cc.

5  :
6  NanoSlice(address), max_size_bytes_(max_size_bytes)
7 {
8  header_()->version = 1;
9  header_()->nanoslice_size = sizeof(Header);
10  header_()->channel_number = channel_number;
11  header_()->sample_count = 0;
12 
13  if (max_size_bytes_ < size()) {
15  }
16 }
NanoSlice(uint8_t *address)
Definition: NanoSlice.cc:3
Header::nanoslice_size_t size() const
Definition: NanoSlice.cc:5

Member Function Documentation

bool dune::NanoSliceWriter::addSample ( uint16_t  value)

Definition at line 23 of file NanoSliceWriter.cc.

24 {
25  if ((size() + sizeof(value)) > max_size_bytes_) {
26  return false;
27  }
29  ++(header_()->sample_count);
30  header_()->nanoslice_size += sizeof(value);
31  return true;
32 }
Header::nanoslice_size_t size() const
Definition: NanoSlice.cc:5
uint16_t * dune::NanoSliceWriter::data_ ( )
protected

Definition at line 46 of file NanoSliceWriter.cc.

47 {
48  return reinterpret_cast<uint16_t *>(buffer_ + sizeof(Header));
49 }
uint8_t * buffer_
Definition: NanoSlice.hh:56
int32_t dune::NanoSliceWriter::finalize ( )

Definition at line 34 of file NanoSliceWriter.cc.

35 {
36  int32_t size_diff = max_size_bytes_ - header_()->nanoslice_size;
38  return size_diff;
39 }
dune::NanoSlice::Header * dune::NanoSliceWriter::header_ ( )
protected

Definition at line 41 of file NanoSliceWriter.cc.

42 {
43  return reinterpret_cast<Header *>(buffer_);
44 }
uint8_t * buffer_
Definition: NanoSlice.hh:56
void dune::NanoSliceWriter::setChannelNumber ( uint16_t  channel)

Definition at line 18 of file NanoSliceWriter.cc.

19 {
21 }
uint8_t channel
Definition: CRTFragment.hh:201

Member Data Documentation

uint32_t dune::NanoSliceWriter::max_size_bytes_
protected

Definition at line 45 of file NanoSliceWriter.hh.


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