WebCFace 2.5.2
Web-based Communication Framework & Dashboard-like UI
Loading...
Searching...
No Matches
canvas2d.h
Go to the documentation of this file.
1#pragma once
2#include <memory>
3#ifdef WEBCFACE_MESON
4#include "webcface-config.h"
5#else
6#include "webcface/common/webcface-config.h"
7#endif
8#include "field.h"
9#include "components.h"
10
12namespace internal {
13template <typename Component>
14class DataSetBuffer;
15class Canvas2DDataBuf;
16} // namespace internal
17
24class WEBCFACE_DLL Canvas2D : protected Field {
25 std::shared_ptr<internal::Canvas2DDataBuf> sb;
26
27 public:
28 Canvas2D();
29 Canvas2D(const Field &base);
30 Canvas2D(const Field &base, const SharedString &field)
31 : Canvas2D(Field{base, field}) {}
32 Canvas2D(const Field &base, const SharedString &field, double width,
33 double height)
34 : Canvas2D(Field{base, field}) {
35 init(width, height);
36 }
37
39
40 using Field::lastName;
41 using Field::member;
42 using Field::name;
43 using Field::nameW;
48 Canvas2D child(std::string_view field) const {
49 return this->Field::child(field);
50 }
55 Canvas2D child(std::wstring_view field) const {
56 return this->Field::child(field);
57 }
61 Canvas2D child(int index) const { return this->Field::child(index); }
66 Canvas2D operator[](std::string_view field) const { return child(field); }
71 Canvas2D operator[](std::wstring_view field) const { return child(field); }
76 Canvas2D operator[](const char *field) const { return child(field); }
80 Canvas2D operator[](const wchar_t *field) const { return child(field); }
85 Canvas2D operator[](int index) const { return child(index); }
90 Canvas2D parent() const { return this->Field::parent(); }
91
98 const Canvas2D &
99 onChange(std::function<void WEBCFACE_CALL_FP(Canvas2D)> callback) const;
106 template <typename F, typename std::enable_if_t<std::is_invocable_v<F>,
107 std::nullptr_t> = nullptr>
108 const Canvas2D &onChange(F callback) const {
109 return onChange(
110 [callback = std::move(callback)](const auto &) { callback(); });
111 }
119 template <typename T>
120 [[deprecated]] void appendListener(T &&callback) const {
121 onChange(std::forward<T>(callback));
122 }
123
129 const Canvas2D &request() const;
134 std::optional<std::vector<Canvas2DComponent>> tryGet() const;
139 std::vector<Canvas2DComponent> get() const {
140 return tryGet().value_or(std::vector<Canvas2DComponent>{});
141 }
150 bool exists() const;
151
156 [[deprecated]] std::chrono::system_clock::time_point time() const;
157
162 const Canvas2D &free() const;
163
172 const Canvas2D &init(double width, double height) const;
173
182
191 template <typename T>
192 const Canvas2D &add(T &&cc) const {
193 *this << std::forward<T>(cc);
194 return *this;
195 }
201 template <bool V, bool C3>
203 *this << std::move(cc.component_2d);
204 return *this;
205 }
213 const Canvas2D &sync() const;
214
219 template <typename T, typename std::enable_if_t<std::is_same_v<T, Canvas2D>,
220 std::nullptr_t> = nullptr>
221 bool operator==(const T &other) const {
222 return static_cast<Field>(*this) == static_cast<Field>(other);
223 }
224 template <typename T, typename std::enable_if_t<std::is_same_v<T, Canvas2D>,
225 std::nullptr_t> = nullptr>
226 bool operator!=(const T &other) const {
227 return static_cast<Field>(*this) != static_cast<Field>(other);
228 }
229};
Canvas2Dの送受信データを表すクラス
Definition canvas2d.h:24
const Canvas2D & operator<<(TemporalComponent< V, true, C3 > cc) const
Geometryを追加
Definition canvas2d.h:202
Canvas2D operator[](const char *field) const
Definition canvas2d.h:76
Canvas2D child(std::wstring_view field) const
「(thisの名前).(追加の名前)」を新しい名前とするField (wstring)
Definition canvas2d.h:55
bool operator==(const T &other) const
Canvas2Dの参照先を比較
Definition canvas2d.h:221
const Canvas2D & onChange(F callback) const
値が変化したときに呼び出されるコールバックを設定
Definition canvas2d.h:108
const Canvas2D & add(T &&cc) const
コンポーネントなどを追加
Definition canvas2d.h:192
bool operator!=(const T &other) const
Definition canvas2d.h:226
Canvas2D operator[](const wchar_t *field) const
Definition canvas2d.h:80
Canvas2D operator[](int index) const
Definition canvas2d.h:85
Canvas2D operator[](std::string_view field) const
Definition canvas2d.h:66
void appendListener(T &&callback) const
Definition canvas2d.h:120
Canvas2D child(std::string_view field) const
「(thisの名前).(追加の名前)」を新しい名前とするField
Definition canvas2d.h:48
Canvas2D(const Field &base, const SharedString &field, double width, double height)
Definition canvas2d.h:32
std::vector< Canvas2DComponent > get() const
Canvasの内容を取得する
Definition canvas2d.h:139
Canvas2D operator[](std::wstring_view field) const
Definition canvas2d.h:71
Canvas2D(const Field &base, const SharedString &field)
Definition canvas2d.h:30
Canvas2D child(int index) const
Definition canvas2d.h:61
Canvas2D parent() const
nameの最後のピリオドの前までを新しい名前とするField
Definition canvas2d.h:90
u8stringとstringとwstringをshared_ptrで持ち共有する
Definition encoding.h:69
Definition component_canvas2d.h:137
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
TemporalCanvas2DComponent component_2d
Definition components.h:24
#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