WebCFace 2.5.2
Web-based Communication Framework & Dashboard-like UI
Loading...
Searching...
No Matches
data_store2.h
Go to the documentation of this file.
1#pragma once
2#include <deque>
3#include <mutex>
4#include <optional>
5#include "webcface/field.h"
6#include "webcface/log.h"
8
10namespace internal {
20template <typename T, typename ReqT = int>
26 StrMap1<T> data_send;
27 StrMap1<T> data_send_prev;
37 StrMap2<T> data_recv;
44 StrSet2 entry;
57 StrMap2<ReqT> req_info;
58
59 SharedString self_member_name;
60
61
62 public:
63 explicit SyncDataStore2(const SharedString &name);
64
65 std::recursive_mutex mtx;
66
67 bool isSelf(const SharedString &member) const;
68
78 unsigned int addReq(const SharedString &member, const SharedString &field);
90 unsigned int addReq(const SharedString &member, const SharedString &field,
91 const ReqT &req_info);
92
100 void setSend(const SharedString &name, const T &data);
101 void setSend(const FieldBase &base, const T &data);
102
107 void setRecv(const SharedString &from, const SharedString &name,
108 const T &data);
109 void setRecv(const FieldBase &base, const T &data);
114 void clearRecv(const SharedString &from, const SharedString &name);
115 void clearRecv(const FieldBase &base);
116
121 std::optional<T> getRecv(const SharedString &from,
122 const SharedString &name);
123 std::optional<T> getRecv(const FieldBase &base);
130 bool unsetRecv(const SharedString &from, const SharedString &name);
131 bool unsetRecv(const FieldBase &base);
132
138 void initMember(const SharedString &from);
143 void setEntry(const SharedString &from, const SharedString &e);
144
149 StrSet1 getEntry(const SharedString &from);
150 StrSet1 getEntry(const FieldBase &base);
151
156 std::pair<SharedString, SharedString> getReq(unsigned int req_id,
157 const SharedString &sub_field);
162 const ReqT &getReqInfo(const SharedString &member,
163 const SharedString &field);
164
169 StrMap1<T> transferSend(bool is_first);
170 StrMap1<T> getSendPrev(bool is_first);
171
176 StrMap2<unsigned int> transferReq();
177};
178
179struct FuncInfo;
180struct RobotLinkData;
181} // namespace internal
182class ImageFrame;
183namespace message {
184struct ViewData;
185struct Canvas2DData;
186struct Canvas3DData;
187struct ImageReq;
188} // namespace message
189namespace internal {
190using ValueData = std::vector<double>;
193using RobotModelData = std::vector<std::shared_ptr<internal::RobotLinkData>>;
195
196struct LogData {
197 std::deque<LogLineData> data;
198 std::size_t sent_lines = 0;
199
200 LogData() = default;
201 explicit LogData(const std::deque<LogLineData> &data) : data(data) {}
202
203 std::vector<LogLineData> getDiff() {
204 auto begin = data.cbegin() + static_cast<int>(sent_lines);
205 auto end = data.cend();
206 sent_lines = data.size();
207 return std::vector<LogLineData>(begin, end);
208 }
209 std::vector<LogLineData> getAll() {
210 sent_lines = data.size();
211 return std::vector<LogLineData>(data.cbegin(), data.cend());
212 }
213};
214
215#if WEBCFACE_SYSTEM_DLLEXPORT
216extern template class SyncDataStore2<std::string, int>; // test用
217extern template class SyncDataStore2<std::shared_ptr<ValueData>, int>;
218extern template class SyncDataStore2<std::shared_ptr<TextData>, int>;
219extern template class SyncDataStore2<std::shared_ptr<FuncData>, int>;
220extern template class SyncDataStore2<std::shared_ptr<message::ViewData>, int>;
221extern template class SyncDataStore2<std::shared_ptr<RobotModelData>, int>;
222extern template class SyncDataStore2<std::shared_ptr<message::Canvas3DData>,
223 int>;
224extern template class SyncDataStore2<std::shared_ptr<message::Canvas2DData>,
225 int>;
226extern template class SyncDataStore2<ImageData, message::ImageReq>;
227extern template class SyncDataStore2<std::shared_ptr<LogData>, int>;
228#endif
229
230} // namespace internal
(ver1.3から追加) 画像データ
Definition image_frame.h:101
u8stringとstringとwstringをshared_ptrで持ち共有する
Definition encoding.h:69
数値、文字列などの値を相互変換するクラス
Definition val_adaptor.h:87
送受信するデータを保持するクラス
Definition data_store2.h:21
std::recursive_mutex mtx
Definition data_store2.h:65
std::vector< double > ValueData
Definition data_store2.h:190
std::vector< std::shared_ptr< internal::RobotLinkData > > RobotModelData
Definition data_store2.h:193
std::map< SharedString, T > StrMap1
Definition encoding.h:110
StrMap1< StrSet1 > StrSet2
Definition encoding.h:114
StrMap1< StrMap1< T > > StrMap2
Definition encoding.h:112
std::set< SharedString > StrSet1
Definition encoding.h:113
メンバ名とデータ名を持つクラス
Definition field.h:37
関数1つの情報を表す。関数の実体も持つ
Definition func_internal.h:142
Definition data_store2.h:196
LogData(const std::deque< LogLineData > &data)
Definition data_store2.h:201
std::vector< LogLineData > getDiff()
Definition data_store2.h:203
std::deque< LogLineData > data
Definition data_store2.h:197
std::vector< LogLineData > getAll()
Definition data_store2.h:209
Definition robot_link_internal.h:16
#define WEBCFACE_NS_END
Definition webcface-config.h:104
#define WEBCFACE_NS_BEGIN
Definition webcface-config.h:103