6#ifndef ACTIVE_SERIALISE_XML_XML_POLYGON
7#define ACTIVE_SERIALISE_XML_XML_POLYGON
9#include "Active/Geometry/Polygon.h"
10#include "Active/Serialise/Package/Package.h"
11#include "Active/Serialise/Item/Wrapper/ValueWrap.h"
12#include "Active/Serialise/XML/Package/Wrapper/Geometry/XMLPolyPoint.h"
13#include "Active/Utility/String.h"
21 concept IsPolyPoint = std::is_base_of<geometry::PolyPoint, Vert>::value;
23 template<
class VertWrap>
24 concept IsPointWrap = std::is_base_of<XMLPolyPoint, VertWrap>::value;
39 using base = std::reference_wrapper<geometry::Polygon>;
84 using enum Entry::Type;
87 {
fieldID[topID], topID, attribute, (m_topID != 0) },
88 {
fieldID[vertex], vertex,
static_cast<uint32_t
>(get().size()), std::nullopt, (get().size() > 0) },
101 switch (item.
index) {
102 case FieldIndex::vertex:
103 return std::make_unique<VertWrap>((item.
available <
static_cast<uint32_t
>(get().vertSize())) ?
105 case FieldIndex::topID:
106 return std::make_unique<ValueWrap<geometry::vertex_id>>(m_topID);
125 base::get().setTopID(m_topID);
137 switch (item.
index) {
138 case FieldIndex::vertex:
139 base::get().emplace_back(m_vertex);
151 mutable Vert m_vertex;
153 mutable geometry::vertex_id m_topID = 0;
159 concept IsPolygon = std::is_base_of<geometry::Polygon, Hole>::value;
161 template<
class HoleWrap>
162 concept IsHoleWrap = std::is_base_of<XMLSolidPolygon<>, HoleWrap>::value;
171 template<
class Vert = geometry::PolyPoint,
class VertWrap = XMLPolyPoint,
172 class Hole = geometry::Polygon,
class HoleWrap = XMLSolidPolygon<Vert, VertWrap>>
223 {
fieldID[hole], hole,
static_cast<uint32_t
>(base::get().getHoleSize()), std::nullopt, (base::get().getHoleSize() > 0) },
236 switch (item.
index) {
237 case FieldIndex::hole:
238 return std::make_unique<HoleWrap>((item.
available <
static_cast<uint32_t
>(base::get().getHoleSize())) ?
256 switch (item.
index) {
257 case FieldIndex::hole:
258 base::get().emplaceHole(clone(m_hole));
vertex_id getTopID() const
Definition Polygon.h:283
std::unique_ptr< Cargo > Unique
Unique pointer.
Definition Cargo.h:23
Definition Inventory.h:19
Inventory & merge(const Inventory &inventory)
Definition Inventory.cpp:66
Definition XMLPolygon.h:174
static utility::String tag
The default element tag.
Definition XMLPolygon.h:190
virtual Cargo::Unique getCargo(const Inventory::Item &item) const override
Definition XMLPolygon.h:233
virtual bool insert(Cargo::Unique &&cargo, const Inventory::Item &item) override
Definition XMLPolygon.h:253
static std::array fieldID
Serialisation field IDs.
Definition XMLPolygon.h:193
FieldIndex
The package fields.
Definition XMLPolygon.h:183
XMLPolygon(const geometry::Polygon &polygon)
Definition XMLPolygon.h:203
XMLPolygon(const geometry::Polygon &polygon, const utility::String &customTag)
Definition XMLPolygon.h:209
virtual bool fillInventory(Inventory &inventory) const override
Definition XMLPolygon.h:219
Definition XMLPolygon.h:33
static std::array fieldID
Serialisation field IDs.
Definition XMLPolygon.h:53
virtual bool fillInventory(Inventory &inventory) const override
Definition XMLPolygon.h:83
XMLSolidPolygon(const geometry::Polygon &polygon, const utility::String &customTag)
Definition XMLPolygon.h:72
virtual Cargo::Unique getCargo(const Inventory::Item &item) const override
Definition XMLPolygon.h:98
virtual void setDefault() override
Definition XMLPolygon.h:117
virtual bool validate() override
Definition XMLPolygon.h:124
virtual bool insert(Cargo::Unique &&cargo, const Inventory::Item &item) override
Definition XMLPolygon.h:134
static utility::String tag
The default element tag.
Definition XMLPolygon.h:50
FieldIndex
Serialisation fields.
Definition XMLPolygon.h:42
XMLSolidPolygon(const geometry::Polygon &polygon)
Definition XMLPolygon.h:65
A Unicode-aware string class.
Definition String.h:51
std::optional< String > Option
Optional.
Definition String.h:63
Concept for classes derived from XMLSolidPolygon.
Definition XMLPolygon.h:162
Concept for classes derived from XMLPolyPoint.
Definition XMLPolygon.h:24
Concept for classes derived from PolyPoint.
Definition XMLPolygon.h:21
Concept for classes derived from Polygon.
Definition XMLPolygon.h:159
int32_t vertex_index
Index of a vertex, e.g. within a polygon.
Definition Point.h:22
int32_t part_index
Index of a part, e.g. a hole within a polygon.
Definition Point.h:26
Definition XMLDateTime.h:12
size_t available
How many are currently available (also acts as the requested item on import/export in 'getCargo')
Definition Entry.h:75
const std::type_info * ownerType
The type info of the owner package.
Definition Entry.h:73
int16_t index
The entry index.
Definition Entry.h:77