MicroSlice.cc
Go to the documentation of this file.
2 
3 dune::MicroSlice::MicroSlice(uint8_t* address) : buffer_(address)
4 {
5 }
6 
8 {
9  return header_()->microslice_size;
10 }
11 
13 {
14  return header_()->nanoslice_count;
15 }
16 
17 std::unique_ptr<dune::NanoSlice> dune::MicroSlice::nanoSlice(uint32_t index) const
18 {
19  std::unique_ptr<NanoSlice> nslice_ptr;
20  if (index < nanoSliceCount()) {
21  uint8_t* ns_ptr = data_(index);
22  nslice_ptr.reset(new NanoSlice(ns_ptr));
23  }
24  return nslice_ptr;
25 }
26 
28 {
29  return reinterpret_cast<Header const *>(buffer_);
30 }
31 
32 uint8_t* dune::MicroSlice::data_(uint32_t index) const
33 {
34  uint8_t* ns_ptr = reinterpret_cast<uint8_t *>(buffer_ + sizeof(Header));
35  for (uint32_t idx = 0; idx < index; ++idx) {
36  NanoSlice tmp_ns(ns_ptr);
37  ns_ptr += tmp_ns.size();
38  }
39  return ns_ptr;
40 }
uint8_t * data_(uint32_t index) const
Definition: MicroSlice.cc:32
uint8_t * buffer_
Definition: MicroSlice.hh:53
MicroSlice(uint8_t *address)
Definition: MicroSlice.cc:3
Header::nanoslice_count_t nanoSliceCount() const
Definition: MicroSlice.cc:12
Header::microslice_size_t size() const
Definition: MicroSlice.cc:7
Header const * header_() const
Definition: MicroSlice.cc:27
Header::nanoslice_size_t size() const
Definition: NanoSlice.cc:5
std::unique_ptr< NanoSlice > nanoSlice(uint32_t index) const
Definition: MicroSlice.cc:17