MUDA
Loading...
Searching...
No Matches
field_builder.inl
1#include <vector_functions.hpp>
2#include <muda/ext/field/sub_field.h>
3
4namespace muda
5{
6template <FieldEntryLayout Layout>
7FieldBuilder<Layout>::~FieldBuilder()
8{
9 if(!m_is_built)
10 {
11 build();
12 }
13}
14
15template <FieldEntryLayout Layout>
16template <typename T>
17FieldEntry<T, Layout, 1, 1>& FieldBuilder<Layout>::EntryProxy::scalar() &&
18{
19 return m_builder.create_entry<T, 1, 1>(m_name, FieldEntryType::Scalar);
20}
21
22template <FieldEntryLayout Layout>
23template <typename T, int N>
24FieldEntry<T, Layout, N, 1>& FieldBuilder<Layout>::EntryProxy::vector() &&
25{
26 static_assert(N >= 2, "When N == 1, use scalar() instead");
27 return m_builder.create_entry<T, N, 1>(m_name, FieldEntryType::Vector);
28}
29
30template <FieldEntryLayout Layout>
31template <typename T>
32FieldEntry<T, Layout, 2, 1>& FieldBuilder<Layout>::EntryProxy::vector2() &&
33{
34 return std::move(*this).template vector<T, 2>();
35}
36
37template <FieldEntryLayout Layout>
38template <typename T>
39FieldEntry<T, Layout, 3, 1>& FieldBuilder<Layout>::EntryProxy::vector3() &&
40{
41 return std::move(*this).template vector<T, 3>();
42}
43template <FieldEntryLayout Layout>
44template <typename T>
45FieldEntry<T, Layout, 4, 1>& FieldBuilder<Layout>::EntryProxy::vector4() &&
46{
47 return std::move(*this).template vector<T, 4>();
48}
49
50template <FieldEntryLayout Layout>
51template <typename T, int M, int N>
52FieldEntry<T, Layout, M, N>& FieldBuilder<Layout>::EntryProxy::matrix() &&
53{
54 return m_builder.create_entry<T, M, N>(m_name, FieldEntryType::Matrix);
55}
56
57template <FieldEntryLayout Layout>
58template <typename T>
59FieldEntry<T, Layout, 2, 2>& FieldBuilder<Layout>::EntryProxy::matrix2x2() &&
60{
61 return std::move(*this).template matrix<T, 2, 2>();
62}
63
64template <FieldEntryLayout Layout>
65template <typename T>
66FieldEntry<T, Layout, 3, 3>& FieldBuilder<Layout>::EntryProxy::matrix3x3() &&
67{
68 return std::move(*this).template matrix<T, 3, 3>();
69}
70
71template <FieldEntryLayout Layout>
72template <typename T>
73FieldEntry<T, Layout, 4, 4>& FieldBuilder<Layout>::EntryProxy::matrix4x4() &&
74{
75 return std::move(*this).template matrix<T, 4, 4>();
76}
77
78template <FieldEntryLayout Layout>
79template <typename T, int M, int N>
80FieldEntry<T, Layout, M, N>& FieldBuilder<Layout>::create_entry(std::string_view name,
81 FieldEntryType type)
82{
83 return m_subfield.template create_entry<T, Layout, M, N>(
84 name, m_layout, type, make_uint2(static_cast<uint32_t>(M), static_cast<uint32_t>(N)));
85}
86
87template <FieldEntryLayout Layout>
88auto FieldBuilder<Layout>::entry(std::string_view name) -> EntryProxy
89{
90 MUDA_ASSERT(m_single_entry == false, "Named entry and Anonymous entry should not appear together!")
91 return EntryProxy{*this, name};
92}
93
94template <FieldEntryLayout Layout>
95auto FieldBuilder<Layout>::entry() -> EntryProxy
96{
97 MUDA_ASSERT(m_subfield.num_entries() == 0,
98 "Anonymous entry should be the only entry in a SubField!");
99 m_single_entry = true;
100 return EntryProxy{*this, m_subfield.name()};
101}
102
103template <FieldEntryLayout Layout>
105{
106 m_subfield.build(m_options);
107 m_is_built = true;
108}
109} // namespace muda
void build()
Finish building the field.
Definition field_builder.inl:104