Nix (Dev) 3.5.10
dev - 3.5.10 - 1af9301
Loading...
Searching...
No Matches
Groups.hpp
Go to the documentation of this file.
1#ifndef IV_SRC_MODEL_DIAMAR_GROUPS_HPP_
2#define IV_SRC_MODEL_DIAMAR_GROUPS_HPP_
3
5#include "model/structs.hpp"
6
7#include <map>
8#include <memory>
9#include <optional>
10#include <string>
11#include <vector>
12
13namespace iv::model::diamar
14{
15
16struct Group
17{
20 iv::model::LocalizedText longNames_, iv::model::LocalizedText description_);
21 Group(const Group &other);
22 Group(Group &&other) noexcept;
24
25 Group &operator=(const Group &other);
26 Group &operator=(Group &&other) noexcept;
27
34 bool load(const iv::file::xml::node &nodeGroup);
35 bool save(iv::file::xml::node &nodeGroup) const;
36
37 [[nodiscard]] std::string_view getName(iv::eLanguage language = iv::eLanguage::English) const;
38 [[nodiscard]] std::string_view getLongName(iv::eLanguage language = iv::eLanguage::English) const;
39 [[nodiscard]] std::string_view getDescription(iv::eLanguage language = iv::eLanguage::English) const;
40
45
47
48private:
49 struct Sections
50 {
51 static constexpr std::string_view names {"Names"};
52 static constexpr std::string_view longNames {"LongNames"};
53 static constexpr std::string_view descriptions {"Descriptions"};
54 static constexpr std::string_view name {"Name"};
55 static constexpr std::string_view longName {"LongName"};
56 static constexpr std::string_view description {"Description"};
57 };
58
59 struct Keys
60 {
61 static constexpr std::string_view id {"Id"};
62 static constexpr std::string_view groupIdForLom {"GroupIdForLom"};
63 };
64
66 {
67 static constexpr std::string string {};
69 static constexpr iv::types::groupId groupId {};
70 static constexpr uint8_t groupIdForLom {0};
71 };
72};
73
74struct Groups : std::map<iv::types::groupId, iv::model::diamar::Group>
75{
77 Groups(const Groups &other);
78 Groups(Groups &&other) noexcept;
80
81 Groups &operator=(const Groups &other);
82 Groups &operator=(Groups &&other) noexcept;
83
84 bool load(const iv::file::xml::node &rootNode);
85 bool save(iv::file::xml::node &rootNode) const;
86
87 [[nodiscard]] std::shared_ptr<iv::model::diamar::Groups> clone() const;
88
89 [[nodiscard]] std::vector<std::string_view> getGroupsNames(iv::eLanguage language);
90 [[nodiscard]] std::vector<iv::types::groupId> getGroupsIds() const;
91 [[nodiscard]] iv::model::diamar::Group &getGroupAt(uint64_t index);
92 [[nodiscard]] std::optional<std::reference_wrapper<iv::model::diamar::Group>>
93 getGroup(const iv::types::groupId &groupId);
96 [[nodiscard]] std::vector<Group> getGroupsOrderedByLomId() const;
97
98private:
99 struct Sections
100 {
101 static constexpr std::string_view groups {"Groups"};
102 static constexpr std::string_view group {"Group"};
103 };
104};
105
106}// namespace iv::model::diamar
107
108#endif//IV_SRC_MODEL_DIAMAR_GROUPS_HPP_
Definition xmlFile.hpp:15
Definition DiamarModel.cpp:14
std::uint8_t groupIdForLom
Definition types.hpp:81
std::string groupId
Definition types.hpp:70
eLanguage
Definition enums.hpp:37
Definition structs.hpp:29
static constexpr iv::eLanguage language
Definition Groups.hpp:68
static constexpr iv::types::groupId groupId
Definition Groups.hpp:69
static constexpr uint8_t groupIdForLom
Definition Groups.hpp:70
Definition Groups.hpp:60
static constexpr std::string_view groupIdForLom
Definition Groups.hpp:62
Definition Groups.hpp:50
static constexpr std::string_view names
Definition Groups.hpp:51
static constexpr std::string_view longNames
Definition Groups.hpp:52
static constexpr std::string_view descriptions
Definition Groups.hpp:53
static constexpr std::string_view description
Definition Groups.hpp:56
static constexpr std::string_view name
Definition Groups.hpp:54
static constexpr std::string_view longName
Definition Groups.hpp:55
Definition Groups.hpp:17
std::string_view getDescription(iv::eLanguage language=iv::eLanguage::English) const
Definition Groups.cpp:105
bool load(const iv::file::xml::node &nodeGroup)
Loads the group from the XML node.
Definition Groups.cpp:57
iv::model::LocalizedText longNames
Definition Groups.hpp:43
std::string_view getName(iv::eLanguage language=iv::eLanguage::English) const
Definition Groups.cpp:95
std::string_view getLongName(iv::eLanguage language=iv::eLanguage::English) const
Definition Groups.cpp:100
iv::types::groupIdForLom idForLom
Definition Groups.hpp:46
bool save(iv::file::xml::node &nodeGroup) const
Definition Groups.cpp:76
iv::model::LocalizedText names
Definition Groups.hpp:42
Group & operator=(const Group &other)
Definition Groups.cpp:29
Group(const Group &other)
iv::model::LocalizedText description
Definition Groups.hpp:44
Definition Groups.hpp:100
static constexpr std::string_view group
Definition Groups.hpp:102
static constexpr std::string_view groups
Definition Groups.hpp:101
Definition Groups.hpp:75
std::vector< iv::types::groupId > getGroupsIds() const
Definition Groups.cpp:211
bool save(iv::file::xml::node &rootNode) const
Definition Groups.cpp:170
std::optional< std::reference_wrapper< iv::model::diamar::Group > > getGroup(const iv::types::groupId &groupId)
Definition Groups.cpp:230
iv::types::groupIdForLom getFirstFreeLomId()
Definition Groups.cpp:249
bool load(const iv::file::xml::node &rootNode)
Definition Groups.cpp:148
Groups(Groups &&other) noexcept
Groups(const Groups &other)
std::shared_ptr< iv::model::diamar::Groups > clone() const
Definition Groups.cpp:187
std::vector< Group > getGroupsOrderedByLomId() const
Definition Groups.cpp:264
iv::model::diamar::Group getGroupByLomId(iv::types::groupIdForLom lomId)
Definition Groups.cpp:236
iv::model::diamar::Group & getGroupAt(uint64_t index)
Definition Groups.cpp:223
Groups & operator=(const Groups &other)
Definition Groups.cpp:118
std::vector< std::string_view > getGroupsNames(iv::eLanguage language)
Definition Groups.cpp:199