WebCFace 2.5.2
Web-based Communication Framework & Dashboard-like UI
Loading...
Searching...
No Matches
member.h
Go to the documentation of this file.
1#pragma once
2#include <string>
3#include <vector>
4#include <optional>
5#include "field.h"
6#ifdef WEBCFACE_MESON
7#include "webcface-config.h"
8#else
9#include "webcface/common/webcface-config.h"
10#endif
11#include "webcface/log.h"
12
14
22class WEBCFACE_DLL Member : protected Field {
23 public:
24 Member() = default;
25 Member(const std::weak_ptr<internal::ClientData> &data_w,
26 const SharedString &member)
27 : Field(data_w, member) {}
28 Member(const Field &base) : Field(base.data_w, base.member_) {}
29
30 friend struct internal::ClientData;
31
36 const std::string &name() const { return member_.decode(); }
41 const std::wstring &nameW() const { return member_.decodeW(); }
42
43 using Field::child;
44 using Field::operator[];
45
46 using Field::canvas2D;
47 using Field::canvas3D;
48 using Field::func;
49 using Field::funcListener;
50 using Field::image;
51 using Field::robotModel;
52 using Field::text;
53 using Field::value;
54 using Field::view;
55
59 Log log(std::string_view name) const { return this->Field::log(name); }
63 Log log(std::wstring_view name) const { return this->Field::log(name); }
68 Log log() const;
69
70 using Field::canvas2DEntries;
71 using Field::canvas3DEntries;
72 using Field::funcEntries;
73 using Field::imageEntries;
74 using Field::logEntries;
75 using Field::robotModelEntries;
76 using Field::textEntries;
77 using Field::valueEntries;
78 using Field::viewEntries;
84 [[deprecated]] std::vector<Value> values() const;
89 [[deprecated]] std::vector<Text> texts() const;
95 [[deprecated]] std::vector<RobotModel> robotModels() const;
101 [[deprecated]] std::vector<Func> funcs() const;
106 [[deprecated]] std::vector<View> views() const;
111 [[deprecated]] std::vector<Image> images() const;
112
119 const Member &
120 onValueEntry(std::function<void WEBCFACE_CALL_FP(Value)> callback) const;
127 const Member &
128 onTextEntry(std::function<void WEBCFACE_CALL_FP(Text)> callback) const;
135 const Member &onRobotModelEntry(
136 std::function<void WEBCFACE_CALL_FP(RobotModel)> callback) const;
143 const Member &
144 onFuncEntry(std::function<void WEBCFACE_CALL_FP(Func)> callback) const;
151 const Member &
152 onImageEntry(std::function<void WEBCFACE_CALL_FP(Image)> callback) const;
159 const Member &
160 onViewEntry(std::function<void WEBCFACE_CALL_FP(View)> callback) const;
167 const Member &onCanvas3DEntry(
168 std::function<void WEBCFACE_CALL_FP(Canvas3D)> callback) const;
175 const Member &onCanvas2DEntry(
176 std::function<void WEBCFACE_CALL_FP(Canvas2D)> callback) const;
183 const Member &
184 onLogEntry(std::function<void WEBCFACE_CALL_FP(Log)> callback) const;
185
192 const Member &
193 onSync(std::function<void WEBCFACE_CALL_FP(Member)> callback) const;
200 template <typename F, typename std::enable_if_t<std::is_invocable_v<F>,
201 std::nullptr_t> = nullptr>
202 const Member &onSync(F callback) const {
203 return onSync(
204 [callback = std::move(callback)](const auto &) { callback(); });
205 }
206
212 std::chrono::system_clock::time_point syncTime() const;
220 const std::string &libName() const;
225 const std::string &libVersion() const;
230 const std::string &remoteAddr() const;
231
243 std::optional<int> pingStatus() const;
255 const Member &
256 onPing(std::function<void WEBCFACE_CALL_FP(Member)> callback) const;
263 template <typename F, typename std::enable_if_t<std::is_invocable_v<F>,
264 std::nullptr_t> = nullptr>
265 const Member &onPing(F callback) const {
266 return onPing(
267 [callback = std::move(callback)](const auto &) { callback(); });
268 }
269
274 template <typename T, typename std::enable_if_t<std::is_same_v<T, Member>,
275 std::nullptr_t> = nullptr>
276 bool operator==(const T &other) const {
277 return static_cast<Field>(*this) == static_cast<Field>(other);
278 }
279 template <typename T, typename std::enable_if_t<std::is_same_v<T, Member>,
280 std::nullptr_t> = nullptr>
281 bool operator!=(const T &other) const {
282 return static_cast<Field>(*this) != static_cast<Field>(other);
283 }
284};
285
Canvas2Dの送受信データを表すクラス
Definition canvas2d.h:24
Canvas3Dの送受信データを表すクラス
Definition canvas3d.h:28
関数1つを表すクラス
Definition func.h:95
(ver1.3から追加) 画像の送受信データを表すクラス
Definition image.h:20
ログの送受信データを表すクラス
Definition log.h:65
Memberを指すクラス
Definition member.h:22
Member()=default
bool operator==(const T &other) const
Memberを比較
Definition member.h:276
const std::string & name() const
Member名
Definition member.h:36
Log log(std::string_view name) const
Definition member.h:59
const std::wstring & nameW() const
Member名 (wstring)
Definition member.h:41
bool operator!=(const T &other) const
Definition member.h:281
const Member & onSync(F callback) const
Memberがsync()したときのイベント
Definition member.h:202
Member(const std::weak_ptr< internal::ClientData > &data_w, const SharedString &member)
Definition member.h:25
Log log(std::wstring_view name) const
Definition member.h:63
Member(const Field &base)
Definition member.h:28
const Member & onPing(F callback) const
通信速度が更新された時のイベント
Definition member.h:265
RobotModelの送受信データを表すクラス
Definition robot_model.h:26
u8stringとstringとwstringをshared_ptrで持ち共有する
Definition encoding.h:69
文字列の送受信データを表すクラス
Definition text.h:183
実数値またはその配列の送受信データを表すクラス
Definition value.h:23
Viewの送受信データを表すクラス
Definition view.h:26
ClientDataの参照とメンバ名とデータ名を持つクラス
Definition field.h:70
Log log(std::string_view field="") const
Definition field.cc:80
Definition client_internal.h:35
#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