mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-30 02:31:44 +00: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
This commit is contained in:
@@ -18,12 +18,13 @@
|
||||
#include "ntcore_cpp.h"
|
||||
|
||||
namespace wpi {
|
||||
class Logger;
|
||||
class NetworkStream;
|
||||
}
|
||||
|
||||
namespace nt {
|
||||
|
||||
class Notifier;
|
||||
class IConnectionNotifier;
|
||||
|
||||
class NetworkConnection {
|
||||
public:
|
||||
@@ -40,8 +41,10 @@ class NetworkConnection {
|
||||
typedef std::vector<std::shared_ptr<Message>> Outgoing;
|
||||
typedef wpi::ConcurrentQueue<Outgoing> OutgoingQueue;
|
||||
|
||||
NetworkConnection(std::unique_ptr<wpi::NetworkStream> stream,
|
||||
Notifier& notifier, HandshakeFunc handshake,
|
||||
NetworkConnection(unsigned int uid,
|
||||
std::unique_ptr<wpi::NetworkStream> stream,
|
||||
IConnectionNotifier& notifier, wpi::Logger& logger,
|
||||
HandshakeFunc handshake,
|
||||
Message::GetEntryTypeFunc get_entry_type);
|
||||
~NetworkConnection();
|
||||
|
||||
@@ -60,7 +63,6 @@ class NetworkConnection {
|
||||
|
||||
void QueueOutgoing(std::shared_ptr<Message> msg);
|
||||
void PostOutgoing(bool keep_alive);
|
||||
void NotifyIfActive(ConnectionListenerCallback callback) const;
|
||||
|
||||
unsigned int uid() const { return m_uid; }
|
||||
|
||||
@@ -82,11 +84,10 @@ class NetworkConnection {
|
||||
void ReadThreadMain();
|
||||
void WriteThreadMain();
|
||||
|
||||
static std::atomic_uint s_uid;
|
||||
|
||||
unsigned int m_uid;
|
||||
std::unique_ptr<wpi::NetworkStream> m_stream;
|
||||
Notifier& m_notifier;
|
||||
IConnectionNotifier& m_notifier;
|
||||
wpi::Logger& m_logger;
|
||||
OutgoingQueue m_outgoing;
|
||||
HandshakeFunc m_handshake;
|
||||
Message::GetEntryTypeFunc m_get_entry_type;
|
||||
|
||||
Reference in New Issue
Block a user