Wildmeshing Toolkit
Loading...
Searching...
No Matches
AttributeDescription.cpp
Go to the documentation of this file.
2#include <nlohmann/json.hpp>
3
5namespace wmtk::attribute {
6// TODO: this definitely will cause a conflict someday if someone else wants to serialize
7// attributetype
10 {
11 {AttributeType::Char, "char"},
12 {AttributeType::Double, "double"},
13 {AttributeType::Int64, "int"},
14 {AttributeType::Rational, "rational"},
15 })
16} // namespace wmtk::attribute
17
19auto AttributeDescription::operator<=>(const AttributeDescription&) const -> std::strong_ordering =
20 default;
21auto AttributeDescription::operator==(const AttributeDescription&) const -> bool = default;
22
23namespace {
24NLOHMANN_JSON_SERIALIZE_ENUM(
26 {
31 })
32} // namespace
34{
36 if (nlohmann_json_t.dimension.has_value()) {
37 nlohmann_json_j["dimension"] = nlohmann_json_t.dimension.value();
38 }
39 if (nlohmann_json_t.type.has_value()) {
40 nlohmann_json_j["type"] = nlohmann_json_t.type.value();
41 }
42}
44{
45 if (nlohmann_json_j.is_string()) {
46 nlohmann_json_t.path = nlohmann_json_j.get<std::string>();
47 } else {
48 nlohmann_json_t.path = nlohmann_json_j["path"];
49 }
50 if (nlohmann_json_j.contains("dimension")) {
51 nlohmann_json_t.dimension = nlohmann_json_j["dimension"];
52 }
53 if (nlohmann_json_j.contains("type")) {
54 nlohmann_json_t.type = nlohmann_json_j["type"];
55 }
56}
57
58std::optional<PrimitiveType> AttributeDescription::primitive_type() const
59{
60 if (this->dimension.has_value()) {
61 int8_t d = this->dimension.value();
62 assert(d < 4);
63
65 } else {
66 return {};
67 }
68}
69
70} // namespace wmtk::components::multimesh::utils
#define WMTK_NLOHMANN_ASSIGN_TYPE_TO_JSON(...)
#define WMTK_NLOHMANN_JSON_FRIEND_TO_JSON_PROTOTYPE(Type)
#define WMTK_NLOHMANN_JSON_FRIEND_FROM_JSON_PROTOTYPE(Type)
#define WMTK_NLOHMANN_JSON_SERIALIZE_ENUM(ENUM_TYPE,...)
constexpr PrimitiveType get_primitive_type_from_id(int8_t id)
Get the primitive type corresponding to its unique integer id.
auto operator==(const AttributeDescription &) const -> bool
auto operator<=>(const AttributeDescription &) const -> std::strong_ordering