WebCFace 3.1.1
Web-based Communication Framework & Dashboard-like UI
Loading...
Searching...
No Matches
robot_model.h
Go to the documentation of this file.
1#pragma once
2#ifdef WEBCFACE_MESON
3#include "webcface-config.h"
4#else
5#include "webcface/common/webcface-config.h"
6#endif
7#include "robot_link.h"
8#include "field.h"
9#include "components.h"
10
12namespace internal {
13template <typename Component>
14class DataSetBuffer;
15} // namespace internal
16
26class WEBCFACE_DLL RobotModel : protected Field {
27 std::shared_ptr<internal::DataSetBuffer<RobotLink>> sb;
28
29 public:
30 RobotModel();
31 RobotModel(const Field &base);
32 RobotModel(const Field &base, const SharedString &field)
33 : RobotModel(Field{base, field}) {}
34
35 friend class Canvas3D;
38
39 using Field::lastName;
40 using Field::lastNameW;
41 using Field::member;
42 using Field::name;
43 using Field::nameW;
52 return this->Field::child(static_cast<SharedString&>(field));
53 }
58 [[deprecated]]
59 RobotModel child(int index) const {
60 return this->Field::child(std::to_string(index));
61 }
69 RobotModel operator[](StringInitializer field) const { return child(std::move(field)); }
75 [[deprecated]]
76 RobotModel operator[](int index) const {
77 return child(std::to_string(index));
78 }
83 RobotModel parent() const { return this->Field::parent(); }
84
91 const RobotModel &
92 onChange(std::function<void WEBCFACE_CALL_FP(RobotModel)> callback) const;
99 template <typename F, typename std::enable_if_t<std::is_invocable_v<F>,
100 std::nullptr_t> = nullptr>
101 const RobotModel &onChange(F callback) const {
102 return onChange(
103 [callback = std::move(callback)](const auto &) { callback(); });
104 }
105
110 const RobotModel &init() const;
115 const RobotModel &operator<<(RobotLink rl) const;
120 template <typename T>
121 const RobotModel &add(T &&rl) const {
122 *this << std::forward<T>(rl);
123 return *this;
124 }
129 const RobotModel &sync() const;
130
135 const RobotModel &set(const std::vector<RobotLink> &v) const;
140 const RobotModel &operator=(const std::vector<RobotLink> &v) const {
141 this->set(v);
142 return *this;
143 }
149 const RobotModel &request() const;
154 std::optional<std::vector<RobotLink>> tryGet() const;
159 std::vector<RobotLink> get() const {
160 return tryGet().value_or(std::vector<RobotLink>{});
161 }
162 operator std::vector<RobotLink>() const { return get(); }
171 bool exists() const;
172
177 const RobotModel &free() const;
178
183 TemporalCanvas3DComponent toComponent3D() const;
189 return toComponent3D().origin(origin);
190 }
196 return toComponent3D().color(color);
197 }
202 template <typename... Args>
203 TemporalCanvas3DComponent angles(Args &&...args) const {
204 return toComponent3D().angles(std::forward<Args>(args)...);
205 }
206
211 template <typename T,
212 typename std::enable_if_t<std::is_same_v<T, RobotModel>,
213 std::nullptr_t> = nullptr>
214 bool operator==(const T &other) const {
215 return static_cast<Field>(*this) == static_cast<Field>(other);
216 }
217 template <typename T,
218 typename std::enable_if_t<std::is_same_v<T, RobotModel>,
219 std::nullptr_t> = nullptr>
220 bool operator!=(const T &other) const {
221 return static_cast<Field>(*this) != static_cast<Field>(other);
222 }
223};
224
Canvas3Dの送受信データを表すクラス
Definition canvas3d.h:28
RobotModelの送受信データを表すクラス
Definition robot_model.h:26
bool operator==(const T &other) const
RobotModelの参照先を比較
Definition robot_model.h:214
RobotModel operator[](StringInitializer field) const
Definition robot_model.h:69
RobotModel child(int index) const
Definition robot_model.h:59
RobotModel operator[](int index) const
Definition robot_model.h:76
TemporalCanvas3DComponent origin(const Transform &origin) const
Canvas3DComponentに変換 + 要素の移動
Definition robot_model.h:188
const RobotModel & onChange(F callback) const
値が変化したときに呼び出されるコールバックを設定
Definition robot_model.h:101
bool operator!=(const T &other) const
Definition robot_model.h:220
const RobotModel & operator=(const std::vector< RobotLink > &v) const
モデルをセットする
Definition robot_model.h:140
RobotModel child(StringInitializer field) const
「(thisの名前).(追加の名前)」を新しい名前とするField
Definition robot_model.h:51
TemporalCanvas3DComponent angles(Args &&...args) const
Canvas3DComponentに変換 + RobotModelの関節を設定
Definition robot_model.h:203
RobotModel(const Field &base, const SharedString &field)
Definition robot_model.h:32
RobotModel parent() const
nameの最後のピリオドの前までを新しい名前とするField
Definition robot_model.h:83
TemporalCanvas3DComponent color(ViewColor color) const
Canvas3DComponentに変換 + 色の指定
Definition robot_model.h:195
const RobotModel & add(T &&rl) const
モデルにlinkを追加
Definition robot_model.h:121
std::vector< RobotLink > get() const
モデルを返す
Definition robot_model.h:159
u8stringとstringとwstringをshared_ptrで持ち共有する
Definition encoding.h:170
SharedString のpublicなコンストラクタインタフェース (入力専用)
Definition encoding.h:235
Canvas3Dを構築するときに使う一時的なCanvas3DComponent.
Definition component_canvas3d.h:121
TemporalCanvas3DComponent & color(ViewColor color) &
Definition component_canvas3d.cc:97
TemporalCanvas3DComponent & origin(const Transform &origin) &
要素の移動
Definition component_canvas3d.cc:88
TemporalCanvas3DComponent & angles(const std::map< std::string, double, std::less<> > &angles) &
RobotModelの関節をまとめて設定
Definition component_canvas3d.cc:138
3次元の平行移動と回転
Definition transform.h:652
View,Canvasなどで送信用にaddされたデータを管理する
Definition data_buffer.h:17
std::ostream & operator<<(std::ostream &os, const Arg &arg)
Definition func_info.cc:99
ViewColor
Definition component_view.h:41
const auto & get(const AxisAngle &aa)
Definition transform.h:227
ClientDataの参照とメンバ名とデータ名を持つクラス
Definition field.h:68
Field parent() const
nameの最後のピリオドの前までを新しい名前とするField
Definition field.cc:39
Field child(const SharedString &field) const
Definition field.cc:48
#define WEBCFACE_DLL
Definition webcface-config.h:69
#define WEBCFACE_NS_END
Definition webcface-config.h:113
#define WEBCFACE_NS_BEGIN
Definition webcface-config.h:112
#define WEBCFACE_CALL_FP
Definition webcface-config.h:107