1414#include < amulet/io/binary_reader.hpp>
1515#include < amulet/io/binary_writer.hpp>
1616
17+ #include < amulet/utils/view/map_view.hpp>
18+
1719#include < amulet/core/dll.hpp>
1820
1921namespace Amulet {
@@ -41,9 +43,10 @@ class IndexArray3D {
4143 AMULET_CORE_EXPORT static IndexArray3D deserialise (BinaryReader&);
4244
4345 const SectionShape& get_shape () const { return _shape; }
44- const size_t & get_size () const { return _size; }
45- std::uint32_t * get_buffer () const { return _buffer; }
46- std::span<std::uint32_t > get_span () const { return { _buffer, _size }; }
46+ size_t get_size () const { return _size; }
47+ std::uint32_t * get_buffer () { return _buffer; }
48+ const std::uint32_t * get_buffer () const { return _buffer; }
49+ std::span<std::uint32_t > get_span () { return { _buffer, _size }; }
4750};
4851
4952class SectionArrayMap {
@@ -84,18 +87,43 @@ class SectionArrayMap {
8487
8588 const SectionShape& get_array_shape () const { return _array_shape; }
8689
87- std::variant<std::uint32_t , std::shared_ptr<IndexArray3D>> get_default_array () const
90+ std::variant<std::uint32_t , std::shared_ptr<const IndexArray3D>> get_default_array () const
91+ {
92+ return std::visit (
93+ [](auto && arg) -> std::variant<std::uint32_t , std::shared_ptr<const IndexArray3D>> {
94+ return arg;
95+ },
96+ _default_array);
97+ }
98+
99+ std::variant<std::uint32_t , std::shared_ptr<IndexArray3D>> get_default_array ()
88100 {
89101 return _default_array;
90102 }
91103
92- void set_default_array (std::variant<std:: uint32_t , std::shared_ptr<IndexArray3D>> default_array)
104+ void set_default_array (std::uint32_t default_array)
93105 {
94- validate_array_shape (default_array);
106+ _default_array = default_array;
107+ }
108+
109+ void set_default_array (std::shared_ptr<IndexArray3D> default_array)
110+ {
111+ validate_array_shape (*default_array);
95112 _default_array = std::move (default_array);
96113 }
97114
98- const std::unordered_map<std::int64_t , std::shared_ptr<IndexArray3D>>& get_arrays () const
115+ void set_default_array (const IndexArray3D& default_array)
116+ {
117+ validate_array_shape (default_array);
118+ _default_array = std::make_shared<IndexArray3D>(default_array);
119+ }
120+
121+ const std::unordered_map<std::int64_t , std::shared_ptr<IndexArray3D>>& get_arrays ()
122+ {
123+ return _arrays;
124+ }
125+
126+ const MapView<std::unordered_map<std::int64_t , std::shared_ptr<IndexArray3D>>, std::shared_ptr<const IndexArray3D>> get_arrays () const
99127 {
100128 return _arrays;
101129 }
@@ -107,17 +135,38 @@ class SectionArrayMap {
107135 return _arrays.contains (cy);
108136 }
109137
110- std::shared_ptr<IndexArray3D> get_section (std::int64_t cy) const
138+ std::shared_ptr<IndexArray3D> get_section (std::int64_t cy)
111139 {
112140 return _arrays.at (cy);
113141 }
114142
143+ std::shared_ptr<const IndexArray3D> get_section (std::int64_t cy) const
144+ {
145+ return _arrays.at (cy);
146+ }
147+
148+ IndexArray3D& get_section_ref (std::int64_t cy)
149+ {
150+ return *_arrays.at (cy);
151+ }
152+
153+ const IndexArray3D& get_section_ref (std::int64_t cy) const
154+ {
155+ return *_arrays.at (cy);
156+ }
157+
115158 void set_section (std::int64_t cy, std::shared_ptr<IndexArray3D> section)
116159 {
117160 validate_array_shape (*section);
118161 _arrays.insert_or_assign (cy, std::move (section));
119162 }
120163
164+ void set_section (std::int64_t cy, const IndexArray3D& section)
165+ {
166+ validate_array_shape (section);
167+ _arrays.insert_or_assign (cy, std::make_shared<IndexArray3D>(section));
168+ }
169+
121170 AMULET_CORE_EXPORT void populate_section (std::int64_t cy);
122171
123172 void del_section (std::int64_t cy)
0 commit comments