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