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 <vector>
3#include <sstream>
4#include <ostream>
5#include <memory>
6#include <utility>
7#include <stdexcept>
8#ifdef WEBCFACE_MESON
9#include "webcface-config.h"
10#else
11#include "webcface/common/webcface-config.h"
12#endif
13#include "robot_model.h"
14#include "components.h"
15
17namespace internal {
18template <typename Component>
19class DataSetBuffer;
20}
21
28class WEBCFACE_DLL Canvas3D : protected Field {
29 std::shared_ptr<internal::DataSetBuffer<TemporalCanvas3DComponent>> sb;
30
31 public:
32 Canvas3D();
33 Canvas3D(const Field &base);
34 Canvas3D(const Field &base, const SharedString &field)
35 : Canvas3D(Field{base, field}) {}
36
38 using Field::lastName;
39 using Field::member;
40 using Field::name;
41 using Field::nameW;
46 Canvas3D child(std::string_view field) const {
47 return this->Field::child(field);
48 }
53 Canvas3D child(std::wstring_view field) const {
54 return this->Field::child(field);
55 }
59 Canvas3D child(int index) const { return this->Field::child(index); }
64 Canvas3D operator[](std::string_view field) const { return child(field); }
69 Canvas3D operator[](std::wstring_view field) const { return child(field); }
74 Canvas3D operator[](const char *field) const { return child(field); }
78 Canvas3D operator[](const wchar_t *field) const { return child(field); }
83 Canvas3D operator[](int index) const { return child(index); }
88 Canvas3D parent() const { return this->Field::parent(); }
89
96 const Canvas3D &
97 onChange(std::function<void WEBCFACE_CALL_FP(Canvas3D)> callback) const;
104 template <typename F, typename std::enable_if_t<std::is_invocable_v<F>,
105 std::nullptr_t> = nullptr>
106 const Canvas3D &onChange(F callback) const {
107 return onChange(
108 [callback = std::move(callback)](const auto &) { callback(); });
109 }
117 template <typename T>
118 [[deprecated]] void appendListener(T &&callback) const {
119 onChange(std::forward<T>(callback));
120 }
121
127 const Canvas3D &request() const;
132 std::optional<std::vector<Canvas3DComponent>> tryGet() const;
137 std::vector<Canvas3DComponent> get() const {
138 return tryGet().value_or(std::vector<Canvas3DComponent>{});
139 }
148 bool exists() const;
149
154 [[deprecated]] std::chrono::system_clock::time_point time() const;
155
160 const Canvas3D &free() const;
161
170 const Canvas3D &init() const;
171
177
186 template <typename T>
187 const Canvas3D &add(T &&cc) const {
188 *this << std::forward<T>(cc);
189 return *this;
190 }
191
196 template <bool V, bool C2>
198 *this << std::move(cc.component_3d);
199 return *this;
200 }
201
209 const Canvas3D &sync() const;
210
216 template <typename T, typename std::enable_if_t<std::is_same_v<T, Canvas3D>,
217 std::nullptr_t> = nullptr>
218 bool operator==(const T &other) const {
219 return static_cast<Field>(*this) == static_cast<Field>(other);
220 }
221 template <typename T, typename std::enable_if_t<std::is_same_v<T, Canvas3D>,
222 std::nullptr_t> = nullptr>
223 bool operator!=(const T &other) const {
224 return static_cast<Field>(*this) != static_cast<Field>(other);
225 }
226};
Canvas3Dの送受信データを表すクラス
Definition canvas3d.h:28
Canvas3D(const Field &base, const SharedString &field)
Definition canvas3d.h:34
Canvas3D operator[](const wchar_t *field) const
Definition canvas3d.h:78
bool operator==(const T &other) const
Canvas3Dの参照先を比較
Definition canvas3d.h:218
Canvas3D operator[](std::string_view field) const
Definition canvas3d.h:64
const Canvas3D & onChange(F callback) const
値が変化したときに呼び出されるコールバックを設定
Definition canvas3d.h:106
Canvas3D child(std::wstring_view field) const
「(thisの名前).(追加の名前)」を新しい名前とするField (wstring)
Definition canvas3d.h:53
Canvas3D child(std::string_view field) const
「(thisの名前).(追加の名前)」を新しい名前とするField
Definition canvas3d.h:46
std::vector< Canvas3DComponent > get() const
Canvasの内容を取得する
Definition canvas3d.h:137
const Canvas3D & add(T &&cc) const
コンポーネントなどを追加
Definition canvas3d.h:187
Canvas3D operator[](std::wstring_view field) const
Definition canvas3d.h:69
Canvas3D parent() const
nameの最後のピリオドの前までを新しい名前とするField
Definition canvas3d.h:88
bool operator!=(const T &other) const
Definition canvas3d.h:223
const Canvas3D & operator<<(TemporalComponent< V, C2, true > cc) const
Geometryを追加
Definition canvas3d.h:197
void appendListener(T &&callback) const
Definition canvas3d.h:118
Canvas3D operator[](const char *field) const
Definition canvas3d.h:74
Canvas3D child(int index) const
Definition canvas3d.h:59
Canvas3D operator[](int index) const
Definition canvas3d.h:83
u8stringとstringとwstringをshared_ptrで持ち共有する
Definition encoding.h:69
Canvas3Dを構築するときに使う一時的なCanvas3DComponent.
Definition component_canvas3d.h:116
View,Canvasなどで送信用にaddされたデータを管理する
Definition data_buffer.h:17
std::ostream & operator<<(std::ostream &os, const Arg &arg)
Definition func_info.cc:96
ClientDataの参照とメンバ名とデータ名を持つクラス
Definition field.h:70
Field parent() const
nameの最後のピリオドの前までを新しい名前とするField
Definition field.cc:33
Field child(const SharedString &field) const
Definition field.cc:42
Canvas2D, Canvas3D (, View) に要素をaddするときに使うインタフェース
Definition components.h:22
TemporalCanvas3DComponent component_3d
Definition components.h:25
#define WEBCFACE_DLL
Definition webcface-config.h:60
#define WEBCFACE_NS_END
Definition webcface-config.h:104
#define WEBCFACE_NS_BEGIN
Definition webcface-config.h:103
#define WEBCFACE_CALL_FP
Definition webcface-config.h:98