mf
Media Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ring.h
Go to the documentation of this file.
1 #ifndef MF_RING_H_
2 #define MF_RING_H_
3 
4 #include "../ndarray/generic/ndarray_generic.h"
5 #include "frame.h"
6 
7 namespace mf {
8 
10 
12 class ring : public ndarray_generic<raw_ring_allocator> {
14 
15 public:
17 
18 private:
19  time_unit read_position_ = 0;
20  time_unit write_position_ = 0;
21  bool full_ = false;
22 
23  static std::size_t adjust_padding_(const frame_array_properties&);
24  section_view_type section_(time_unit start, time_unit duration);
25 
26 public:
27  explicit ring(const frame_array_properties&);
28 
29  void initialize();
30 
31  time_unit total_duration() const noexcept { return base::shape().front(); }
32  time_unit frame_length() const noexcept { return base::shape().back(); }
33 
36 
38  void end_write(time_unit written_duration);
39 
41  void end_read(time_unit read_duration);
42 
43  void skip(time_unit duration);
44 };
45 
46 
47 }
48 
49 #endif
50 
Ring buffer.
Definition: ring.h:12
Generic ndarray_view where lower dimension(s) are type-erased.
Definition: ndarray_view_generic.h:25
std::ptrdiff_t time_unit
Discrete time unit type.
Definition: common.h:52
section_view_type begin_write(time_unit duration)
Definition: ring.cc:86
Array container with type erased multidimensional frames.
Definition: ndarray_generic.h:33
time_unit writable_duration() const
Definition: ring.cc:81
void skip(time_unit duration)
Definition: ring.cc:116
time_unit readable_duration() const
Definition: ring.cc:74
void end_read(time_unit read_duration)
Definition: ring.cc:108
pointer start() noexcept
Definition: ndarray.h:99
Properties for construction of ndarray_generic and derived container objects.
Definition: ndarray_generic.h:15
time_unit total_duration() const noexcept
Definition: ring.h:31
ring(const frame_array_properties &)
Definition: ring.cc:10
const shape_type & shape() const noexcept
Definition: ndarray.h:101
void end_write(time_unit written_duration)
Definition: ring.cc:93
time_unit frame_length() const noexcept
Definition: ring.h:32
ndarray_view_generic< 1 > frame_array_view
Definition: frame.h:11
frame_array_view section_view_type
Definition: ring.h:16
void initialize()
Definition: ring.cc:56
section_view_type begin_read(time_unit duration)
Definition: ring.cc:101