2020-12-26 14:12:05 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
2015-07-16 22:55:50 -07:00
|
|
|
|
2017-08-19 23:08:27 -07:00
|
|
|
#ifndef NTCORE_DISPATCHER_H_
|
|
|
|
|
#define NTCORE_DISPATCHER_H_
|
2015-07-16 22:55:50 -07:00
|
|
|
|
|
|
|
|
#include <atomic>
|
2015-07-29 20:33:26 -07:00
|
|
|
#include <functional>
|
2015-07-16 22:55:50 -07:00
|
|
|
#include <memory>
|
|
|
|
|
#include <string>
|
2021-06-06 16:13:58 -07:00
|
|
|
#include <string_view>
|
2017-09-04 22:01:59 -07:00
|
|
|
#include <thread>
|
2017-08-19 23:08:27 -07:00
|
|
|
#include <utility>
|
2015-07-16 22:55:50 -07:00
|
|
|
#include <vector>
|
|
|
|
|
|
2021-12-12 20:09:57 -08:00
|
|
|
#include <wpi/DataLog.h>
|
|
|
|
|
#include <wpi/UidVector.h>
|
2018-04-29 23:33:19 -07:00
|
|
|
#include <wpi/condition_variable.h>
|
|
|
|
|
#include <wpi/mutex.h>
|
2021-06-06 19:51:14 -07:00
|
|
|
#include <wpi/span.h>
|
2015-07-16 22:55:50 -07:00
|
|
|
|
Implement independent instances.
Previously, most of the classes were implemented as singletons so only one
instance was possible.
This change adds an instance handle-based API. In Java, this API is located
in a different package than the old API (edu.wpi.first.networktables).
Backwards compatibility with ITable and the old NetworkTable API is largely
maintained, but a handful of classes have moved to the new package in Java
(ConnectionInfo and PersistentException), and the old JNI has been completed
replaced.
Also:
- Move SetTeam implementation to Dispatcher.
- Consistently pass time through Java and C++ Value API.
- Rename nt_Value.h to NetworkTableValue.h for consistency with Java.
- Improve documentation
- Make C++ and Java APIs more consistent
- Document RPC functions and support RPC in Java.
- Add polling features for entry and connection listeners and use them to
move callback threads to Java level.
- Remove thread start and stop hooks (as polling is available).
- Make Notifiers, RpcServer, Dispatcher, and Storage mockable.
- Set NOTIFY_NEW on immediate entry notifications.
- Make GetTable("/") and GetTable("") equivalent.
- Generate local notification for flags update when loading persistent file.
And many unit test updates/changes:
- Use InitGoogleMock instead of InitGoogleTest in test main.
- Move test printers to TestPrinter.h/cpp.
- Provide printers for StringRef, EntryNotifier, and Handle.
- StorageTest: Check notifications.
- Add entry notifier unit tests.
- Storage: Add test for incoming entry assignment.
- Update connection listener tests.
- Add entry listener unit tests.
Fixes #11, #140, #189, #190, #192, #193, #221
2017-04-23 10:26:17 -07:00
|
|
|
#include "IDispatcher.h"
|
2017-09-04 22:01:59 -07:00
|
|
|
#include "INetworkConnection.h"
|
2015-07-16 22:55:50 -07:00
|
|
|
|
2016-07-27 00:39:38 -07:00
|
|
|
namespace wpi {
|
Implement independent instances.
Previously, most of the classes were implemented as singletons so only one
instance was possible.
This change adds an instance handle-based API. In Java, this API is located
in a different package than the old API (edu.wpi.first.networktables).
Backwards compatibility with ITable and the old NetworkTable API is largely
maintained, but a handful of classes have moved to the new package in Java
(ConnectionInfo and PersistentException), and the old JNI has been completed
replaced.
Also:
- Move SetTeam implementation to Dispatcher.
- Consistently pass time through Java and C++ Value API.
- Rename nt_Value.h to NetworkTableValue.h for consistency with Java.
- Improve documentation
- Make C++ and Java APIs more consistent
- Document RPC functions and support RPC in Java.
- Add polling features for entry and connection listeners and use them to
move callback threads to Java level.
- Remove thread start and stop hooks (as polling is available).
- Make Notifiers, RpcServer, Dispatcher, and Storage mockable.
- Set NOTIFY_NEW on immediate entry notifications.
- Make GetTable("/") and GetTable("") equivalent.
- Generate local notification for flags update when loading persistent file.
And many unit test updates/changes:
- Use InitGoogleMock instead of InitGoogleTest in test main.
- Move test printers to TestPrinter.h/cpp.
- Provide printers for StringRef, EntryNotifier, and Handle.
- StorageTest: Check notifications.
- Add entry notifier unit tests.
- Storage: Add test for incoming entry assignment.
- Update connection listener tests.
- Add entry listener unit tests.
Fixes #11, #140, #189, #190, #192, #193, #221
2017-04-23 10:26:17 -07:00
|
|
|
class Logger;
|
2015-08-02 00:33:41 -07:00
|
|
|
class NetworkAcceptor;
|
|
|
|
|
class NetworkStream;
|
2017-08-19 23:08:27 -07:00
|
|
|
} // namespace wpi
|
2015-07-17 22:39:36 -07:00
|
|
|
|
2015-07-17 07:21:07 -07:00
|
|
|
namespace nt {
|
2015-07-16 22:55:50 -07:00
|
|
|
|
Implement independent instances.
Previously, most of the classes were implemented as singletons so only one
instance was possible.
This change adds an instance handle-based API. In Java, this API is located
in a different package than the old API (edu.wpi.first.networktables).
Backwards compatibility with ITable and the old NetworkTable API is largely
maintained, but a handful of classes have moved to the new package in Java
(ConnectionInfo and PersistentException), and the old JNI has been completed
replaced.
Also:
- Move SetTeam implementation to Dispatcher.
- Consistently pass time through Java and C++ Value API.
- Rename nt_Value.h to NetworkTableValue.h for consistency with Java.
- Improve documentation
- Make C++ and Java APIs more consistent
- Document RPC functions and support RPC in Java.
- Add polling features for entry and connection listeners and use them to
move callback threads to Java level.
- Remove thread start and stop hooks (as polling is available).
- Make Notifiers, RpcServer, Dispatcher, and Storage mockable.
- Set NOTIFY_NEW on immediate entry notifications.
- Make GetTable("/") and GetTable("") equivalent.
- Generate local notification for flags update when loading persistent file.
And many unit test updates/changes:
- Use InitGoogleMock instead of InitGoogleTest in test main.
- Move test printers to TestPrinter.h/cpp.
- Provide printers for StringRef, EntryNotifier, and Handle.
- StorageTest: Check notifications.
- Add entry notifier unit tests.
- Storage: Add test for incoming entry assignment.
- Update connection listener tests.
- Add entry listener unit tests.
Fixes #11, #140, #189, #190, #192, #193, #221
2017-04-23 10:26:17 -07:00
|
|
|
class IConnectionNotifier;
|
|
|
|
|
class IStorage;
|
2017-09-04 22:01:59 -07:00
|
|
|
class NetworkConnection;
|
Implement independent instances.
Previously, most of the classes were implemented as singletons so only one
instance was possible.
This change adds an instance handle-based API. In Java, this API is located
in a different package than the old API (edu.wpi.first.networktables).
Backwards compatibility with ITable and the old NetworkTable API is largely
maintained, but a handful of classes have moved to the new package in Java
(ConnectionInfo and PersistentException), and the old JNI has been completed
replaced.
Also:
- Move SetTeam implementation to Dispatcher.
- Consistently pass time through Java and C++ Value API.
- Rename nt_Value.h to NetworkTableValue.h for consistency with Java.
- Improve documentation
- Make C++ and Java APIs more consistent
- Document RPC functions and support RPC in Java.
- Add polling features for entry and connection listeners and use them to
move callback threads to Java level.
- Remove thread start and stop hooks (as polling is available).
- Make Notifiers, RpcServer, Dispatcher, and Storage mockable.
- Set NOTIFY_NEW on immediate entry notifications.
- Make GetTable("/") and GetTable("") equivalent.
- Generate local notification for flags update when loading persistent file.
And many unit test updates/changes:
- Use InitGoogleMock instead of InitGoogleTest in test main.
- Move test printers to TestPrinter.h/cpp.
- Provide printers for StringRef, EntryNotifier, and Handle.
- StorageTest: Check notifications.
- Add entry notifier unit tests.
- Storage: Add test for incoming entry assignment.
- Update connection listener tests.
- Add entry listener unit tests.
Fixes #11, #140, #189, #190, #192, #193, #221
2017-04-23 10:26:17 -07:00
|
|
|
|
|
|
|
|
class DispatcherBase : public IDispatcher {
|
2015-08-01 11:15:04 -07:00
|
|
|
friend class DispatcherTest;
|
2016-11-03 21:03:45 -07:00
|
|
|
|
2015-07-16 22:55:50 -07:00
|
|
|
public:
|
2021-06-10 11:13:09 -07:00
|
|
|
using Connector = std::function<std::unique_ptr<wpi::NetworkStream>()>;
|
2016-04-08 13:31:35 -07:00
|
|
|
|
Implement independent instances.
Previously, most of the classes were implemented as singletons so only one
instance was possible.
This change adds an instance handle-based API. In Java, this API is located
in a different package than the old API (edu.wpi.first.networktables).
Backwards compatibility with ITable and the old NetworkTable API is largely
maintained, but a handful of classes have moved to the new package in Java
(ConnectionInfo and PersistentException), and the old JNI has been completed
replaced.
Also:
- Move SetTeam implementation to Dispatcher.
- Consistently pass time through Java and C++ Value API.
- Rename nt_Value.h to NetworkTableValue.h for consistency with Java.
- Improve documentation
- Make C++ and Java APIs more consistent
- Document RPC functions and support RPC in Java.
- Add polling features for entry and connection listeners and use them to
move callback threads to Java level.
- Remove thread start and stop hooks (as polling is available).
- Make Notifiers, RpcServer, Dispatcher, and Storage mockable.
- Set NOTIFY_NEW on immediate entry notifications.
- Make GetTable("/") and GetTable("") equivalent.
- Generate local notification for flags update when loading persistent file.
And many unit test updates/changes:
- Use InitGoogleMock instead of InitGoogleTest in test main.
- Move test printers to TestPrinter.h/cpp.
- Provide printers for StringRef, EntryNotifier, and Handle.
- StorageTest: Check notifications.
- Add entry notifier unit tests.
- Storage: Add test for incoming entry assignment.
- Update connection listener tests.
- Add entry listener unit tests.
Fixes #11, #140, #189, #190, #192, #193, #221
2017-04-23 10:26:17 -07:00
|
|
|
DispatcherBase(IStorage& storage, IConnectionNotifier& notifier,
|
|
|
|
|
wpi::Logger& logger);
|
2020-12-28 00:10:13 -08:00
|
|
|
~DispatcherBase() override;
|
2015-07-16 22:55:50 -07:00
|
|
|
|
2017-06-02 20:25:20 -04:00
|
|
|
unsigned int GetNetworkMode() const;
|
2019-12-29 14:56:41 -06:00
|
|
|
void StartLocal();
|
2021-06-06 16:13:58 -07:00
|
|
|
void StartServer(std::string_view persist_filename,
|
2016-07-27 00:39:38 -07:00
|
|
|
std::unique_ptr<wpi::NetworkAcceptor> acceptor);
|
2016-11-04 16:01:42 -07:00
|
|
|
void StartClient();
|
2015-07-16 22:55:50 -07:00
|
|
|
void Stop();
|
|
|
|
|
void SetUpdateRate(double interval);
|
2021-06-06 16:13:58 -07:00
|
|
|
void SetIdentity(std::string_view name);
|
2015-07-17 22:39:36 -07:00
|
|
|
void Flush();
|
2015-08-02 10:47:05 -07:00
|
|
|
std::vector<ConnectionInfo> GetConnections() const;
|
Implement independent instances.
Previously, most of the classes were implemented as singletons so only one
instance was possible.
This change adds an instance handle-based API. In Java, this API is located
in a different package than the old API (edu.wpi.first.networktables).
Backwards compatibility with ITable and the old NetworkTable API is largely
maintained, but a handful of classes have moved to the new package in Java
(ConnectionInfo and PersistentException), and the old JNI has been completed
replaced.
Also:
- Move SetTeam implementation to Dispatcher.
- Consistently pass time through Java and C++ Value API.
- Rename nt_Value.h to NetworkTableValue.h for consistency with Java.
- Improve documentation
- Make C++ and Java APIs more consistent
- Document RPC functions and support RPC in Java.
- Add polling features for entry and connection listeners and use them to
move callback threads to Java level.
- Remove thread start and stop hooks (as polling is available).
- Make Notifiers, RpcServer, Dispatcher, and Storage mockable.
- Set NOTIFY_NEW on immediate entry notifications.
- Make GetTable("/") and GetTable("") equivalent.
- Generate local notification for flags update when loading persistent file.
And many unit test updates/changes:
- Use InitGoogleMock instead of InitGoogleTest in test main.
- Move test printers to TestPrinter.h/cpp.
- Provide printers for StringRef, EntryNotifier, and Handle.
- StorageTest: Check notifications.
- Add entry notifier unit tests.
- Storage: Add test for incoming entry assignment.
- Update connection listener tests.
- Add entry listener unit tests.
Fixes #11, #140, #189, #190, #192, #193, #221
2017-04-23 10:26:17 -07:00
|
|
|
bool IsConnected() const;
|
2015-07-17 22:39:36 -07:00
|
|
|
|
2017-09-30 23:37:02 -07:00
|
|
|
unsigned int AddListener(
|
|
|
|
|
std::function<void(const ConnectionNotification& event)> callback,
|
|
|
|
|
bool immediate_notify) const;
|
|
|
|
|
unsigned int AddPolledListener(unsigned int poller_uid,
|
|
|
|
|
bool immediate_notify) const;
|
|
|
|
|
|
2021-12-12 20:09:57 -08:00
|
|
|
unsigned int StartDataLog(wpi::log::DataLog& log, std::string_view name);
|
|
|
|
|
void StopDataLog(unsigned int logger);
|
|
|
|
|
|
2016-11-04 16:01:42 -07:00
|
|
|
void SetConnector(Connector connector);
|
|
|
|
|
void SetConnectorOverride(Connector connector);
|
|
|
|
|
void ClearConnectorOverride();
|
|
|
|
|
|
2015-07-17 22:39:36 -07:00
|
|
|
bool active() const { return m_active; }
|
2015-07-16 22:55:50 -07:00
|
|
|
|
2015-08-02 00:33:41 -07:00
|
|
|
DispatcherBase(const DispatcherBase&) = delete;
|
|
|
|
|
DispatcherBase& operator=(const DispatcherBase&) = delete;
|
2015-07-16 22:55:50 -07:00
|
|
|
|
2015-08-02 00:33:41 -07:00
|
|
|
private:
|
2015-07-16 22:55:50 -07:00
|
|
|
void DispatchThreadMain();
|
2015-08-02 00:33:41 -07:00
|
|
|
void ServerThreadMain();
|
2016-04-08 13:31:35 -07:00
|
|
|
void ClientThreadMain();
|
2015-07-16 22:55:50 -07:00
|
|
|
|
2015-07-31 20:32:52 -07:00
|
|
|
bool ClientHandshake(
|
|
|
|
|
NetworkConnection& conn,
|
|
|
|
|
std::function<std::shared_ptr<Message>()> get_msg,
|
2021-06-06 19:51:14 -07:00
|
|
|
std::function<void(wpi::span<std::shared_ptr<Message>>)> send_msgs);
|
2015-07-31 20:32:52 -07:00
|
|
|
bool ServerHandshake(
|
|
|
|
|
NetworkConnection& conn,
|
|
|
|
|
std::function<std::shared_ptr<Message>()> get_msg,
|
2021-06-06 19:51:14 -07:00
|
|
|
std::function<void(wpi::span<std::shared_ptr<Message>>)> send_msgs);
|
2015-07-29 20:33:26 -07:00
|
|
|
|
2015-07-31 20:32:52 -07:00
|
|
|
void ClientReconnect(unsigned int proto_rev = 0x0300);
|
2015-07-17 22:39:36 -07:00
|
|
|
|
2017-09-04 22:01:59 -07:00
|
|
|
void QueueOutgoing(std::shared_ptr<Message> msg, INetworkConnection* only,
|
|
|
|
|
INetworkConnection* except) override;
|
2015-07-17 22:39:36 -07:00
|
|
|
|
Implement independent instances.
Previously, most of the classes were implemented as singletons so only one
instance was possible.
This change adds an instance handle-based API. In Java, this API is located
in a different package than the old API (edu.wpi.first.networktables).
Backwards compatibility with ITable and the old NetworkTable API is largely
maintained, but a handful of classes have moved to the new package in Java
(ConnectionInfo and PersistentException), and the old JNI has been completed
replaced.
Also:
- Move SetTeam implementation to Dispatcher.
- Consistently pass time through Java and C++ Value API.
- Rename nt_Value.h to NetworkTableValue.h for consistency with Java.
- Improve documentation
- Make C++ and Java APIs more consistent
- Document RPC functions and support RPC in Java.
- Add polling features for entry and connection listeners and use them to
move callback threads to Java level.
- Remove thread start and stop hooks (as polling is available).
- Make Notifiers, RpcServer, Dispatcher, and Storage mockable.
- Set NOTIFY_NEW on immediate entry notifications.
- Make GetTable("/") and GetTable("") equivalent.
- Generate local notification for flags update when loading persistent file.
And many unit test updates/changes:
- Use InitGoogleMock instead of InitGoogleTest in test main.
- Move test printers to TestPrinter.h/cpp.
- Provide printers for StringRef, EntryNotifier, and Handle.
- StorageTest: Check notifications.
- Add entry notifier unit tests.
- Storage: Add test for incoming entry assignment.
- Update connection listener tests.
- Add entry listener unit tests.
Fixes #11, #140, #189, #190, #192, #193, #221
2017-04-23 10:26:17 -07:00
|
|
|
IStorage& m_storage;
|
|
|
|
|
IConnectionNotifier& m_notifier;
|
2017-06-02 20:25:20 -04:00
|
|
|
unsigned int m_networkMode = NT_NET_MODE_NONE;
|
2015-08-19 19:09:25 -07:00
|
|
|
std::string m_persist_filename;
|
2015-07-16 22:55:50 -07:00
|
|
|
std::thread m_dispatch_thread;
|
|
|
|
|
std::thread m_clientserver_thread;
|
|
|
|
|
|
2016-07-27 00:39:38 -07:00
|
|
|
std::unique_ptr<wpi::NetworkAcceptor> m_server_acceptor;
|
2016-11-04 16:01:42 -07:00
|
|
|
Connector m_client_connector_override;
|
2017-08-13 12:05:29 -07:00
|
|
|
Connector m_client_connector;
|
Implement independent instances.
Previously, most of the classes were implemented as singletons so only one
instance was possible.
This change adds an instance handle-based API. In Java, this API is located
in a different package than the old API (edu.wpi.first.networktables).
Backwards compatibility with ITable and the old NetworkTable API is largely
maintained, but a handful of classes have moved to the new package in Java
(ConnectionInfo and PersistentException), and the old JNI has been completed
replaced.
Also:
- Move SetTeam implementation to Dispatcher.
- Consistently pass time through Java and C++ Value API.
- Rename nt_Value.h to NetworkTableValue.h for consistency with Java.
- Improve documentation
- Make C++ and Java APIs more consistent
- Document RPC functions and support RPC in Java.
- Add polling features for entry and connection listeners and use them to
move callback threads to Java level.
- Remove thread start and stop hooks (as polling is available).
- Make Notifiers, RpcServer, Dispatcher, and Storage mockable.
- Set NOTIFY_NEW on immediate entry notifications.
- Make GetTable("/") and GetTable("") equivalent.
- Generate local notification for flags update when loading persistent file.
And many unit test updates/changes:
- Use InitGoogleMock instead of InitGoogleTest in test main.
- Move test printers to TestPrinter.h/cpp.
- Provide printers for StringRef, EntryNotifier, and Handle.
- StorageTest: Check notifications.
- Add entry notifier unit tests.
- Storage: Add test for incoming entry assignment.
- Update connection listener tests.
- Add entry listener unit tests.
Fixes #11, #140, #189, #190, #192, #193, #221
2017-04-23 10:26:17 -07:00
|
|
|
uint8_t m_connections_uid = 0;
|
2015-07-17 22:39:36 -07:00
|
|
|
|
|
|
|
|
// Mutex for user-accessible items
|
2017-11-13 09:51:05 -08:00
|
|
|
mutable wpi::mutex m_user_mutex;
|
2017-09-04 22:01:59 -07:00
|
|
|
std::vector<std::shared_ptr<INetworkConnection>> m_connections;
|
2015-07-16 22:55:50 -07:00
|
|
|
std::string m_identity;
|
|
|
|
|
|
2016-11-03 21:03:45 -07:00
|
|
|
std::atomic_bool m_active; // set to false to terminate threads
|
2015-07-17 22:39:36 -07:00
|
|
|
std::atomic_uint m_update_rate; // periodic dispatch update rate, in ms
|
|
|
|
|
|
|
|
|
|
// Condition variable for forced dispatch wakeup (flush)
|
2017-11-13 09:51:05 -08:00
|
|
|
wpi::mutex m_flush_mutex;
|
|
|
|
|
wpi::condition_variable m_flush_cv;
|
2021-01-25 08:15:08 -08:00
|
|
|
uint64_t m_last_flush = 0;
|
2015-08-19 21:16:44 -07:00
|
|
|
bool m_do_flush = false;
|
2015-07-17 22:39:36 -07:00
|
|
|
|
2015-07-31 23:14:26 -07:00
|
|
|
// Condition variable for client reconnect (uses user mutex)
|
2017-11-13 09:51:05 -08:00
|
|
|
wpi::condition_variable m_reconnect_cv;
|
2015-08-19 21:16:44 -07:00
|
|
|
unsigned int m_reconnect_proto_rev = 0x0300;
|
|
|
|
|
bool m_do_reconnect = true;
|
Implement independent instances.
Previously, most of the classes were implemented as singletons so only one
instance was possible.
This change adds an instance handle-based API. In Java, this API is located
in a different package than the old API (edu.wpi.first.networktables).
Backwards compatibility with ITable and the old NetworkTable API is largely
maintained, but a handful of classes have moved to the new package in Java
(ConnectionInfo and PersistentException), and the old JNI has been completed
replaced.
Also:
- Move SetTeam implementation to Dispatcher.
- Consistently pass time through Java and C++ Value API.
- Rename nt_Value.h to NetworkTableValue.h for consistency with Java.
- Improve documentation
- Make C++ and Java APIs more consistent
- Document RPC functions and support RPC in Java.
- Add polling features for entry and connection listeners and use them to
move callback threads to Java level.
- Remove thread start and stop hooks (as polling is available).
- Make Notifiers, RpcServer, Dispatcher, and Storage mockable.
- Set NOTIFY_NEW on immediate entry notifications.
- Make GetTable("/") and GetTable("") equivalent.
- Generate local notification for flags update when loading persistent file.
And many unit test updates/changes:
- Use InitGoogleMock instead of InitGoogleTest in test main.
- Move test printers to TestPrinter.h/cpp.
- Provide printers for StringRef, EntryNotifier, and Handle.
- StorageTest: Check notifications.
- Add entry notifier unit tests.
- Storage: Add test for incoming entry assignment.
- Update connection listener tests.
- Add entry listener unit tests.
Fixes #11, #140, #189, #190, #192, #193, #221
2017-04-23 10:26:17 -07:00
|
|
|
|
2021-12-12 20:09:57 -08:00
|
|
|
struct DataLogger {
|
|
|
|
|
DataLogger() = default;
|
|
|
|
|
DataLogger(wpi::log::DataLog& log, std::string_view name, int64_t time)
|
|
|
|
|
: entry{log, name,
|
|
|
|
|
"{\"schema\":\"NTConnectionInfo\",\"source\":\"NT\"}", "json",
|
|
|
|
|
time} {}
|
|
|
|
|
|
|
|
|
|
explicit operator bool() const { return static_cast<bool>(entry); }
|
|
|
|
|
|
|
|
|
|
wpi::log::StringLogEntry entry;
|
|
|
|
|
unsigned int notifier = 0;
|
|
|
|
|
};
|
|
|
|
|
wpi::UidVector<DataLogger, 4> m_dataloggers;
|
|
|
|
|
|
Implement independent instances.
Previously, most of the classes were implemented as singletons so only one
instance was possible.
This change adds an instance handle-based API. In Java, this API is located
in a different package than the old API (edu.wpi.first.networktables).
Backwards compatibility with ITable and the old NetworkTable API is largely
maintained, but a handful of classes have moved to the new package in Java
(ConnectionInfo and PersistentException), and the old JNI has been completed
replaced.
Also:
- Move SetTeam implementation to Dispatcher.
- Consistently pass time through Java and C++ Value API.
- Rename nt_Value.h to NetworkTableValue.h for consistency with Java.
- Improve documentation
- Make C++ and Java APIs more consistent
- Document RPC functions and support RPC in Java.
- Add polling features for entry and connection listeners and use them to
move callback threads to Java level.
- Remove thread start and stop hooks (as polling is available).
- Make Notifiers, RpcServer, Dispatcher, and Storage mockable.
- Set NOTIFY_NEW on immediate entry notifications.
- Make GetTable("/") and GetTable("") equivalent.
- Generate local notification for flags update when loading persistent file.
And many unit test updates/changes:
- Use InitGoogleMock instead of InitGoogleTest in test main.
- Move test printers to TestPrinter.h/cpp.
- Provide printers for StringRef, EntryNotifier, and Handle.
- StorageTest: Check notifications.
- Add entry notifier unit tests.
- Storage: Add test for incoming entry assignment.
- Update connection listener tests.
- Add entry listener unit tests.
Fixes #11, #140, #189, #190, #192, #193, #221
2017-04-23 10:26:17 -07:00
|
|
|
protected:
|
|
|
|
|
wpi::Logger& m_logger;
|
2015-08-02 00:33:41 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class Dispatcher : public DispatcherBase {
|
|
|
|
|
friend class DispatcherTest;
|
2016-11-03 21:03:45 -07:00
|
|
|
|
2015-08-02 00:33:41 -07:00
|
|
|
public:
|
Implement independent instances.
Previously, most of the classes were implemented as singletons so only one
instance was possible.
This change adds an instance handle-based API. In Java, this API is located
in a different package than the old API (edu.wpi.first.networktables).
Backwards compatibility with ITable and the old NetworkTable API is largely
maintained, but a handful of classes have moved to the new package in Java
(ConnectionInfo and PersistentException), and the old JNI has been completed
replaced.
Also:
- Move SetTeam implementation to Dispatcher.
- Consistently pass time through Java and C++ Value API.
- Rename nt_Value.h to NetworkTableValue.h for consistency with Java.
- Improve documentation
- Make C++ and Java APIs more consistent
- Document RPC functions and support RPC in Java.
- Add polling features for entry and connection listeners and use them to
move callback threads to Java level.
- Remove thread start and stop hooks (as polling is available).
- Make Notifiers, RpcServer, Dispatcher, and Storage mockable.
- Set NOTIFY_NEW on immediate entry notifications.
- Make GetTable("/") and GetTable("") equivalent.
- Generate local notification for flags update when loading persistent file.
And many unit test updates/changes:
- Use InitGoogleMock instead of InitGoogleTest in test main.
- Move test printers to TestPrinter.h/cpp.
- Provide printers for StringRef, EntryNotifier, and Handle.
- StorageTest: Check notifications.
- Add entry notifier unit tests.
- Storage: Add test for incoming entry assignment.
- Update connection listener tests.
- Add entry listener unit tests.
Fixes #11, #140, #189, #190, #192, #193, #221
2017-04-23 10:26:17 -07:00
|
|
|
Dispatcher(IStorage& storage, IConnectionNotifier& notifier,
|
|
|
|
|
wpi::Logger& logger)
|
|
|
|
|
: DispatcherBase(storage, notifier, logger) {}
|
2015-08-02 00:33:41 -07:00
|
|
|
|
2021-06-06 16:13:58 -07:00
|
|
|
void StartServer(std::string_view persist_filename,
|
2021-04-04 12:40:46 -07:00
|
|
|
const char* listen_address, unsigned int port);
|
2016-11-04 16:01:42 -07:00
|
|
|
|
|
|
|
|
void SetServer(const char* server_name, unsigned int port);
|
2021-04-04 12:40:46 -07:00
|
|
|
void SetServer(
|
2021-06-06 19:51:14 -07:00
|
|
|
wpi::span<const std::pair<std::string_view, unsigned int>> servers);
|
Implement independent instances.
Previously, most of the classes were implemented as singletons so only one
instance was possible.
This change adds an instance handle-based API. In Java, this API is located
in a different package than the old API (edu.wpi.first.networktables).
Backwards compatibility with ITable and the old NetworkTable API is largely
maintained, but a handful of classes have moved to the new package in Java
(ConnectionInfo and PersistentException), and the old JNI has been completed
replaced.
Also:
- Move SetTeam implementation to Dispatcher.
- Consistently pass time through Java and C++ Value API.
- Rename nt_Value.h to NetworkTableValue.h for consistency with Java.
- Improve documentation
- Make C++ and Java APIs more consistent
- Document RPC functions and support RPC in Java.
- Add polling features for entry and connection listeners and use them to
move callback threads to Java level.
- Remove thread start and stop hooks (as polling is available).
- Make Notifiers, RpcServer, Dispatcher, and Storage mockable.
- Set NOTIFY_NEW on immediate entry notifications.
- Make GetTable("/") and GetTable("") equivalent.
- Generate local notification for flags update when loading persistent file.
And many unit test updates/changes:
- Use InitGoogleMock instead of InitGoogleTest in test main.
- Move test printers to TestPrinter.h/cpp.
- Provide printers for StringRef, EntryNotifier, and Handle.
- StorageTest: Check notifications.
- Add entry notifier unit tests.
- Storage: Add test for incoming entry assignment.
- Update connection listener tests.
- Add entry listener unit tests.
Fixes #11, #140, #189, #190, #192, #193, #221
2017-04-23 10:26:17 -07:00
|
|
|
void SetServerTeam(unsigned int team, unsigned int port);
|
2016-11-04 16:01:42 -07:00
|
|
|
|
|
|
|
|
void SetServerOverride(const char* server_name, unsigned int port);
|
|
|
|
|
void ClearServerOverride();
|
2015-07-16 22:55:50 -07:00
|
|
|
};
|
|
|
|
|
|
2015-07-17 07:21:07 -07:00
|
|
|
} // namespace nt
|
2015-07-16 22:55:50 -07:00
|
|
|
|
2017-08-19 23:08:27 -07:00
|
|
|
#endif // NTCORE_DISPATCHER_H_
|