mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +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:
@@ -5,7 +5,7 @@
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "nt_Value.h"
|
||||
#include "networktables/NetworkTableValue.h"
|
||||
#include "Value_internal.h"
|
||||
#include "support/timestamp.h"
|
||||
|
||||
@@ -16,9 +16,12 @@ Value::Value() {
|
||||
m_val.last_change = wpi::Now();
|
||||
}
|
||||
|
||||
Value::Value(NT_Type type, const private_init&) {
|
||||
Value::Value(NT_Type type, unsigned long long time, const private_init&) {
|
||||
m_val.type = type;
|
||||
m_val.last_change = wpi::Now();
|
||||
if (time == 0)
|
||||
m_val.last_change = wpi::Now();
|
||||
else
|
||||
m_val.last_change = time;
|
||||
if (m_val.type == NT_BOOLEAN_ARRAY)
|
||||
m_val.data.arr_boolean.arr = nullptr;
|
||||
else if (m_val.type == NT_DOUBLE_ARRAY)
|
||||
@@ -36,16 +39,18 @@ Value::~Value() {
|
||||
delete[] m_val.data.arr_string.arr;
|
||||
}
|
||||
|
||||
std::shared_ptr<Value> Value::MakeBooleanArray(llvm::ArrayRef<int> value) {
|
||||
auto val = std::make_shared<Value>(NT_BOOLEAN_ARRAY, private_init());
|
||||
std::shared_ptr<Value> Value::MakeBooleanArray(llvm::ArrayRef<int> value,
|
||||
unsigned long long time) {
|
||||
auto val = std::make_shared<Value>(NT_BOOLEAN_ARRAY, time, private_init());
|
||||
val->m_val.data.arr_boolean.arr = new int[value.size()];
|
||||
val->m_val.data.arr_boolean.size = value.size();
|
||||
std::copy(value.begin(), value.end(), val->m_val.data.arr_boolean.arr);
|
||||
return val;
|
||||
}
|
||||
|
||||
std::shared_ptr<Value> Value::MakeDoubleArray(llvm::ArrayRef<double> value) {
|
||||
auto val = std::make_shared<Value>(NT_DOUBLE_ARRAY, private_init());
|
||||
std::shared_ptr<Value> Value::MakeDoubleArray(llvm::ArrayRef<double> value,
|
||||
unsigned long long time) {
|
||||
auto val = std::make_shared<Value>(NT_DOUBLE_ARRAY, time, private_init());
|
||||
val->m_val.data.arr_double.arr = new double[value.size()];
|
||||
val->m_val.data.arr_double.size = value.size();
|
||||
std::copy(value.begin(), value.end(), val->m_val.data.arr_double.arr);
|
||||
@@ -53,8 +58,8 @@ std::shared_ptr<Value> Value::MakeDoubleArray(llvm::ArrayRef<double> value) {
|
||||
}
|
||||
|
||||
std::shared_ptr<Value> Value::MakeStringArray(
|
||||
llvm::ArrayRef<std::string> value) {
|
||||
auto val = std::make_shared<Value>(NT_STRING_ARRAY, private_init());
|
||||
llvm::ArrayRef<std::string> value, unsigned long long time) {
|
||||
auto val = std::make_shared<Value>(NT_STRING_ARRAY, time, private_init());
|
||||
val->m_string_array = value;
|
||||
// point NT_Value to the contents in the vector.
|
||||
val->m_val.data.arr_string.arr = new NT_String[value.size()];
|
||||
@@ -67,8 +72,8 @@ std::shared_ptr<Value> Value::MakeStringArray(
|
||||
}
|
||||
|
||||
std::shared_ptr<Value> Value::MakeStringArray(
|
||||
std::vector<std::string>&& value) {
|
||||
auto val = std::make_shared<Value>(NT_STRING_ARRAY, private_init());
|
||||
std::vector<std::string>&& value, unsigned long long time) {
|
||||
auto val = std::make_shared<Value>(NT_STRING_ARRAY, time, private_init());
|
||||
val->m_string_array = std::move(value);
|
||||
value.clear();
|
||||
// point NT_Value to the contents in the vector.
|
||||
|
||||
Reference in New Issue
Block a user