WPILibC++  2020.3.2
ntcore_cpp.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2015-2019 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{0};
83 
88  uint64_t last_update{0};
89 
94  unsigned int protocol_version{0};
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), flags(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 
1138 void StartLocal(NT_Inst inst);
1139 
1144 void StopLocal(NT_Inst inst);
1145 
1155 WPI_DEPRECATED("use NT_Inst function instead")
1156 void StartServer(StringRef persist_filename, const char* listen_address,
1157  unsigned int port);
1158 
1164 void StartServer(NT_Inst inst, const Twine& persist_filename,
1165  const char* listen_address, unsigned int port);
1166 
1170 WPI_DEPRECATED("use NT_Inst function instead")
1171 void StopServer();
1172 
1178 void StopServer(NT_Inst inst);
1179 
1183 WPI_DEPRECATED("use NT_Inst function instead")
1184 void StartClient();
1185 
1192 WPI_DEPRECATED("use NT_Inst function instead")
1193 void StartClient(const char* server_name, unsigned int port);
1194 
1201 WPI_DEPRECATED("use NT_Inst function instead")
1202 void StartClient(ArrayRef<std::pair<StringRef, unsigned int>> servers);
1203 
1209 void StartClient(NT_Inst inst);
1210 
1216 void StartClient(NT_Inst inst, const char* server_name, unsigned int port);
1217 
1223 void StartClient(NT_Inst inst,
1224  ArrayRef<std::pair<StringRef, unsigned int>> servers);
1225 
1234 void StartClientTeam(NT_Inst inst, unsigned int team, unsigned int port);
1235 
1239 WPI_DEPRECATED("use NT_Inst function instead")
1240 void StopClient();
1241 
1246 void StopClient(NT_Inst inst);
1247 
1254 WPI_DEPRECATED("use NT_Inst function instead")
1255 void SetServer(const char* server_name, unsigned int port);
1256 
1263 WPI_DEPRECATED("use NT_Inst function instead")
1264 void SetServer(ArrayRef<std::pair<StringRef, unsigned int>> servers);
1265 
1271 void SetServer(NT_Inst inst, const char* server_name, unsigned int port);
1272 
1278 void SetServer(NT_Inst inst,
1279  ArrayRef<std::pair<StringRef, unsigned int>> servers);
1280 
1289 void SetServerTeam(NT_Inst inst, unsigned int team, unsigned int port);
1290 
1298 WPI_DEPRECATED("use NT_Inst function instead")
1299 void StartDSClient(unsigned int port);
1300 
1305 void StartDSClient(NT_Inst inst, unsigned int port);
1306 
1308 WPI_DEPRECATED("use NT_Inst function instead")
1309 void StopDSClient();
1310 
1316 void StopDSClient(NT_Inst inst);
1317 
1319 WPI_DEPRECATED("use NT_Inst function instead")
1320 void StopRpcServer();
1321 
1328 WPI_DEPRECATED("use NT_Inst function instead")
1329 void SetUpdateRate(double interval);
1330 
1336 void SetUpdateRate(NT_Inst inst, double interval);
1337 
1349 WPI_DEPRECATED("use NT_Inst function instead")
1350 void Flush();
1351 
1357 void Flush(NT_Inst inst);
1358 
1365 WPI_DEPRECATED("use NT_Inst function instead")
1366 std::vector<ConnectionInfo> GetConnections();
1367 
1373 std::vector<ConnectionInfo> GetConnections(NT_Inst inst);
1374 
1381 bool IsConnected(NT_Inst inst);
1382 
1398 WPI_DEPRECATED("use NT_Inst function instead")
1399 const char* SavePersistent(StringRef filename);
1400 
1405 const char* SavePersistent(NT_Inst inst, const Twine& filename);
1406 
1416 WPI_DEPRECATED("use NT_Inst function instead")
1417 const char* LoadPersistent(
1418  StringRef filename, std::function<void(size_t line, const char* msg)> warn);
1419 
1426 const char* LoadPersistent(
1427  NT_Inst inst, const Twine& filename,
1428  std::function<void(size_t line, const char* msg)> warn);
1429 
1439 const char* SaveEntries(NT_Inst inst, const Twine& filename,
1440  const Twine& prefix);
1441 
1452 const char* LoadEntries(NT_Inst inst, const Twine& filename,
1453  const Twine& prefix,
1454  std::function<void(size_t line, const char* msg)> warn);
1455 
1470 uint64_t Now();
1471 
1487 typedef std::function<void(unsigned int level, const char* file,
1488  unsigned int line, const char* msg)>
1490 
1501 WPI_DEPRECATED("use NT_Inst function instead")
1502 void SetLogger(LogFunc func, unsigned int min_level);
1503 
1517 NT_Logger AddLogger(NT_Inst inst,
1518  std::function<void(const LogMessage& msg)> func,
1519  unsigned int min_level, unsigned int max_level);
1520 
1528 NT_LoggerPoller CreateLoggerPoller(NT_Inst inst);
1529 
1536 void DestroyLoggerPoller(NT_LoggerPoller poller);
1537 
1548 NT_Logger AddPolledLogger(NT_LoggerPoller poller, unsigned int min_level,
1549  unsigned int max_level);
1550 
1558 std::vector<LogMessage> PollLogger(NT_LoggerPoller poller);
1559 
1571 std::vector<LogMessage> PollLogger(NT_LoggerPoller poller, double timeout,
1572  bool* timed_out);
1573 
1580 void CancelPollLogger(NT_LoggerPoller poller);
1581 
1587 void RemoveLogger(NT_Logger logger);
1588 
1600 bool WaitForLoggerQueue(NT_Inst inst, double timeout);
1601 
1605 inline bool RpcAnswer::PostResponse(StringRef result) const {
1606  auto ret = PostRpcResponse(entry, call, result);
1607  call = 0;
1608  return ret;
1609 }
1610 
1611 } // namespace nt
1612 
1613 #endif // NTCORE_NTCORE_CPP_H_
nt::GetDefaultInstance
NT_Inst GetDefaultInstance()
Get default instance.
nt::StartClientTeam
void StartClientTeam(NT_Inst inst, unsigned int team, unsigned int port)
Starts a client using commonly known robot addresses for the specified team.
nt::LogFunc
std::function< void(unsigned int level, const char *file, unsigned int line, const char *msg)> LogFunc
Log function.
Definition: ntcore_cpp.h:1489
nt::CancelPollEntryListener
void CancelPollEntryListener(NT_EntryListenerPoller poller)
Cancel a PollEntryListener call.
nt::SetServerTeam
void SetServerTeam(NT_Inst inst, unsigned int team, unsigned int port)
Sets server addresses and port for client (without restarting client).
nt::EntryInfo::name
std::string name
Entry name.
Definition: ntcore_cpp.h:49
nt::RpcAnswer::call
NT_RpcCall call
Call handle.
Definition: ntcore_cpp.h:145
nt::DestroyEntryListenerPoller
void DestroyEntryListenerPoller(NT_EntryListenerPoller poller)
Destroy a entry listener poller.
nt::GetConnections
std::vector< ConnectionInfo > GetConnections()
Get information on the currently established network connections.
nt::RpcAnswer::PostResponse
bool PostResponse(StringRef result) const
Post RPC response (return value) for a polled RPC.
Definition: ntcore_cpp.h:1605
nt::ConnectionListenerCallback
std::function< void(NT_ConnectionListener conn_listener, bool connected, const ConnectionInfo &conn)> ConnectionListenerCallback
Connection listener callback function.
Definition: ntcore_cpp.h:785
nt::PollLogger
std::vector< LogMessage > PollLogger(NT_LoggerPoller poller)
Get the next log event.
nt::DestroyRpcCallPoller
void DestroyRpcCallPoller(NT_RpcCallPoller poller)
Destroy a RPC call poller.
nt::PackRpcValues
std::string PackRpcValues(ArrayRef< std::shared_ptr< Value >> values)
Pack RPC values as required for RPC version 1 definition messages.
nt::CreateConnectionListenerPoller
NT_ConnectionListenerPoller CreateConnectionListenerPoller(NT_Inst inst)
Create a connection listener poller.
nt::EntryListenerCallback
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
nt::IsConnected
bool IsConnected(NT_Inst inst)
Return whether or not the instance is connected to another node.
nt::RpcDefinition
NetworkTables RPC Version 1 Definition.
Definition: ntcore_cpp.h:126
nt::RpcAnswer::conn
ConnectionInfo conn
Connection that called the RPC.
Definition: ntcore_cpp.h:154
nt::Now
uint64_t Now()
Returns monotonic current time in 1 us increments.
nt::PostRpcResponse
bool PostRpcResponse(NT_Entry entry, NT_RpcCall call, StringRef result)
Post RPC response (return value) for a polled RPC.
nt::CreateLoggerPoller
NT_LoggerPoller CreateLoggerPoller(NT_Inst inst)
Create a log poller.
wpi::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:42
nt::EntryNotification::value
std::shared_ptr< Value > value
The new value.
Definition: ntcore_cpp.h:202
nt::DeleteEntry
void DeleteEntry(StringRef name)
Delete Entry.
nt::AddLogger
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.
nt::ConnectionNotification::conn
ConnectionInfo conn
Connection info.
Definition: ntcore_cpp.h:235
nt::EntryInfo::flags
unsigned int flags
Entry flags.
Definition: ntcore_cpp.h:55
nt::WaitForEntryListenerQueue
bool WaitForEntryListenerQueue(NT_Inst inst, double timeout)
Wait for the entry listener queue to be empty.
nt::StopServer
void StopServer()
Stops the server if it is running.
nt::GetInstanceFromHandle
NT_Inst GetInstanceFromHandle(NT_Handle handle)
Get instance handle from another handle.
nt::EntryNotification::flags
unsigned int flags
Update flags.
Definition: ntcore_cpp.h:208
nt::LogMessage::line
unsigned int line
The line number in the source file that generated the message.
Definition: ntcore_cpp.h:268
nt::AddEntryListener
NT_EntryListener AddEntryListener(StringRef prefix, EntryListenerCallback callback, unsigned int flags)
Add a listener for all entries starting with a certain prefix.
nt::EntryNotification::listener
NT_EntryListener listener
Listener that was triggered.
Definition: ntcore_cpp.h:193
nt::LogMessage
NetworkTables log message.
Definition: ntcore_cpp.h:247
nt::DeleteAllEntries
void DeleteAllEntries()
Delete All Entries.
nt::ConnectionInfo::remote_ip
std::string remote_ip
The IP address of the remote node.
Definition: ntcore_cpp.h:79
nt::CreateEntryListenerPoller
NT_EntryListenerPoller CreateEntryListenerPoller(NT_Inst inst)
Create a entry listener poller.
nt::ConnectionInfo::protocol_version
unsigned int protocol_version
The protocol version being used for this connection.
Definition: ntcore_cpp.h:94
nt::CancelPollConnectionListener
void CancelPollConnectionListener(NT_ConnectionListenerPoller poller)
Cancel a PollConnectionListener call.
nt::RemoveConnectionListener
void RemoveConnectionListener(NT_ConnectionListener conn_listener)
Remove a connection listener.
nt::EntryNotification
NetworkTables Entry Notification.
Definition: ntcore_cpp.h:180
nt::WaitForLoggerQueue
bool WaitForLoggerQueue(NT_Inst inst, double timeout)
Wait for the incoming log event queue to be empty.
nt::CancelRpcResult
void CancelRpcResult(NT_Entry entry, NT_RpcCall call)
Ignore the result of a RPC call.
nt::LogMessage::logger
NT_Logger logger
The logger that generated the message.
Definition: ntcore_cpp.h:259
nt::CreateRpc
void CreateRpc(NT_Entry entry, StringRef def, std::function< void(const RpcAnswer &answer)> callback)
Create a callback-based RPC entry point.
nt::LogMessage::level
unsigned int level
Log level of the message.
Definition: ntcore_cpp.h:262
nt::RpcAnswer::params
std::string params
Call raw parameters.
Definition: ntcore_cpp.h:151
nt::ConnectionNotification::listener
NT_ConnectionListener listener
Listener that was triggered.
Definition: ntcore_cpp.h:229
nt::CreateInstance
NT_Inst CreateInstance()
Create an instance.
nt::StartServer
void StartServer(StringRef persist_filename, const char *listen_address, unsigned int port)
Starts a server using the specified filename, listening address, and port.
nt::SetUpdateRate
void SetUpdateRate(double interval)
Set the periodic update rate.
nt::EntryInfo::last_change
uint64_t last_change
Timestamp of last change to entry (type or value).
Definition: ntcore_cpp.h:58
nt::GetEntryFlags
unsigned int GetEntryFlags(StringRef name)
Get Entry Flags.
nt::GetEntryLastChange
uint64_t GetEntryLastChange(NT_Entry entry)
Gets the last time the entry was changed.
nt::GetEntryName
std::string GetEntryName(NT_Entry entry)
Gets the name of the specified entry.
nt::ConnectionInfo::last_update
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
nt::AddPolledLogger
NT_Logger AddPolledLogger(NT_LoggerPoller poller, unsigned int min_level, unsigned int max_level)
Set the log level for a log poller.
nt::GetEntryType
NT_Type GetEntryType(NT_Entry entry)
Gets the type for the specified entry, or unassigned if non existent.
nt::DestroyLoggerPoller
void DestroyLoggerPoller(NT_LoggerPoller poller)
Destroy a log poller.
nt::SetEntryValue
bool SetEntryValue(StringRef name, std::shared_ptr< Value > value)
Set Entry Value.
nt::PollEntryListener
std::vector< EntryNotification > PollEntryListener(NT_EntryListenerPoller poller)
Get the next entry listener event.
nt::RpcAnswer::name
std::string name
Entry name.
Definition: ntcore_cpp.h:148
nt::RpcAnswer
NetworkTables Remote Procedure Call (Server Side)
Definition: ntcore_cpp.h:134
nt::ConnectionNotification::connected
bool connected
True if event is due to connection being established.
Definition: ntcore_cpp.h:232
nt::SaveEntries
const char * SaveEntries(NT_Inst inst, const Twine &filename, const Twine &prefix)
Save table values to a file.
nt::SetServer
void SetServer(const char *server_name, unsigned int port)
Sets server address and port for client (without restarting client).
nt::SetEntryTypeValue
void SetEntryTypeValue(StringRef name, std::shared_ptr< Value > value)
Set Entry Type and Value.
nt::StopLocal
void StopLocal(NT_Inst inst)
Stops local-only operation.
nt::GetEntryInfo
std::vector< EntryInfo > GetEntryInfo(StringRef prefix, unsigned int types)
Get Entry Information.
nt::SetDefaultEntryValue
bool SetDefaultEntryValue(StringRef name, std::shared_ptr< Value > value)
Set Default Entry Value.
nt::ConnectionNotification
NetworkTables Connection Notification.
Definition: ntcore_cpp.h:221
nt::LogMessage::filename
const char * filename
The filename of the source file that generated the message.
Definition: ntcore_cpp.h:265
nt::SetLogger
void SetLogger(LogFunc func, unsigned int min_level)
Set logger callback function.
nt::CreatePolledRpc
void CreatePolledRpc(NT_Entry entry, StringRef def, NT_RpcCallPoller poller)
Create a polled RPC entry point.
nt::RpcAnswer::entry
NT_Entry entry
Entry handle.
Definition: ntcore_cpp.h:142
nt::GetEntryValue
std::shared_ptr< Value > GetEntryValue(StringRef name)
Get Entry Value.
nt::DestroyConnectionListenerPoller
void DestroyConnectionListenerPoller(NT_ConnectionListenerPoller poller)
Destroy a connection listener poller.
nt::LoadEntries
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.
wpi::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
nt::GetEntry
NT_Entry GetEntry(NT_Inst inst, const Twine &name)
Get Entry Handle.
nt::PackRpcDefinition
std::string PackRpcDefinition(const RpcDefinition &def)
Pack a RPC version 1 definition.
nt::StartClient
void StartClient()
Starts a client.
nt::CallRpc
NT_RpcCall CallRpc(NT_Entry entry, StringRef params)
Call a RPC function.
nt::StartDSClient
void StartDSClient(unsigned int port)
Starts requesting server address from Driver Station.
nt::WaitForRpcCallQueue
bool WaitForRpcCallQueue(NT_Inst inst, double timeout)
Wait for the incoming RPC call queue to be empty.
nt::RemoveEntryListener
void RemoveEntryListener(NT_EntryListener entry_listener)
Remove an entry listener.
nt::GetEntries
std::vector< NT_Entry > GetEntries(NT_Inst inst, const Twine &prefix, unsigned int types)
Get Entry Handles.
nt::AddPolledConnectionListener
NT_ConnectionListener AddPolledConnectionListener(NT_ConnectionListenerPoller poller, bool immediate_notify)
Create a polled connection listener.
nt::EntryNotification::entry
NT_Entry entry
Entry handle.
Definition: ntcore_cpp.h:196
nt::RpcResultDef
NetworkTables RPC Version 1 Definition Result.
Definition: ntcore_cpp.h:117
nt::RemoveLogger
void RemoveLogger(NT_Logger logger)
Remove a logger.
nt::AddPolledEntryListener
NT_EntryListener AddPolledEntryListener(NT_EntryListenerPoller poller, const Twine &prefix, unsigned int flags)
Create a polled entry listener.
nt::AddConnectionListener
NT_ConnectionListener AddConnectionListener(ConnectionListenerCallback callback, bool immediate_notify)
Add a connection listener.
nt::WaitForConnectionListenerQueue
bool WaitForConnectionListenerQueue(NT_Inst inst, double timeout)
Wait for the connection listener queue to be empty.
nt::SetEntryFlags
void SetEntryFlags(StringRef name, unsigned int flags)
Set Entry Flags.
nt::LoadPersistent
const char * LoadPersistent(StringRef filename, std::function< void(size_t line, const char *msg)> warn)
Load persistent values from a file.
nt::StopDSClient
void StopDSClient()
Stops requesting server address from Driver Station.
nt::StopClient
void StopClient()
Stops the client if it is running.
nt::DestroyInstance
void DestroyInstance(NT_Inst inst)
Destroy an instance.
nt::RpcParamDef
NetworkTables RPC Version 1 Definition Parameter.
Definition: ntcore_cpp.h:107
nt::EntryInfo::type
NT_Type type
Entry type.
Definition: ntcore_cpp.h:52
nt::EntryNotification::name
std::string name
Entry name.
Definition: ntcore_cpp.h:199
nt::Value
A network table entry value.
Definition: NetworkTableValue.h:37
nt::EntryInfo::entry
NT_Entry entry
Entry handle.
Definition: ntcore_cpp.h:46
nt::SavePersistent
const char * SavePersistent(StringRef filename)
Save persistent values to a file.
NT_Type
NT_Type
NetworkTables data types.
Definition: ntcore_c.h:52
nt::CancelPollRpc
void CancelPollRpc(NT_RpcCallPoller poller)
Cancel a PollRpc call.
nt::GetNetworkMode
unsigned int GetNetworkMode()
Get the current network mode.
nt::ConnectionInfo::remote_port
unsigned int remote_port
The port number of the remote node.
Definition: ntcore_cpp.h:82
nt::ConnectionInfo
NetworkTables Connection Information.
Definition: ntcore_cpp.h:71
nt::PollRpc
std::vector< RpcAnswer > PollRpc(NT_RpcCallPoller poller)
Get the next incoming RPC call.
nt::UnpackRpcValues
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::PollConnectionListener
std::vector< ConnectionNotification > PollConnectionListener(NT_ConnectionListenerPoller poller)
Get the next connection event.
wpi::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:85
nt
NetworkTables (ntcore) namespace.
Definition: NetworkTableValue.h:27
nt::ConnectionInfo::remote_id
std::string remote_id
The remote identifier (as set on the remote node by NetworkTableInstance::SetNetworkIdentity() or nt:...
Definition: ntcore_cpp.h:76
nt::Flush
void Flush()
Flush Entries.
nt::StartLocal
void StartLocal(NT_Inst inst)
Starts local-only operation.
nt::SetNetworkIdentity
void SetNetworkIdentity(StringRef name)
Set the network identity of this node.
nt::StopRpcServer
void StopRpcServer()
Stops the RPC server if it is running.
nt::UnpackRpcDefinition
bool UnpackRpcDefinition(StringRef packed, RpcDefinition *def)
Unpack a RPC version 1 definition.
nt::CancelPollLogger
void CancelPollLogger(NT_LoggerPoller poller)
Cancel a PollLogger call.
nt::GetRpcResult
bool GetRpcResult(NT_Entry entry, NT_RpcCall call, std::string *result)
Get the result (return value) of a RPC call.
nt::CreateRpcCallPoller
NT_RpcCallPoller CreateRpcCallPoller(NT_Inst inst)
Create a RPC call poller.
nt::LogMessage::message
std::string message
The message.
Definition: ntcore_cpp.h:271
nt::EntryInfo
NetworkTables Entry Information.
Definition: ntcore_cpp.h:44