WebCFace 2.5.2
Web-based Communication Framework & Dashboard-like UI
Loading...
Searching...
No Matches
field.h
Go to the documentation of this file.
1#pragma once
2#include <memory>
3#include <string>
4#include <string_view>
5#include <vector>
6#ifdef WEBCFACE_MESON
7#include "webcface-config.h"
8#else
9#include "webcface/common/webcface-config.h"
10#endif
12
14
15namespace internal {
16struct ClientData;
17}
18
19class Member;
20class Value;
21class Text;
22class View;
23class Image;
24class Func;
25class FuncListener;
26class RobotModel;
27class Canvas2D;
28class Canvas3D;
29class Log;
30
31constexpr char field_separator = '.';
32
43
51
52 FieldBase() = default;
53 explicit FieldBase(const SharedString &member)
54 : member_(member), field_() {}
55 FieldBase(const SharedString &member, const SharedString &field)
56 : member_(member), field_(field) {}
57 FieldBase(const FieldBase &base, const SharedString &field)
58 : member_(base.member_), field_(field) {}
59
60 bool operator==(const FieldBase &rhs) const {
61 return this->member_ == rhs.member_ && this->field_ == rhs.field_;
62 }
63 bool operator!=(const FieldBase &rhs) const { return !(*this == rhs); }
64};
65
70struct WEBCFACE_DLL Field : public FieldBase {
76 std::weak_ptr<internal::ClientData> data_w;
77
78 Field() = default;
79 Field(const std::weak_ptr<internal::ClientData> &data_w,
80 const SharedString &member)
81 : FieldBase(member), data_w(data_w) {}
82 Field(const std::weak_ptr<internal::ClientData> &data_w,
83 const SharedString &member, const SharedString &field)
84 : FieldBase(member, field), data_w(data_w) {}
85 Field(const Field &base, const SharedString &field)
86 : FieldBase(base, field), data_w(base.data_w) {}
87
92 std::shared_ptr<internal::ClientData> dataLock() const;
97 std::shared_ptr<internal::ClientData> setCheck() const;
98
99 bool expired() const;
100
105 Member member() const;
110 const std::string &name() const { return field_.decode(); }
115 const std::wstring &nameW() const { return field_.decodeW(); }
116
117 protected:
118 SharedString lastName8() const;
119
120 public:
121 Field child(const SharedString &field) const;
122
127 std::string lastName() const { return lastName8().decode(); }
132 std::wstring lastNameW() const { return lastName8().decodeW(); }
137 Field parent() const;
142 Field child(std::string_view field) const {
143 return child(SharedString::encode(field));
144 }
149 Field child(std::wstring_view field) const {
150 return child(SharedString::encode(field));
151 }
156 Field child(int index) const { return child(std::to_string(index)); }
161 Field operator[](std::string_view field) const { return child(field); }
166 Field operator[](std::wstring_view field) const { return child(field); }
171 Field operator[](int index) const { return child(index); }
172
173 Value value(std::string_view field = "") const;
174 Value value(std::wstring_view field) const;
175 Text text(std::string_view field = "") const;
176 Text text(std::wstring_view field) const;
177 RobotModel robotModel(std::string_view field = "") const;
178 RobotModel robotModel(std::wstring_view field) const;
179 Image image(std::string_view field = "") const;
180 Image image(std::wstring_view field) const;
181 Func func(std::string_view field = "") const;
182 Func func(std::wstring_view field) const;
183 FuncListener funcListener(std::string_view field) const;
184 FuncListener funcListener(std::wstring_view field) const;
185 View view(std::string_view field = "") const;
186 View view(std::wstring_view field) const;
187 Canvas3D canvas3D(std::string_view field = "") const;
188 Canvas3D canvas3D(std::wstring_view field) const;
189 Canvas2D canvas2D(std::string_view field = "") const;
190 Canvas2D canvas2D(std::wstring_view field) const;
194 Log log(std::string_view field = "") const;
198 Log log(std::wstring_view field) const;
199
200
201 std::vector<Value> valueEntries() const;
202 std::vector<Text> textEntries() const;
203 std::vector<RobotModel> robotModelEntries() const;
204 std::vector<Func> funcEntries() const;
205 std::vector<View> viewEntries() const;
206 std::vector<Canvas3D> canvas3DEntries() const;
207 std::vector<Canvas2D> canvas2DEntries() const;
208 std::vector<Image> imageEntries() const;
212 std::vector<Log> logEntries() const;
213
220 bool isSelf() const;
221
222 bool operator==(const Field &other) const;
223 bool operator!=(const Field &other) const { return !(*this == other); }
224};
Canvas2Dの送受信データを表すクラス
Definition canvas2d.h:24
Canvas3Dの送受信データを表すクラス
Definition canvas3d.h:28
Definition func.h:590
関数1つを表すクラス
Definition func.h:95
(ver1.3から追加) 画像の送受信データを表すクラス
Definition image.h:20
ログの送受信データを表すクラス
Definition log.h:65
Memberを指すクラス
Definition member.h:22
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
bool operator==(const T &other, const InputRef &ref)
Definition text.h:566
constexpr char field_separator
Definition field.h:31
メンバ名とデータ名を持つクラス
Definition field.h:37
bool operator==(const FieldBase &rhs) const
Definition field.h:60
SharedString member_
メンバー名
Definition field.h:42
FieldBase(const SharedString &member)
Definition field.h:53
bool operator!=(const FieldBase &rhs) const
Definition field.h:63
FieldBase(const SharedString &member, const SharedString &field)
Definition field.h:55
SharedString field_
フィールド名
Definition field.h:50
FieldBase(const FieldBase &base, const SharedString &field)
Definition field.h:57
ClientDataの参照とメンバ名とデータ名を持つクラス
Definition field.h:70
const std::string & name() const
field名を返す
Definition field.h:110
Field(const std::weak_ptr< internal::ClientData > &data_w, const SharedString &member, const SharedString &field)
Definition field.h:82
Field child(int index) const
「(thisの名前).(index)」を新しい名前とするField
Definition field.h:156
Field child(std::wstring_view field) const
「(thisの名前).(追加の名前)」を新しい名前とするField (wstring)
Definition field.h:149
Field(const std::weak_ptr< internal::ClientData > &data_w, const SharedString &member)
Definition field.h:79
Field child(std::string_view field) const
「(thisの名前).(追加の名前)」を新しい名前とするField
Definition field.h:142
Field operator[](int index) const
「(thisの名前).(index)」を新しい名前とするField
Definition field.h:171
Field(const Field &base, const SharedString &field)
Definition field.h:85
bool operator!=(const Field &other) const
Definition field.h:223
const std::wstring & nameW() const
field名を返す (wstring)
Definition field.h:115
std::string lastName() const
nameのうちピリオドで区切られた最後の部分を取り出す
Definition field.h:127
Field()=default
std::weak_ptr< internal::ClientData > data_w
ClientDataの参照
Definition field.h:76
std::wstring lastNameW() const
nameのうちピリオドで区切られた最後の部分を取り出す (wstring)
Definition field.h:132
Field operator[](std::wstring_view field) const
「(thisの名前).(追加の名前)」を新しい名前とするField (wstring)
Definition field.h:166
Field operator[](std::string_view field) const
「(thisの名前).(追加の名前)」を新しい名前とするField
Definition field.h:161
#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