WebCFace 2.5.2
Web-based Communication Framework & Dashboard-like UI
Loading...
Searching...
No Matches
func.h
Go to the documentation of this file.
1#pragma once
2#include "./base.h"
5#include <optional>
6#include <vector>
7
8#ifndef MSGPACK_DEFINE_MAP
9#define MSGPACK_DEFINE_MAP(...)
10#endif
11
13namespace message {
14
23struct Call : public MessageBase<MessageKind::call> {
24 using CallerId = std::size_t;
25 using MemberId = unsigned int;
26
27 CallerId caller_id = 0;
28 MemberId caller_member_id = 0;
29 MemberId target_member_id = 0;
31 std::vector<webcface::ValAdaptor> args;
32 Call() = default;
33 Call(CallerId caller_id, MemberId caller_member_id,
34 MemberId target_member_id, const SharedString &field,
35 const std::vector<ValAdaptor> &args)
36 : message::MessageBase<MessageKind::call>(), caller_id(caller_id),
37 caller_member_id(caller_member_id),
38 target_member_id(target_member_id), field(field), args(args) {}
39 MSGPACK_DEFINE_MAP(MSGPACK_NVP("i", caller_id),
40 MSGPACK_NVP("c", caller_member_id),
41 MSGPACK_NVP("r", target_member_id),
42 MSGPACK_NVP("f", field), MSGPACK_NVP("a", args))
43};
55struct CallResponse : public MessageBase<MessageKind::call_response> {
56 std::size_t caller_id;
57 unsigned int caller_member_id;
58 bool started;
59 MSGPACK_DEFINE_MAP(MSGPACK_NVP("i", caller_id),
60 MSGPACK_NVP("c", caller_member_id),
61 MSGPACK_NVP("s", started))
62};
75struct CallResult : public MessageBase<MessageKind::call_result> {
76 std::size_t caller_id;
77 unsigned int caller_member_id;
80 MSGPACK_DEFINE_MAP(MSGPACK_NVP("i", caller_id),
81 MSGPACK_NVP("c", caller_member_id),
82 MSGPACK_NVP("e", is_error), MSGPACK_NVP("r", result))
83};
84
91struct Arg {
93 ValType type_ = ValType::none_;
94 std::optional<ValAdaptor> init_ = std::nullopt;
95 std::optional<double> min_ = std::nullopt, max_ = std::nullopt;
96 std::vector<ValAdaptor> option_;
97 Arg() = default;
98 Arg(const SharedString &name, ValType type,
99 const std::optional<ValAdaptor> &init, const std::optional<double> &min_,
100 const std::optional<double> &max_, const std::vector<ValAdaptor> &option)
101 : name_(name), type_(type), init_(init), min_(min_), max_(max_),
102 option_(option) {}
103 MSGPACK_DEFINE_MAP(MSGPACK_NVP("n", name_), MSGPACK_NVP("t", type_),
104 MSGPACK_NVP("i", init_), MSGPACK_NVP("m", min_),
105 MSGPACK_NVP("x", max_), MSGPACK_NVP("o", option_))
106};
107struct FuncInfo : public MessageBase<MessageKind::func_info> {
108 unsigned int member_id = 0;
111 std::vector<std::shared_ptr<Arg>> args;
112 FuncInfo() = default;
113 FuncInfo(unsigned int member_id, const SharedString &field,
114 ValType return_type, const std::vector<std::shared_ptr<Arg>> &args)
115 : member_id(member_id), field(field), return_type(return_type),
116 args(args) {}
117 MSGPACK_DEFINE_MAP(MSGPACK_NVP("m", member_id), MSGPACK_NVP("f", field),
118 MSGPACK_NVP("r", return_type), MSGPACK_NVP("a", args))
119};
120
121}
u8stringとstringとwstringをshared_ptrで持ち共有する
Definition encoding.h:69
数値、文字列などの値を相互変換するクラス
Definition val_adaptor.h:87
#define MSGPACK_DEFINE_MAP(...)
Definition canvas2d.h:10
ValType
引数や戻り値の型を表すenum
Definition val_adaptor.h:21
client(member)->server->client func登録
Definition func.h:91
Arg(const SharedString &name, ValType type, const std::optional< ValAdaptor > &init, const std::optional< double > &min_, const std::optional< double > &max_, const std::vector< ValAdaptor > &option)
Definition func.h:98
SharedString name_
Definition func.h:92
std::vector< ValAdaptor > option_
Definition func.h:96
関数呼び出しの応答1 (client(receiver)->server->client(caller))
Definition func.h:55
unsigned int caller_member_id
Definition func.h:57
std::size_t caller_id
Definition func.h:56
bool started
関数の実行を開始したかどうか
Definition func.h:58
関数呼び出しの応答2 (client(receiver)->server->client(caller))
Definition func.h:75
unsigned int caller_member_id
Definition func.h:77
std::size_t caller_id
Definition func.h:76
ValAdaptor result
Definition func.h:79
bool is_error
Definition func.h:78
関数呼び出し (client(caller)->server->client(receiver))
Definition func.h:23
std::vector< webcface::ValAdaptor > args
Definition func.h:31
std::size_t CallerId
Definition func.h:24
Call(CallerId caller_id, MemberId caller_member_id, MemberId target_member_id, const SharedString &field, const std::vector< ValAdaptor > &args)
Definition func.h:33
SharedString field
Definition func.h:30
unsigned int MemberId
Definition func.h:25
Definition func.h:107
ValType return_type
Definition func.h:110
SharedString field
Definition func.h:109
FuncInfo(unsigned int member_id, const SharedString &field, ValType return_type, const std::vector< std::shared_ptr< Arg > > &args)
Definition func.h:113
std::vector< std::shared_ptr< Arg > > args
Definition func.h:111
型からkindを取得するためだけのベースクラス
Definition base.h:53
#define WEBCFACE_NS_END
Definition webcface-config.h:104
#define WEBCFACE_NS_BEGIN
Definition webcface-config.h:103