WPILibC++  2019.2.1-24-g74f7ba0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
ntcore_cpp.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2015-2018 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #ifndef NTCORE_NTCORE_CPP_H_
9 #define NTCORE_NTCORE_CPP_H_
10 
11 #include <stdint.h>
12 
13 #include <cassert>
14 #include <functional>
15 #include <memory>
16 #include <string>
17 #include <thread>
18 #include <utility>
19 #include <vector>
20 
21 #include <wpi/ArrayRef.h>
22 #include <wpi/StringRef.h>
23 #include <wpi/Twine.h>
24 #include <wpi/deprecated.h>
25 
26 #include "networktables/NetworkTableValue.h"
27 
29 namespace nt {
30 
39 using wpi::ArrayRef;
40 using wpi::StringRef;
41 using wpi::Twine;
42 
44 struct EntryInfo {
46  NT_Entry entry;
47 
49  std::string name;
50 
53 
55  unsigned int flags;
56 
58  uint64_t last_change;
59 
60  friend void swap(EntryInfo& first, EntryInfo& second) {
61  using std::swap;
62  swap(first.entry, second.entry);
63  swap(first.name, second.name);
64  swap(first.type, second.type);
65  swap(first.flags, second.flags);
66  swap(first.last_change, second.last_change);
67  }
68 };
69 
76  std::string remote_id;
77 
79  std::string remote_ip;
80 
82  unsigned int remote_port;
83 
88  uint64_t last_update;
89 
94  unsigned int protocol_version;
95 
96  friend void swap(ConnectionInfo& first, ConnectionInfo& second) {
97  using std::swap;
98  swap(first.remote_id, second.remote_id);
99  swap(first.remote_ip, second.remote_ip);
100  swap(first.remote_port, second.remote_port);
101  swap(first.last_update, second.last_update);
102  swap(first.protocol_version, second.protocol_version);
103  }
104 };
105 
107 struct RpcParamDef {
108  RpcParamDef() = default;
109  RpcParamDef(StringRef name_, std::shared_ptr<Value> def_value_)
110  : name(name_), def_value(def_value_) {}
111 
112  std::string name;
113  std::shared_ptr<Value> def_value;
114 };
115 
117 struct RpcResultDef {
118  RpcResultDef() = default;
119  RpcResultDef(StringRef name_, NT_Type type_) : name(name_), type(type_) {}
120 
121  std::string name;
122  NT_Type type;
123 };
124 
127  unsigned int version;
128  std::string name;
129  std::vector<RpcParamDef> params;
130  std::vector<RpcResultDef> results;
131 };
132 
134 class RpcAnswer {
135  public:
136  RpcAnswer() : entry(0), call(0) {}
137  RpcAnswer(NT_Entry entry_, NT_RpcCall call_, StringRef name_,
138  StringRef params_, const ConnectionInfo& conn_)
139  : entry(entry_), call(call_), name(name_), params(params_), conn(conn_) {}
140 
142  NT_Entry entry;
143 
145  mutable NT_RpcCall call;
146 
148  std::string name;
149 
151  std::string params;
152 
155 
160  explicit operator bool() const { return call != 0; }
161 
167  bool PostResponse(StringRef result) const;
168 
169  friend void swap(RpcAnswer& first, RpcAnswer& second) {
170  using std::swap;
171  swap(first.entry, second.entry);
172  swap(first.call, second.call);
173  swap(first.name, second.name);
174  swap(first.params, second.params);
175  swap(first.conn, second.conn);
176  }
177 };
178 
181  public:
182  EntryNotification() : listener(0), entry(0) {}
183  EntryNotification(NT_EntryListener listener_, NT_Entry entry_,
184  StringRef name_, std::shared_ptr<Value> value_,
185  unsigned int flags_)
186  : listener(listener_),
187  entry(entry_),
188  name(name_),
189  value(value_),
190  flags(flags_) {}
191 
193  NT_EntryListener listener;
194 
196  NT_Entry entry;
197 
199  std::string name;
200 
202  std::shared_ptr<Value> value;
203 
208  unsigned int flags;
209 
210  friend void swap(EntryNotification& first, EntryNotification& second) {
211  using std::swap;
212  swap(first.listener, second.listener);
213  swap(first.entry, second.entry);
214  swap(first.name, second.name);
215  swap(first.value, second.value);
216  swap(first.flags, second.flags);
217  }
218 };
219 
222  public:
223  ConnectionNotification() : listener(0), connected(false) {}
224  ConnectionNotification(NT_ConnectionListener listener_, bool connected_,
225  const ConnectionInfo& conn_)
226  : listener(listener_), connected(connected_), conn(conn_) {}
227 
229  NT_ConnectionListener listener;
230 
232  bool connected = false;
233 
236 
237  friend void swap(ConnectionNotification& first,
238  ConnectionNotification& second) {
239  using std::swap;
240  swap(first.listener, second.listener);
241  swap(first.connected, second.connected);
242  swap(first.conn, second.conn);
243  }
244 };
245 
247 class LogMessage {
248  public:
249  LogMessage() : logger(0), level(0), filename(""), line(0) {}
250  LogMessage(NT_Logger logger_, unsigned int level_, const char* filename_,
251  unsigned int line_, StringRef message_)
252  : logger(logger_),
253  level(level_),
254  filename(filename_),
255  line(line_),
256  message(message_) {}
257 
259  NT_Logger logger;
260 
262  unsigned int level;
263 
265  const char* filename;
266 
268  unsigned int line;
269 
271  std::string message;
272 
273  friend void swap(LogMessage& first, LogMessage& second) {
274  using std::swap;
275  swap(first.logger, second.logger);
276  swap(first.level, second.level);
277  swap(first.filename, second.filename);
278  swap(first.line, second.line);
279  swap(first.message, second.message);
280  }
281 };
282 
294 NT_Inst GetDefaultInstance();
295 
301 NT_Inst CreateInstance();
302 
309 void DestroyInstance(NT_Inst inst);
310 
317 NT_Inst GetInstanceFromHandle(NT_Handle handle);
318 
333 NT_Entry GetEntry(NT_Inst inst, const Twine& name);
334 
349 std::vector<NT_Entry> GetEntries(NT_Inst inst, const Twine& prefix,
350  unsigned int types);
351 
359 std::string GetEntryName(NT_Entry entry);
360 
367 NT_Type GetEntryType(NT_Entry entry);
368 
376 uint64_t GetEntryLastChange(NT_Entry entry);
377 
387 WPI_DEPRECATED("use NT_Entry function instead")
388 std::shared_ptr<Value> GetEntryValue(StringRef name);
389 
399 std::shared_ptr<Value> GetEntryValue(NT_Entry entry);
400 
412 WPI_DEPRECATED("use NT_Entry function instead")
413 bool SetDefaultEntryValue(StringRef name, std::shared_ptr<Value> value);
414 
426 bool SetDefaultEntryValue(NT_Entry entry, std::shared_ptr<Value> value);
427 
438 WPI_DEPRECATED("use NT_Entry function instead")
439 bool SetEntryValue(StringRef name, std::shared_ptr<Value> value);
440 
451 bool SetEntryValue(NT_Entry entry, std::shared_ptr<Value> value);
452 
466 WPI_DEPRECATED("use NT_Entry function instead")
467 void SetEntryTypeValue(StringRef name, std::shared_ptr<Value> value);
468 
482 void SetEntryTypeValue(NT_Entry entry, std::shared_ptr<Value> value);
483 
490 WPI_DEPRECATED("use NT_Entry function instead")
491 void SetEntryFlags(StringRef name, unsigned int flags);
492 
499 void SetEntryFlags(NT_Entry entry, unsigned int flags);
500 
507 WPI_DEPRECATED("use NT_Entry function instead")
508 unsigned int GetEntryFlags(StringRef name);
509 
516 unsigned int GetEntryFlags(NT_Entry entry);
517 
531 WPI_DEPRECATED("use NT_Entry function instead")
532 void DeleteEntry(StringRef name);
533 
547 void DeleteEntry(NT_Entry entry);
548 
560 WPI_DEPRECATED("use NT_Inst function instead")
561 void DeleteAllEntries();
562 
568 void DeleteAllEntries(NT_Inst inst);
569 
584 WPI_DEPRECATED("use NT_Inst function instead")
585 std::vector<EntryInfo> GetEntryInfo(StringRef prefix, unsigned int types);
586 
592 std::vector<EntryInfo> GetEntryInfo(NT_Inst inst, const Twine& prefix,
593  unsigned int types);
594 
604 EntryInfo GetEntryInfo(NT_Entry entry);
605 
624 typedef std::function<void(NT_EntryListener entry_listener, StringRef name,
625  std::shared_ptr<Value> value, unsigned int flags)>
627 
636 WPI_DEPRECATED("use NT_Inst function instead")
637 NT_EntryListener AddEntryListener(StringRef prefix,
638  EntryListenerCallback callback,
639  unsigned int flags);
640 
646 NT_EntryListener AddEntryListener(
647  NT_Inst inst, const Twine& prefix,
648  std::function<void(const EntryNotification& event)> callback,
649  unsigned int flags);
650 
659 NT_EntryListener AddEntryListener(
660  NT_Entry entry,
661  std::function<void(const EntryNotification& event)> callback,
662  unsigned int flags);
663 
675 NT_EntryListenerPoller CreateEntryListenerPoller(NT_Inst inst);
676 
683 void DestroyEntryListenerPoller(NT_EntryListenerPoller poller);
684 
694 NT_EntryListener AddPolledEntryListener(NT_EntryListenerPoller poller,
695  const Twine& prefix,
696  unsigned int flags);
697 
707 NT_EntryListener AddPolledEntryListener(NT_EntryListenerPoller poller,
708  NT_Entry entry, unsigned int flags);
709 
719 std::vector<EntryNotification> PollEntryListener(NT_EntryListenerPoller poller);
720 
734 std::vector<EntryNotification> PollEntryListener(NT_EntryListenerPoller poller,
735  double timeout,
736  bool* timed_out);
737 
745 void CancelPollEntryListener(NT_EntryListenerPoller poller);
746 
752 void RemoveEntryListener(NT_EntryListener entry_listener);
753 
765 bool WaitForEntryListenerQueue(NT_Inst inst, double timeout);
766 
783 typedef std::function<void(NT_ConnectionListener conn_listener, bool connected,
784  const ConnectionInfo& conn)>
786 
794 WPI_DEPRECATED("use NT_Inst function instead")
795 NT_ConnectionListener AddConnectionListener(ConnectionListenerCallback callback,
796  bool immediate_notify);
797 
803 NT_ConnectionListener AddConnectionListener(
804  NT_Inst inst,
805  std::function<void(const ConnectionNotification& event)> callback,
806  bool immediate_notify);
807 
819 NT_ConnectionListenerPoller CreateConnectionListenerPoller(NT_Inst inst);
820 
827 void DestroyConnectionListenerPoller(NT_ConnectionListenerPoller poller);
828 
836 NT_ConnectionListener AddPolledConnectionListener(
837  NT_ConnectionListenerPoller poller, bool immediate_notify);
838 
850  NT_ConnectionListenerPoller poller);
851 
866  NT_ConnectionListenerPoller poller, double timeout, bool* timed_out);
867 
875 void CancelPollConnectionListener(NT_ConnectionListenerPoller poller);
876 
882 void RemoveConnectionListener(NT_ConnectionListener conn_listener);
883 
895 bool WaitForConnectionListenerQueue(NT_Inst inst, double timeout);
896 
913 void CreateRpc(NT_Entry entry, StringRef def,
914  std::function<void(const RpcAnswer& answer)> callback);
915 
927 NT_RpcCallPoller CreateRpcCallPoller(NT_Inst inst);
928 
935 void DestroyRpcCallPoller(NT_RpcCallPoller poller);
936 
946 void CreatePolledRpc(NT_Entry entry, StringRef def, NT_RpcCallPoller poller);
947 
959 std::vector<RpcAnswer> PollRpc(NT_RpcCallPoller poller);
960 
975 std::vector<RpcAnswer> PollRpc(NT_RpcCallPoller poller, double timeout,
976  bool* timed_out);
977 
984 void CancelPollRpc(NT_RpcCallPoller poller);
985 
997 bool WaitForRpcCallQueue(NT_Inst inst, double timeout);
998 
1009 bool PostRpcResponse(NT_Entry entry, NT_RpcCall call, StringRef result);
1010 
1022 NT_RpcCall CallRpc(NT_Entry entry, StringRef params);
1023 
1033 bool GetRpcResult(NT_Entry entry, NT_RpcCall call, std::string* result);
1034 
1046 bool GetRpcResult(NT_Entry entry, NT_RpcCall call, std::string* result,
1047  double timeout, bool* timed_out);
1048 
1055 void CancelRpcResult(NT_Entry entry, NT_RpcCall call);
1056 
1063 std::string PackRpcDefinition(const RpcDefinition& def);
1064 
1073 bool UnpackRpcDefinition(StringRef packed, RpcDefinition* def);
1074 
1081 std::string PackRpcValues(ArrayRef<std::shared_ptr<Value>> values);
1082 
1090 std::vector<std::shared_ptr<Value>> UnpackRpcValues(StringRef packed,
1091  ArrayRef<NT_Type> types);
1092 
1107 WPI_DEPRECATED("use NT_Inst function instead")
1108 void SetNetworkIdentity(StringRef name);
1109 
1115 void SetNetworkIdentity(NT_Inst inst, const Twine& name);
1116 
1122 WPI_DEPRECATED("use NT_Inst function instead")
1123 unsigned int GetNetworkMode();
1124 
1131 unsigned int GetNetworkMode(NT_Inst inst);
1132 
1142 WPI_DEPRECATED("use NT_Inst function instead")
1143 void StartServer(StringRef persist_filename, const char* listen_address,
1144  unsigned int port);
1145 
1151 void StartServer(NT_Inst inst, const Twine& persist_filename,
1152  const char* listen_address, unsigned int port);
1153 
1157 WPI_DEPRECATED("use NT_Inst function instead")
1158 void StopServer();
1159 
1165 void StopServer(NT_Inst inst);
1166 
1170 WPI_DEPRECATED("use NT_Inst function instead")
1171 void StartClient();
1172 
1179 WPI_DEPRECATED("use NT_Inst function instead")
1180 void StartClient(const char* server_name, unsigned int port);
1181 
1188 WPI_DEPRECATED("use NT_Inst function instead")
1189 void StartClient(ArrayRef<std::pair<StringRef, unsigned int>> servers);
1190 
1196 void StartClient(NT_Inst inst);
1197 
1203 void StartClient(NT_Inst inst, const char* server_name, unsigned int port);
1204 
1210 void StartClient(NT_Inst inst,
1211  ArrayRef<std::pair<StringRef, unsigned int>> servers);
1212 
1221 void StartClientTeam(NT_Inst inst, unsigned int team, unsigned int port);
1222 
1226 WPI_DEPRECATED("use NT_Inst function instead")
1227 void StopClient();
1228 
1233 void StopClient(NT_Inst inst);
1234 
1241 WPI_DEPRECATED("use NT_Inst function instead")
1242 void SetServer(const char* server_name, unsigned int port);
1243 
1250 WPI_DEPRECATED("use NT_Inst function instead")
1251 void SetServer(ArrayRef<std::pair<StringRef, unsigned int>> servers);
1252 
1258 void SetServer(NT_Inst inst, const char* server_name, unsigned int port);
1259 
1265 void SetServer(NT_Inst inst,
1266  ArrayRef<std::pair<StringRef, unsigned int>> servers);
1267 
1276 void SetServerTeam(NT_Inst inst, unsigned int team, unsigned int port);
1277 
1285 WPI_DEPRECATED("use NT_Inst function instead")
1286 void StartDSClient(unsigned int port);
1287 
1292 void StartDSClient(NT_Inst inst, unsigned int port);
1293 
1295 WPI_DEPRECATED("use NT_Inst function instead")
1296 void StopDSClient();
1297 
1303 void StopDSClient(NT_Inst inst);
1304 
1306 WPI_DEPRECATED("use NT_Inst function instead")
1307 void StopRpcServer();
1308 
1315 WPI_DEPRECATED("use NT_Inst function instead")
1316 void SetUpdateRate(double interval);
1317 
1323 void SetUpdateRate(NT_Inst inst, double interval);
1324 
1336 WPI_DEPRECATED("use NT_Inst function instead")
1337 void Flush();
1338 
1344 void Flush(NT_Inst inst);
1345 
1352 WPI_DEPRECATED("use NT_Inst function instead")
1353 std::vector<ConnectionInfo> GetConnections();
1354 
1360 std::vector<ConnectionInfo> GetConnections(NT_Inst inst);
1361 
1368 bool IsConnected(NT_Inst inst);
1369 
1385 WPI_DEPRECATED("use NT_Inst function instead")
1386 const char* SavePersistent(StringRef filename);
1387 
1392 const char* SavePersistent(NT_Inst inst, const Twine& filename);
1393 
1403 WPI_DEPRECATED("use NT_Inst function instead")
1404 const char* LoadPersistent(
1405  StringRef filename, std::function<void(size_t line, const char* msg)> warn);
1406 
1413 const char* LoadPersistent(
1414  NT_Inst inst, const Twine& filename,
1415  std::function<void(size_t line, const char* msg)> warn);
1416 
1426 const char* SaveEntries(NT_Inst inst, const Twine& filename,
1427  const Twine& prefix);
1428 
1439 const char* LoadEntries(NT_Inst inst, const Twine& filename,
1440  const Twine& prefix,
1441  std::function<void(size_t line, const char* msg)> warn);
1442 
1457 uint64_t Now();
1458 
1474 typedef std::function<void(unsigned int level, const char* file,
1475  unsigned int line, const char* msg)>
1477 
1488 WPI_DEPRECATED("use NT_Inst function instead")
1489 void SetLogger(LogFunc func, unsigned int min_level);
1490 
1504 NT_Logger AddLogger(NT_Inst inst,
1505  std::function<void(const LogMessage& msg)> func,
1506  unsigned int min_level, unsigned int max_level);
1507 
1515 NT_LoggerPoller CreateLoggerPoller(NT_Inst inst);
1516 
1523 void DestroyLoggerPoller(NT_LoggerPoller poller);
1524 
1535 NT_Logger AddPolledLogger(NT_LoggerPoller poller, unsigned int min_level,
1536  unsigned int max_level);
1537 
1545 std::vector<LogMessage> PollLogger(NT_LoggerPoller poller);
1546 
1558 std::vector<LogMessage> PollLogger(NT_LoggerPoller poller, double timeout,
1559  bool* timed_out);
1560 
1567 void CancelPollLogger(NT_LoggerPoller poller);
1568 
1574 void RemoveLogger(NT_Logger logger);
1575 
1587 bool WaitForLoggerQueue(NT_Inst inst, double timeout);
1588 
1592 inline bool RpcAnswer::PostResponse(StringRef result) const {
1593  auto ret = PostRpcResponse(entry, call, result);
1594  call = 0;
1595  return ret;
1596 }
1597 
1598 } // namespace nt
1599 
1600 #endif // NTCORE_NTCORE_CPP_H_
NetworkTables Connection Information.
Definition: ntcore_cpp.h:71
std::vector< EntryNotification > PollEntryListener(NT_EntryListenerPoller poller)
Get the next entry listener event.
void SetUpdateRate(double interval)
Set the periodic update rate.
std::vector< LogMessage > PollLogger(NT_LoggerPoller poller)
Get the next log event.
bool PostResponse(StringRef result) const
Post RPC response (return value) for a polled RPC.
Definition: ntcore_cpp.h:1592
std::function< void(unsigned int level, const char *file, unsigned int line, const char *msg)> LogFunc
Log function.
Definition: ntcore_cpp.h:1476
std::function< void(NT_ConnectionListener conn_listener, bool connected, const ConnectionInfo &conn)> ConnectionListenerCallback
Connection listener callback function.
Definition: ntcore_cpp.h:785
bool IsConnected(NT_Inst inst)
Return whether or not the instance is connected to another node.
bool UnpackRpcDefinition(StringRef packed, RpcDefinition *def)
Unpack a RPC version 1 definition.
NT_EntryListener AddEntryListener(StringRef prefix, EntryListenerCallback callback, unsigned int flags)
Add a listener for all entries starting with a certain prefix.
unsigned int remote_port
The port number of the remote node.
Definition: ntcore_cpp.h:82
std::string name
Entry name.
Definition: ntcore_cpp.h:199
std::string remote_id
The remote identifier (as set on the remote node by NetworkTableInstance::SetNetworkIdentity() or nt:...
Definition: ntcore_cpp.h:76
NT_ConnectionListenerPoller CreateConnectionListenerPoller(NT_Inst inst)
Create a connection listener poller.
void RemoveEntryListener(NT_EntryListener entry_listener)
Remove an entry listener.
NetworkTables log message.
Definition: ntcore_cpp.h:247
NetworkTables RPC Version 1 Definition.
Definition: ntcore_cpp.h:126
NT_LoggerPoller CreateLoggerPoller(NT_Inst inst)
Create a log poller.
const char * SaveEntries(NT_Inst inst, const Twine &filename, const Twine &prefix)
Save table values to a file.
bool PostRpcResponse(NT_Entry entry, NT_RpcCall call, StringRef result)
Post RPC response (return value) for a polled RPC.
std::string PackRpcValues(ArrayRef< std::shared_ptr< Value >> values)
Pack RPC values as required for RPC version 1 definition messages.
bool connected
True if event is due to connection being established.
Definition: ntcore_cpp.h:232
NetworkTables Remote Procedure Call (Server Side)
Definition: ntcore_cpp.h:134
bool GetRpcResult(NT_Entry entry, NT_RpcCall call, std::string *result)
Get the result (return value) of a RPC call.
NT_Type type
Entry type.
Definition: ntcore_cpp.h:52
std::vector< ConnectionInfo > GetConnections()
Get information on the currently established network connections.
NT_EntryListener AddPolledEntryListener(NT_EntryListenerPoller poller, const Twine &prefix, unsigned int flags)
Create a polled entry listener.
NT_Logger AddLogger(NT_Inst inst, std::function< void(const LogMessage &msg)> func, unsigned int min_level, unsigned int max_level)
Add logger callback function.
NetworkTables Entry Notification.
Definition: ntcore_cpp.h:180
void SetServer(const char *server_name, unsigned int port)
Sets server address and port for client (without restarting client).
Definition: optional.h:885
void DestroyRpcCallPoller(NT_RpcCallPoller poller)
Destroy a RPC call poller.
ConnectionInfo conn
Connection that called the RPC.
Definition: ntcore_cpp.h:154
NT_Inst CreateInstance()
Create an instance.
const char * LoadEntries(NT_Inst inst, const Twine &filename, const Twine &prefix, std::function< void(size_t line, const char *msg)> warn)
Load table values from a file.
NT_Type GetEntryType(NT_Entry entry)
Gets the type for the specified entry, or unassigned if non existent.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: ArrayRef.h:41
bool SetEntryValue(StringRef name, std::shared_ptr< Value > value)
Set Entry Value.
NT_Entry entry
Entry handle.
Definition: ntcore_cpp.h:142
NT_ConnectionListener listener
Listener that was triggered.
Definition: ntcore_cpp.h:229
void StartDSClient(unsigned int port)
Starts requesting server address from Driver Station.
NT_RpcCall call
Call handle.
Definition: ntcore_cpp.h:145
NT_Entry entry
Entry handle.
Definition: ntcore_cpp.h:46
void RemoveConnectionListener(NT_ConnectionListener conn_listener)
Remove a connection listener.
bool WaitForLoggerQueue(NT_Inst inst, double timeout)
Wait for the incoming log event queue to be empty.
void DeleteEntry(StringRef name)
Delete Entry.
uint64_t GetEntryLastChange(NT_Entry entry)
Gets the last time the entry was changed.
std::string GetEntryName(NT_Entry entry)
Gets the name of the specified entry.
void CancelPollConnectionListener(NT_ConnectionListenerPoller poller)
Cancel a PollConnectionListener call.
NT_Entry entry
Entry handle.
Definition: ntcore_cpp.h:196
void StartServer(StringRef persist_filename, const char *listen_address, unsigned int port)
Starts a server using the specified filename, listening address, and port.
void StopServer()
Stops the server if it is running.
NT_Entry GetEntry(NT_Inst inst, const Twine &name)
Get Entry Handle.
std::vector< EntryInfo > GetEntryInfo(StringRef prefix, unsigned int types)
Get Entry Information.
std::string params
Call raw parameters.
Definition: ntcore_cpp.h:151
NT_EntryListenerPoller CreateEntryListenerPoller(NT_Inst inst)
Create a entry listener poller.
NT_Logger AddPolledLogger(NT_LoggerPoller poller, unsigned int min_level, unsigned int max_level)
Set the log level for a log poller.
unsigned int GetEntryFlags(StringRef name)
Get Entry Flags.
void CancelPollEntryListener(NT_EntryListenerPoller poller)
Cancel a PollEntryListener call.
std::shared_ptr< Value > value
The new value.
Definition: ntcore_cpp.h:202
void SetLogger(LogFunc func, unsigned int min_level)
Set logger callback function.
void DestroyLoggerPoller(NT_LoggerPoller poller)
Destroy a log poller.
NetworkTables (ntcore) namespace.
Definition: ITable.h:21
std::shared_ptr< Value > GetEntryValue(StringRef name)
Get Entry Value.
void StopClient()
Stops the client if it is running.
std::string message
The message.
Definition: ntcore_cpp.h:271
void DeleteAllEntries()
Delete All Entries.
NetworkTables RPC Version 1 Definition Parameter.
Definition: ntcore_cpp.h:107
void DestroyInstance(NT_Inst inst)
Destroy an instance.
void SetEntryFlags(StringRef name, unsigned int flags)
Set Entry Flags.
NetworkTables Entry Information.
Definition: ntcore_cpp.h:44
void CancelRpcResult(NT_Entry entry, NT_RpcCall call)
Ignore the result of a RPC call.
void DestroyEntryListenerPoller(NT_EntryListenerPoller poller)
Destroy a entry listener poller.
NetworkTables Connection Notification.
Definition: ntcore_cpp.h:221
bool SetDefaultEntryValue(StringRef name, std::shared_ptr< Value > value)
Set Default Entry Value.
void DestroyConnectionListenerPoller(NT_ConnectionListenerPoller poller)
Destroy a connection listener poller.
const char * LoadPersistent(StringRef filename, std::function< void(size_t line, const char *msg)> warn)
Load persistent values from a file.
std::string name
Entry name.
Definition: ntcore_cpp.h:49
void CancelPollRpc(NT_RpcCallPoller poller)
Cancel a PollRpc call.
void RemoveLogger(NT_Logger logger)
Remove a logger.
void StartClient()
Starts a client.
NT_ConnectionListener AddPolledConnectionListener(NT_ConnectionListenerPoller poller, bool immediate_notify)
Create a polled connection listener.
void CreateRpc(NT_Entry entry, StringRef def, std::function< void(const RpcAnswer &answer)> callback)
Create a callback-based RPC entry point.
std::string PackRpcDefinition(const RpcDefinition &def)
Pack a RPC version 1 definition.
std::function< void(NT_EntryListener entry_listener, StringRef name, std::shared_ptr< Value > value, unsigned int flags)> EntryListenerCallback
Entry listener callback function.
Definition: ntcore_cpp.h:626
ConnectionInfo conn
Connection info.
Definition: ntcore_cpp.h:235
bool WaitForEntryListenerQueue(NT_Inst inst, double timeout)
Wait for the entry listener queue to be empty.
void SetEntryTypeValue(StringRef name, std::shared_ptr< Value > value)
Set Entry Type and Value.
void Flush()
Flush Entries.
const char * SavePersistent(StringRef filename)
Save persistent values to a file.
NT_ConnectionListener AddConnectionListener(ConnectionListenerCallback callback, bool immediate_notify)
Add a connection listener.
std::vector< NT_Entry > GetEntries(NT_Inst inst, const Twine &prefix, unsigned int types)
Get Entry Handles.
void StartClientTeam(NT_Inst inst, unsigned int team, unsigned int port)
Starts a client using commonly known robot addresses for the specified team.
unsigned int protocol_version
The protocol version being used for this connection.
Definition: ntcore_cpp.h:94
void SetServerTeam(NT_Inst inst, unsigned int team, unsigned int port)
Sets server addresses and port for client (without restarting client).
void CreatePolledRpc(NT_Entry entry, StringRef def, NT_RpcCallPoller poller)
Create a polled RPC entry point.
NT_Inst GetDefaultInstance()
Get default instance.
bool WaitForConnectionListenerQueue(NT_Inst inst, double timeout)
Wait for the connection listener queue to be empty.
unsigned int GetNetworkMode()
Get the current network mode.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
NT_Type
NetworkTables data types.
Definition: ntcore_c.h:52
std::string name
Entry name.
Definition: ntcore_cpp.h:148
unsigned int flags
Entry flags.
Definition: ntcore_cpp.h:55
NT_RpcCall CallRpc(NT_Entry entry, StringRef params)
Call a RPC function.
NT_EntryListener listener
Listener that was triggered.
Definition: ntcore_cpp.h:193
std::string remote_ip
The IP address of the remote node.
Definition: ntcore_cpp.h:79
bool WaitForRpcCallQueue(NT_Inst inst, double timeout)
Wait for the incoming RPC call queue to be empty.
uint64_t last_change
Timestamp of last change to entry (type or value).
Definition: ntcore_cpp.h:58
NetworkTables RPC Version 1 Definition Result.
Definition: ntcore_cpp.h:117
A network table entry value.
Definition: NetworkTableValue.h:36
void SetNetworkIdentity(StringRef name)
Set the network identity of this node.
unsigned int line
The line number in the source file that generated the message.
Definition: ntcore_cpp.h:268
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:79
std::vector< ConnectionNotification > PollConnectionListener(NT_ConnectionListenerPoller poller)
Get the next connection event.
void CancelPollLogger(NT_LoggerPoller poller)
Cancel a PollLogger call.
std::vector< RpcAnswer > PollRpc(NT_RpcCallPoller poller)
Get the next incoming RPC call.
std::vector< std::shared_ptr< Value > > UnpackRpcValues(StringRef packed, ArrayRef< NT_Type > types)
Unpack RPC values as required for RPC version 1 definition messages.
NT_Inst GetInstanceFromHandle(NT_Handle handle)
Get instance handle from another handle.
void StopDSClient()
Stops requesting server address from Driver Station.
unsigned int level
Log level of the message.
Definition: ntcore_cpp.h:262
NT_Logger logger
The logger that generated the message.
Definition: ntcore_cpp.h:259
NT_RpcCallPoller CreateRpcCallPoller(NT_Inst inst)
Create a RPC call poller.
void StopRpcServer()
Stops the RPC server if it is running.
unsigned int flags
Update flags.
Definition: ntcore_cpp.h:208
uint64_t last_update
The last time any update was received from the remote node (same scale as returned by nt::Now())...
Definition: ntcore_cpp.h:88
uint64_t Now()
Returns monotonic current time in 1 us increments.
const char * filename
The filename of the source file that generated the message.
Definition: ntcore_cpp.h:265