WebCFace 2.9.0
Web-based Communication Framework & Dashboard-like UI
Loading...
Searching...
No Matches
canvas3d.h
Go to the documentation of this file.
1#pragma once
2#include "./base.h"
4#include <map>
5#include <optional>
6#include <unordered_map>
7#include <vector>
8#include <array>
9
10#ifndef MSGPACK_DEFINE_MAP
11#define MSGPACK_DEFINE_MAP(...)
12#endif
13
15namespace message {
16
18 int type = 0;
19 std::array<double, 3> origin_pos, origin_rot;
20 int color = 0;
21 std::optional<int> geometry_type;
22 std::vector<double> geometry_properties;
23 std::optional<SharedString> field_member, field_field;
24 std::map<std::string, double> angles;
26 bool operator==(const Canvas3DComponentData &other) const {
27 return type == other.type && origin_pos == other.origin_pos &&
28 origin_rot == other.origin_rot && color == other.color &&
29 geometry_type == other.geometry_type &&
30 geometry_properties == other.geometry_properties &&
31 field_member == other.field_member &&
32 field_field == other.field_field && angles == other.angles;
33 }
34 bool operator!=(const Canvas3DComponentData &other) const {
35 return !(*this == other);
36 }
37 MSGPACK_DEFINE_MAP(MSGPACK_NVP("t", type), MSGPACK_NVP("op", origin_pos),
38 MSGPACK_NVP("or", origin_rot), MSGPACK_NVP("c", color),
39 MSGPACK_NVP("gt", geometry_type),
40 MSGPACK_NVP("gp", geometry_properties),
41 MSGPACK_NVP("fm", field_member),
42 MSGPACK_NVP("ff", field_field), MSGPACK_NVP("a", angles))
43};
45 std::map<std::string, std::shared_ptr<Canvas3DComponentData>> components;
46 std::vector<SharedString> data_ids;
47 Canvas3DData() = default;
48};
49struct Canvas3D : public MessageBase<MessageKind::canvas3d> {
51 std::map<std::string, std::shared_ptr<Canvas3DComponentData>> data_diff;
52 std::optional<std::vector<SharedString>> data_ids;
53 Canvas3D() = default;
55 const SharedString &field,
56 std::map<std::string, std::shared_ptr<Canvas3DComponentData>> data_diff,
57 std::optional<std::vector<SharedString>> data_ids)
58 : field(field), data_diff(std::move(data_diff)),
59 data_ids(std::move(data_ids)) {}
60 MSGPACK_DEFINE_MAP(MSGPACK_NVP("f", field), MSGPACK_NVP("d", data_diff),
61 MSGPACK_NVP("l", data_ids))
62};
63struct Canvas3DOld : public MessageBase<MessageKind::canvas3d_old> {
65 std::map<std::string, std::shared_ptr<Canvas3DComponentData>> data_diff;
66 std::size_t length = 0;
67 Canvas3DOld() = default;
69 const SharedString &field,
70 const std::unordered_map<int, std::shared_ptr<Canvas3DComponentData>>
71 &data_diff,
72 std::size_t length)
73 : field(field), data_diff(), length(length) {
74 for (const auto &vc : data_diff) {
75 this->data_diff.emplace(std::to_string(vc.first), vc.second);
76 }
77 }
79 const SharedString &field,
80 const std::map<std::string, std::shared_ptr<Canvas3DComponentData>>
81 &data_diff,
82 std::size_t length)
83 : field(field), data_diff(data_diff), length(length) {}
84 MSGPACK_DEFINE_MAP(MSGPACK_NVP("f", field), MSGPACK_NVP("d", data_diff),
85 MSGPACK_NVP("l", length))
86};
87template <>
89 : public MessageBase<MessageKind::canvas3d + MessageKind::res> {
90 unsigned int req_id = 0;
92 std::map<std::string, std::shared_ptr<Canvas3DComponentData>> data_diff;
93 std::optional<std::vector<SharedString>> data_ids;
94 Res() = default;
95 Res(unsigned int req_id, const SharedString &sub_field,
96 const std::map<std::string, std::shared_ptr<Canvas3DComponentData>>
97 &data_diff,
98 const std::optional<std::vector<SharedString>> &data_ids)
99 : req_id(req_id), sub_field(sub_field), data_diff(data_diff),
100 data_ids(data_ids) {}
101 MSGPACK_DEFINE_MAP(MSGPACK_NVP("i", req_id), MSGPACK_NVP("f", sub_field),
102 MSGPACK_NVP("d", data_diff), MSGPACK_NVP("l", data_ids))
103};
104template <>
106 : public MessageBase<MessageKind::canvas3d_old + MessageKind::res> {
107 unsigned int req_id = 0;
109 std::map<std::string, std::shared_ptr<Canvas3DComponentData>> data_diff;
110 std::size_t length = 0;
111 Res() = default;
112 Res(unsigned int req_id, const SharedString &sub_field,
113 const std::map<std::string, std::shared_ptr<Canvas3DComponentData>>
114 &data_diff,
115 std::size_t length)
116 : req_id(req_id), sub_field(sub_field), data_diff(data_diff),
117 length(length) {}
118 MSGPACK_DEFINE_MAP(MSGPACK_NVP("i", req_id), MSGPACK_NVP("f", sub_field),
119 MSGPACK_NVP("d", data_diff), MSGPACK_NVP("l", length))
120};
121
122} // namespace message
124
126WEBCFACE_MESSAGE_FMT(webcface::message::Res<webcface::message::Canvas3D>)
127WEBCFACE_MESSAGE_FMT(webcface::message::Entry<webcface::message::Canvas3D>)
128WEBCFACE_MESSAGE_FMT(webcface::message::Req<webcface::message::Canvas3D>)
129WEBCFACE_MESSAGE_FMT(webcface::message::Canvas3DOld)
130WEBCFACE_MESSAGE_FMT(webcface::message::Res<webcface::message::Canvas3DOld>)
131WEBCFACE_MESSAGE_FMT(webcface::message::Entry<webcface::message::Canvas3DOld>)
132WEBCFACE_MESSAGE_FMT(webcface::message::Req<webcface::message::Canvas3DOld>)
#define MSGPACK_DEFINE_MAP(...)
Definition base.h:11
u8stringとstringとwstringをshared_ptrで持ち共有する
Definition encoding.h:67
#define WEBCFACE_MESSAGE_FMT(Type)
Definition fmt.h:21
Definition arg.h:14
std::array< double, 3 > origin_rot
Definition canvas3d.h:19
std::optional< SharedString > field_field
Definition canvas3d.h:23
int color
Definition canvas3d.h:20
std::array< double, 3 > origin_pos
Definition canvas3d.h:19
std::optional< SharedString > field_member
Definition canvas3d.h:23
bool operator==(const Canvas3DComponentData &other) const
Definition canvas3d.h:26
std::optional< int > geometry_type
Definition canvas3d.h:21
int type
Definition canvas3d.h:18
std::map< std::string, double > angles
Definition canvas3d.h:24
bool operator!=(const Canvas3DComponentData &other) const
Definition canvas3d.h:34
std::vector< double > geometry_properties
Definition canvas3d.h:22
Definition canvas3d.h:44
std::map< std::string, std::shared_ptr< Canvas3DComponentData > > components
Definition canvas3d.h:45
std::vector< SharedString > data_ids
Definition canvas3d.h:46
Definition canvas3d.h:63
Canvas3DOld(const SharedString &field, const std::map< std::string, std::shared_ptr< Canvas3DComponentData > > &data_diff, std::size_t length)
Definition canvas3d.h:78
SharedString field
Definition canvas3d.h:64
Canvas3DOld(const SharedString &field, const std::unordered_map< int, std::shared_ptr< Canvas3DComponentData > > &data_diff, std::size_t length)
Definition canvas3d.h:68
std::map< std::string, std::shared_ptr< Canvas3DComponentData > > data_diff
Definition canvas3d.h:65
Definition canvas3d.h:49
std::optional< std::vector< SharedString > > data_ids
Definition canvas3d.h:52
Canvas3D(const SharedString &field, std::map< std::string, std::shared_ptr< Canvas3DComponentData > > data_diff, std::optional< std::vector< SharedString > > data_ids)
Definition canvas3d.h:54
SharedString field
Definition canvas3d.h:50
std::map< std::string, std::shared_ptr< Canvas3DComponentData > > data_diff
Definition canvas3d.h:51
型からkindを取得するためだけのベースクラス
Definition base.h:60
SharedString sub_field
Definition canvas3d.h:108
std::map< std::string, std::shared_ptr< Canvas3DComponentData > > data_diff
Definition canvas3d.h:109
Res(unsigned int req_id, const SharedString &sub_field, const std::map< std::string, std::shared_ptr< Canvas3DComponentData > > &data_diff, std::size_t length)
Definition canvas3d.h:112
std::optional< std::vector< SharedString > > data_ids
Definition canvas3d.h:93
Res(unsigned int req_id, const SharedString &sub_field, const std::map< std::string, std::shared_ptr< Canvas3DComponentData > > &data_diff, const std::optional< std::vector< SharedString > > &data_ids)
Definition canvas3d.h:95
SharedString sub_field
Definition canvas3d.h:91
std::map< std::string, std::shared_ptr< Canvas3DComponentData > > data_diff
Definition canvas3d.h:92
Definition base.h:65
#define WEBCFACE_NS_END
Definition webcface-config.h:118
#define WEBCFACE_NS_BEGIN
Definition webcface-config.h:117