mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +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:
@@ -10,10 +10,10 @@
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include "nt_Value.h"
|
||||
#include "networktables/NetworkTableValue.h"
|
||||
#include "support/leb128.h"
|
||||
#include "support/raw_istream.h"
|
||||
//#include "Log.h"
|
||||
#include "Log.h"
|
||||
|
||||
namespace nt {
|
||||
|
||||
@@ -26,7 +26,8 @@ namespace nt {
|
||||
*/
|
||||
class WireDecoder {
|
||||
public:
|
||||
explicit WireDecoder(wpi::raw_istream& is, unsigned int proto_rev);
|
||||
WireDecoder(wpi::raw_istream& is, unsigned int proto_rev,
|
||||
wpi::Logger& logger);
|
||||
~WireDecoder();
|
||||
|
||||
void set_proto_rev(unsigned int proto_rev) { m_proto_rev = proto_rev; }
|
||||
@@ -34,6 +35,9 @@ class WireDecoder {
|
||||
/* Get the active protocol revision. */
|
||||
unsigned int proto_rev() const { return m_proto_rev; }
|
||||
|
||||
/* Get the logger. */
|
||||
wpi::Logger& logger() const { return m_logger; }
|
||||
|
||||
/* Clears error indicator. */
|
||||
void Reset() { m_error = nullptr; }
|
||||
|
||||
@@ -54,8 +58,7 @@ class WireDecoder {
|
||||
*buf = m_buf;
|
||||
m_is.read(m_buf, len);
|
||||
#if 0
|
||||
nt::Logger& logger = nt::Logger::GetInstance();
|
||||
if (logger.min_level() <= NT_LOG_DEBUG4 && logger.HasLogger()) {
|
||||
if (m_logger.min_level() <= NT_LOG_DEBUG4 && m_logger.HasLogger()) {
|
||||
std::ostringstream oss;
|
||||
oss << "read " << len << " bytes:" << std::hex;
|
||||
if (!rv)
|
||||
@@ -64,7 +67,7 @@ class WireDecoder {
|
||||
for (std::size_t i=0; i < len; ++i)
|
||||
oss << ' ' << (unsigned int)((*buf)[i]);
|
||||
}
|
||||
logger.Log(NT_LOG_DEBUG4, __FILE__, __LINE__, oss.str().c_str());
|
||||
m_logger.Log(NT_LOG_DEBUG4, __FILE__, __LINE__, oss.str().c_str());
|
||||
}
|
||||
#endif
|
||||
return !m_is.has_error();
|
||||
@@ -135,6 +138,9 @@ class WireDecoder {
|
||||
/* input stream */
|
||||
wpi::raw_istream& m_is;
|
||||
|
||||
/* logger */
|
||||
wpi::Logger& m_logger;
|
||||
|
||||
/* temporary buffer */
|
||||
char* m_buf;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user