OGLplus  (0.59.0) a C++ wrapper for rendering APIs

interface.hpp
Go to the documentation of this file.
1 
9 #ifndef EAGINE_VALUE_TREE_INTERFACE_HPP
10 #define EAGINE_VALUE_TREE_INTERFACE_HPP
11 
12 #include "../identifier_t.hpp"
13 #include "../interface.hpp"
14 #include "../reflect/map_enumerators.hpp"
15 #include "../string_path.hpp"
16 #include "../string_span.hpp"
17 #include "../tags.hpp"
18 #include <chrono>
19 #include <cstdint>
20 #include <memory>
21 #include <string>
22 
23 namespace eagine::valtree {
24 //------------------------------------------------------------------------------
27 enum class value_type {
29  unknown,
31  bool_type,
33  byte_type,
35  int16_type,
37  int32_type,
39  int64_type,
41  float_type,
47  composite
48 };
49 //------------------------------------------------------------------------------
50 template <typename Selector>
51 constexpr auto enumerator_mapping(type_identity<value_type>, Selector) noexcept {
52  return enumerator_map_type<value_type, 10>{
53  {{"unknown", value_type::unknown},
54  {"bool_type", value_type::bool_type},
55  {"byte_type", value_type::byte_type},
56  {"int16_type", value_type::int16_type},
57  {"int32_type", value_type::int32_type},
58  {"int64_type", value_type::int64_type},
59  {"float_type", value_type::float_type},
60  {"duration_type", value_type::duration_type},
61  {"string_type", value_type::string_type},
62  {"composite", value_type::composite}}};
63 }
64 //------------------------------------------------------------------------------
65 struct compound_interface;
66 
72 struct attribute_interface : interface<attribute_interface> {
73 
75  virtual auto type_id() const noexcept -> identifier_t = 0;
76 };
77 //------------------------------------------------------------------------------
83 struct compound_interface : interface<compound_interface> {
84 
86  virtual auto type_id() const noexcept -> identifier_t = 0;
87 
90  virtual void add_ref(attribute_interface& attr) noexcept = 0;
91 
94  virtual void release(attribute_interface& attr) noexcept = 0;
95 
97  virtual auto structure() -> attribute_interface* = 0;
98 
101  virtual auto attribute_name(attribute_interface& attr) -> string_view = 0;
102 
105  virtual auto canonical_type(attribute_interface& attr) -> value_type = 0;
106 
109  virtual auto is_link(attribute_interface& attr) -> bool = 0;
110 
113  virtual auto nested_count(attribute_interface& attr) -> span_size_t = 0;
114 
117  virtual auto nested(attribute_interface& attr, span_size_t index)
118  -> attribute_interface* = 0;
119 
122  virtual auto nested(attribute_interface&, string_view name)
123  -> attribute_interface* = 0;
124 
127  virtual auto find(attribute_interface& attr, const basic_string_path& path)
128  -> attribute_interface* {
129  return find(attr, path, {});
130  }
131 
134  virtual auto find(
135  attribute_interface& attr,
136  const basic_string_path&,
137  span<const string_view> tags) -> attribute_interface* = 0;
138 
141  virtual auto value_count(attribute_interface& attr) -> span_size_t = 0;
142 
144  virtual auto
145  fetch_values(attribute_interface&, span_size_t offset, span<bool> dest)
146  -> span_size_t = 0;
147 
149  virtual auto
150  fetch_values(attribute_interface&, span_size_t offset, span<char> dest)
151  -> span_size_t = 0;
152 
154  virtual auto
155  fetch_values(attribute_interface&, span_size_t offset, span<byte> dest)
156  -> span_size_t = 0;
157 
159  virtual auto fetch_values(
161  span_size_t offset,
162  span<std::int16_t> dest) -> span_size_t = 0;
163 
165  virtual auto fetch_values(
167  span_size_t offset,
168  span<std::int32_t> dest) -> span_size_t = 0;
169 
171  virtual auto fetch_values(
173  span_size_t offset,
174  span<std::int64_t> dest) -> span_size_t = 0;
175 
177  virtual auto fetch_values(
179  span_size_t offset,
180  span<std::uint16_t> dest) -> span_size_t = 0;
181 
183  virtual auto fetch_values(
185  span_size_t offset,
186  span<std::uint32_t> dest) -> span_size_t = 0;
187 
189  virtual auto fetch_values(
191  span_size_t offset,
192  span<std::uint64_t> dest) -> span_size_t = 0;
193 
195  virtual auto
196  fetch_values(attribute_interface&, span_size_t offset, span<float> dest)
197  -> span_size_t = 0;
198 
200  virtual auto fetch_values(
202  span_size_t offset,
203  span<std::chrono::duration<float>> dest) -> span_size_t = 0;
204 
206  virtual auto fetch_values(
208  span_size_t offset,
209  span<std::string> dest) -> span_size_t = 0;
210 };
211 //------------------------------------------------------------------------------
212 } // namespace eagine::valtree
213 
214 #endif // EAGINE_VALUE_TREE_INTERFACE_HPP
@ string_type
string value type.
value_type
Value tree value element data type enumeration.
Definition: interface.hpp:27
virtual auto fetch_values(attribute_interface &, span_size_t offset, span< bool > dest) -> span_size_t=0
Fetches boolean values from attribute into dest, starting at offset.
std::ptrdiff_t span_size_t
Signed span size type used by eagine.
Definition: types.hpp:36
@ int16_type
16-bit integer value type.
@ int32_type
32-bit integer value type.
@ byte_type
Byte/BLOB value type.
@ composite
composite structure type.
virtual auto nested(attribute_interface &attr, span_size_t index) -> attribute_interface *=0
Returns the nested attribute of an attribute at given index.
@ unknown
Unknown value type.
basic_span< T, T *, S > span
Default alias for basic memory spans with native pointer type.
Definition: span.hpp:415
Basic class storing paths made of string elements.
Definition: string_path.hpp:27
@ int64_type
64-bit integer value type.
Base template for abstract interfaces, implements common functionality.
Definition: interface.hpp:18
virtual auto attribute_name(attribute_interface &attr) -> string_view=0
Returns the name of the specified attribute.
virtual auto type_id() const noexcept -> identifier_t=0
Returns the implementation type identifier of this attribute.
virtual auto structure() -> attribute_interface *=0
Returns the root of attribute hierarch, describing the tree structure.
@ float_type
floating-point number value type.
Interface for value tree attribute implementations.
Definition: interface.hpp:72
virtual auto type_id() const noexcept -> identifier_t=0
Returns the implementation type identifier of this compound.
virtual auto is_link(attribute_interface &attr) -> bool=0
Indicates if the specified attribute is a reference or link in the tree.
@ bool_type
Boolean value type.
virtual void add_ref(attribute_interface &attr) noexcept=0
Add usage reference to the specified attribute.
virtual auto canonical_type(attribute_interface &attr) -> value_type=0
Returns the value type of the specified attribute.
std::uint64_t identifier_t
The underlying integer type for eagine::identifier.
Definition: identifier_t.hpp:19
Template type used mostly for function type-tag dispatching.
Definition: type_identity.hpp:19
@ duration_type
time duration value type.
Interface for value tree compound implementations.
Definition: interface.hpp:83
virtual void release(attribute_interface &attr) noexcept=0
Release usage reference to the specified attribute.
Value-tree code is placed in this namespace.
Definition: eagine.hpp:53
virtual auto value_count(attribute_interface &attr) -> span_size_t=0
Returns the count of individual values stored in an attribute.
virtual auto find(attribute_interface &attr, const basic_string_path &path) -> attribute_interface *
Finds the nested attribute of an attribute at the given path.
Definition: interface.hpp:127
virtual auto nested_count(attribute_interface &attr) -> span_size_t=0
Returns the count of nested attributes in an attribute.

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).