mf
Media Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ndarray_timed_view_generic.h
Go to the documentation of this file.
1 #ifndef MF_NDARRAY_TIMED_VIEW_GENERIC_H_
2 #define MF_NDARRAY_TIMED_VIEW_GENERIC_H_
3 
4 #include "ndarray_view_generic.h"
5 
6 namespace mf {
7 
8 // TODO reduce verbosity
9 
11 template<std::size_t Dim>
12 class ndarray_timed_view_generic : public ndarray_timed_view<Dim + 1, byte> {
14 
15 public:
16  using shape_type = typename base::shape_type;
17  using strides_type = typename base::strides_type;
18 
19 private:
20  frame_format format_;
21 
22 public:
25  base(vw), format_(format) { }
27  base(start_time), format_(format) { }
29  base(gen_vw, start_time), format_(gen_vw.format()) { }
30 
32 
33  operator ndarray_view_generic<Dim> () const noexcept
34  { return ndarray_view_generic<Dim>(*this, format_); }
35 
36  const frame_format& format() const noexcept { return format_; }
37 
38  decltype(auto) slice(std::ptrdiff_t c, std::ptrdiff_t dimension) const
39  { return ndarray_view_generic<Dim - 1>(base::slice(c, dimension), format_); }
40 
41  decltype(auto) operator[](std::ptrdiff_t c) const
42  { return ndarray_view_generic<Dim - 1>(base::operator[](c), format_); }
43 
44  decltype(auto) operator()(std::ptrdiff_t start, std::ptrdiff_t end, std::ptrdiff_t step = 1) const
45  { return ndarray_timed_view_generic(base::operator()(start, end, step), format_); }
46 
47  decltype(auto) operator()(std::ptrdiff_t c) const
48  { return ndarray_timed_view_generic(base::operator()(c), format_); }
49 
50  decltype(auto) operator()() const
51  { return ndarray_timed_view_generic(base::operator()(), format_); }
52 };
53 
54 
55 template<std::size_t Generic_dim, std::size_t Concrete_dim, typename Concrete_elem>
57  auto gen_vw = to_generic<Generic_dim>(static_cast<const ndarray_view<Concrete_dim, Concrete_elem>&>(vw));
59 }
60 
61 
62 
63 template<std::size_t Concrete_dim, typename Concrete_elem, std::size_t Generic_dim>
66  const ndsize<Concrete_dim - Generic_dim>& frame_shape
67 ) {
68  auto vw = from_generic<Concrete_dim, Concrete_elem, Generic_dim>(static_cast<ndarray_view_generic<Generic_dim>>(gen_vw), frame_shape);
70 }
71 
72 
73 
74 }
75 
76 #endif
Generic ndarray_view where lower dimension(s) are type-erased.
Definition: ndarray_view_generic.h:25
Mapping between coordinates, indices, and addresses of multi-dimensional data.
Definition: ndarray_view.h:16
ndarray_timed_view_generic(time_unit start_time, const frame_format &format)
Definition: ndarray_timed_view_generic.h:26
std::ptrdiff_t time_unit
Discrete time unit type.
Definition: common.h:52
static ndarray_timed_view_generic null()
Definition: ndarray_timed_view_generic.h:31
ndarray_timed_view_generic(const ndarray_view_generic< Dim > &gen_vw, time_unit start_time)
Definition: ndarray_timed_view_generic.h:28
ndsize< Dim > shape_type
Definition: ndarray_view.h:75
Ndarray view with absolute time indices associated to first dimension.
Definition: ndarray_timed_view.h:13
decltype(auto) operator[](std::ptrdiff_t c) const
Subscript operator, creates slice on first dimension.
Definition: ndarray_view.h:163
ndarray_timed_view_generic(const base &vw, const frame_format &format)
Definition: ndarray_timed_view_generic.h:24
ndarray_view< Dim-1, byte > slice(std::ptrdiff_t c, std::ptrdiff_t dimension) const
Create ndarray_view with one less dimension, by fixing coordinate of axis dimension to c...
typename base::strides_type strides_type
Definition: ndarray_timed_view_generic.h:17
ndarray_timed_view_generic()
Definition: ndarray_timed_view_generic.h:23
ndarray_timed_view_generic< Generic_dim > to_generic(const ndarray_timed_view< Concrete_dim, Concrete_elem > &vw)
Definition: ndarray_timed_view_generic.h:56
ndptrdiff< Dim > strides_type
Definition: ndarray_view.h:76
Vector of n-dimensional coordinates.
Definition: ndcoord.h:18
const frame_format & format() const noexcept
Definition: ndarray_timed_view_generic.h:36
Generic ndarray_timed_view where lower dimension(s) are type-erased.
Definition: ndarray_timed_view_generic.h:12
static constexpr std::size_t dimension
Definition: ndarray_view.h:81
time_unit start_time() const
Definition: ndarray_timed_view.h:33
pointer start() const noexcept
Definition: ndarray_view.h:199
Format information of type-erased frame of ndarray_view_generic.
Definition: frame_format.h:14
ndarray_timed_view< Concrete_dim, Concrete_elem > from_generic(const ndarray_timed_view_generic< Generic_dim > &gen_vw, const ndsize< Concrete_dim-Generic_dim > &frame_shape)
Definition: ndarray_timed_view_generic.h:64
decltype(auto) slice(std::ptrdiff_t c, std::ptrdiff_t dimension) const
Definition: ndarray_timed_view_generic.h:38
typename base::shape_type shape_type
Definition: ndarray_timed_view_generic.h:16