1 #ifndef MF_NDARRAY_RING_H_
2 #define MF_NDARRAY_RING_H_
4 #include "../ndarray/generic/ndarray_view_generic.h"
5 #include "../ndarray/generic/ndarray_timed_view_generic.h"
15 template<std::
size_t Frame_dim,
typename Elem>
16 class ndarray_ring_base {
18 constexpr
static std::size_t concrete_dim = Frame_dim + 1;
19 using frame_shape_type = ndsize<Frame_dim>;
20 using frame_view_type = ndarray_view<Frame_dim, Elem>;
21 using section_view_type = ndarray_view<concrete_dim, Elem>;
24 frame_shape_type frame_shape_;
27 ndarray_generic_properties properties_(std::size_t duration)
const noexcept {
28 return ndarray_generic_properties(
29 frame_format::default_format<Elem>(),
30 frame_shape_.product(),
36 explicit ndarray_ring_base(
const frame_shape_type& shp) : frame_shape_(shp) { }
38 const frame_shape_type& frame_shape() const noexcept {
return frame_shape_; }
44 template<std::
size_t Frame_dim,
typename Elem>
46 using base = detail::ndarray_ring_base<Frame_dim, Elem>;
49 using base::concrete_dim;
56 ring(base::properties_(dur)) { }
59 return from_generic<concrete_dim, Elem>(
ring::begin_write(duration), base::frame_shape());
63 return from_generic<concrete_dim, Elem>(
ring::begin_read(duration), base::frame_shape());
69 template<std::
size_t Frame_dim,
typename Elem>
71 using base = detail::ndarray_ring_base<Frame_dim, Elem>;
74 using base::concrete_dim;
102 template<std::
size_t Frame_dim,
typename Elem>
104 using base = detail::ndarray_ring_base<Frame_dim, Elem>;
107 using base::concrete_dim;
123 section.
reset(from_generic<concrete_dim, Elem>(generic_section, base::frame_shape()));
141 section.
reset(from_generic<concrete_dim, Elem>(generic_section, base::frame_shape()));
Ring buffer.
Definition: ring.h:12
section_view_type begin_read_span(time_span)
Definition: timed_ring.cc:83
ndarray_shared_ring(const frame_shape_type &frame_shape, std::size_t dur, bool seekable, time_unit end_time=-1)
Definition: ndarray_ring.h:112
Mapping between coordinates, indices, and addresses of multi-dimensional data.
Definition: ndarray_view.h:16
section_view_type begin_read(time_unit)
Definition: timed_ring.cc:77
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
bool try_begin_read(time_unit read_duration, section_view_type §ion)
Definition: ndarray_ring.h:138
Ndarray view with absolute time indices associated to first dimension.
Definition: ndarray_timed_view.h:13
ndarray_timed_ring(const frame_shape_type &frame_shape, time_unit dur)
Definition: ndarray_ring.h:79
Shared ring wrapper with concrete frame type.
Definition: ndarray_ring.h:103
section_view_type begin_read_span(time_span span)
Definition: ndarray_ring.h:95
section_view_type begin_write_span(time_span)
Definition: timed_ring.cc:71
section_view_type begin_write(time_unit write_duration)
Definition: ndarray_ring.h:116
section_view_type begin_read_span(time_span)
Begin reading frames at time span span.
Definition: shared_ring.cc:142
section_view_type begin_read(time_unit read_duration)
Definition: ndarray_ring.h:134
section_view_type begin_read_span(time_span span)
Definition: ndarray_ring.h:130
section_view_type begin_write(time_unit)
Definition: timed_ring.cc:65
section_view_type begin_write(time_unit duration)
Definition: ndarray_ring.h:83
time_unit end_time() const
End of file time. */.
Definition: shared_ring.h:195
Timed ring wrapper with concrete frame type.
Definition: ndarray_ring.h:70
section_view_type begin_read(time_unit duration)
Definition: ndarray_ring.h:91
Timed ring buffer with changed semantics, for dual-thread use.
Definition: shared_ring.h:32
void reset(const ndarray_view &other) noexcept
Definition: ndarray_view.tcc:129
section_view_type begin_write(time_unit duration)
Definition: ndarray_ring.h:58
Vector of n-dimensional coordinates.
Definition: ndcoord.h:18
section_view_type begin_read(time_unit duration)
Definition: ndarray_ring.h:62
section_view_type begin_write_span(time_span span)
Definition: ndarray_ring.h:87
Ring buffer which adds absolute time index to frames.
Definition: timed_ring.h:13
section_view_type try_begin_read(time_unit read_duration)
Begin reading read_duration frames at current read start time, if they are available.
Definition: shared_ring.cc:206
One-dimensional time span.
Definition: common.h:61
Ring wrapper with concrete frame type.
Definition: ndarray_ring.h:45
bool try_begin_write(time_unit write_duration, section_view_type §ion)
Definition: ndarray_ring.h:120
section_view_type begin_write(time_unit write_duration)
Begin writing write_duration frames at current write start time.
Definition: shared_ring.cc:23
section_view_type try_begin_write(time_unit write_duration)
Begin writing write_duration frames at current write start time, if they are available.
Definition: shared_ring.cc:84
ndarray_ring(const frame_shape_type &frame_shape, time_unit dur)
Definition: ndarray_ring.h:54
Generic ndarray_timed_view where lower dimension(s) are type-erased.
Definition: ndarray_timed_view_generic.h:12
section_view_type begin_read(time_unit read_duration)
Begin reading read_duration frames at current read start time.
Definition: shared_ring.cc:161
section_view_type begin_read(time_unit duration)
Definition: ring.cc:101