17 #include "llvm/ArrayRef.h"
18 #include "llvm/StringRef.h"
25 using llvm::StringRef;
44 std::string remote_id;
45 std::string remote_ip;
46 unsigned int remote_port;
47 unsigned long long last_update;
48 unsigned int protocol_version;
54 RpcParamDef(StringRef name_, std::shared_ptr<Value> def_value_)
55 : name(name_), def_value(def_value_) {}
58 std::shared_ptr<Value> def_value;
64 RpcResultDef(StringRef name_, NT_Type type_) : name(name_), type(type_) {}
74 std::vector<RpcParamDef> params;
75 std::vector<RpcResultDef> results;
81 unsigned int call_uid;
97 std::shared_ptr<Value> GetEntryValue(StringRef name);
108 bool SetDefaultEntryValue(StringRef name, std::shared_ptr<Value> value);
118 bool SetEntryValue(StringRef name, std::shared_ptr<Value> value);
131 void SetEntryTypeValue(StringRef name, std::shared_ptr<Value> value);
135 void SetEntryFlags(StringRef name,
unsigned int flags);
139 unsigned int GetEntryFlags(StringRef name);
152 void DeleteEntry(StringRef name);
163 void DeleteAllEntries();
177 std::vector<EntryInfo> GetEntryInfo(StringRef prefix,
unsigned int types);
194 void SetListenerOnStart(std::function<
void()> on_start);
195 void SetListenerOnExit(std::function<
void()> on_exit);
197 typedef std::function<void(
unsigned int uid, StringRef name,
198 std::shared_ptr<Value> value,
unsigned int flags)>
199 EntryListenerCallback;
201 typedef std::function<void(
unsigned int uid,
bool connected,
203 ConnectionListenerCallback;
205 unsigned int AddEntryListener(StringRef prefix, EntryListenerCallback callback,
207 void RemoveEntryListener(
unsigned int entry_listener_uid);
208 unsigned int AddConnectionListener(ConnectionListenerCallback callback,
209 bool immediate_notify);
210 void RemoveConnectionListener(
unsigned int conn_listener_uid);
212 bool NotifierDestroyed();
218 #if defined(_MSC_VER) && _MSC_VER < 1900
219 const double kTimeout_Indefinite = -1;
221 constexpr
double kTimeout_Indefinite = -1;
224 void SetRpcServerOnStart(std::function<
void()> on_start);
225 void SetRpcServerOnExit(std::function<
void()> on_exit);
227 typedef std::function<std::string(StringRef name, StringRef params,
231 void CreateRpc(StringRef name, StringRef def, RpcCallback callback);
232 void CreatePolledRpc(StringRef name, StringRef def);
234 bool PollRpc(
bool blocking,
RpcCallInfo* call_info);
235 bool PollRpc(
bool blocking,
double time_out,
RpcCallInfo* call_info);
236 void PostRpcResponse(
unsigned int rpc_id,
unsigned int call_uid,
239 unsigned int CallRpc(StringRef name, StringRef params);
240 bool GetRpcResult(
bool blocking,
unsigned int call_uid, std::string* result);
241 bool GetRpcResult(
bool blocking,
unsigned int call_uid,
double time_out,
242 std::string* result);
243 void CancelBlockingRpcResult(
unsigned int call_uid);
246 bool UnpackRpcDefinition(StringRef packed,
RpcDefinition* def);
247 std::string PackRpcValues(ArrayRef<std::shared_ptr<Value>> values);
248 std::vector<std::shared_ptr<Value>> UnpackRpcValues(StringRef packed,
249 ArrayRef<NT_Type> types);
254 void SetNetworkIdentity(StringRef name);
255 void StartServer(StringRef persist_filename,
const char* listen_address,
259 void StartClient(
const char* server_name,
unsigned int port);
260 void StartClient(ArrayRef<std::pair<StringRef, unsigned int>> servers);
262 void SetServer(
const char* server_name,
unsigned int port);
263 void SetServer(ArrayRef<std::pair<StringRef, unsigned int>> servers);
264 void StartDSClient(
unsigned int port);
266 void StopRpcServer();
268 void SetUpdateRate(
double interval);
269 std::vector<ConnectionInfo> GetConnections();
275 const char* SavePersistent(StringRef filename);
276 const char* LoadPersistent(
277 StringRef filename, std::function<
void(
size_t line,
const char* msg)> warn);
284 unsigned long long Now();
287 typedef std::function<void(
unsigned int level,
const char* file,
288 unsigned int line,
const char* msg)>
290 void SetLogger(LogFunc func,
unsigned int min_level);
NetworkTables Connection Information.
Definition: ntcore_cpp.h:43
NetworkTables RPC Call Data.
Definition: ntcore_cpp.h:79
NetworkTables RPC Definition.
Definition: ntcore_cpp.h:71
unsigned long long last_change
Timestamp of last change to entry (type or value).
Definition: ntcore_cpp.h:39
NT_Type type
Entry type.
Definition: ntcore_cpp.h:33
NetworkTables RPC Parameter Definition.
Definition: ntcore_cpp.h:52
NetworkTables Entry Information.
Definition: ntcore_cpp.h:28
std::string name
Entry name.
Definition: ntcore_cpp.h:30
unsigned int flags
Entry flags.
Definition: ntcore_cpp.h:36
NetworkTables RPC Result Definition.
Definition: ntcore_cpp.h:62