[ntcore] Allow numeric-compatible value sets (#4620)

Also fix entry publishing behavior to allow numerically compatible set
default publish following a subscribe.
This commit is contained in:
Peter Johnson
2022-11-18 22:46:24 -08:00
committed by GitHub
parent 88bd67e7de
commit e962fd2916
8 changed files with 476 additions and 56 deletions

View File

@@ -89,6 +89,15 @@ Value Value::MakeBooleanArray(std::span<const int> value, int64_t time) {
return val;
}
Value Value::MakeBooleanArray(std::vector<int>&& value, int64_t time) {
Value val{NT_BOOLEAN_ARRAY, time, private_init{}};
auto data = std::make_shared<std::vector<int>>(std::move(value));
val.m_val.data.arr_boolean.arr = data->data();
val.m_val.data.arr_boolean.size = data->size();
val.m_storage = std::move(data);
return val;
}
Value Value::MakeIntegerArray(std::span<const int64_t> value, int64_t time) {
Value val{NT_INTEGER_ARRAY, time, private_init{}};
auto data =
@@ -99,6 +108,15 @@ Value Value::MakeIntegerArray(std::span<const int64_t> value, int64_t time) {
return val;
}
Value Value::MakeIntegerArray(std::vector<int64_t>&& value, int64_t time) {
Value val{NT_INTEGER_ARRAY, time, private_init{}};
auto data = std::make_shared<std::vector<int64_t>>(std::move(value));
val.m_val.data.arr_int.arr = data->data();
val.m_val.data.arr_int.size = data->size();
val.m_storage = std::move(data);
return val;
}
Value Value::MakeFloatArray(std::span<const float> value, int64_t time) {
Value val{NT_FLOAT_ARRAY, time, private_init{}};
auto data = std::make_shared<std::vector<float>>(value.begin(), value.end());
@@ -108,6 +126,15 @@ Value Value::MakeFloatArray(std::span<const float> value, int64_t time) {
return val;
}
Value Value::MakeFloatArray(std::vector<float>&& value, int64_t time) {
Value val{NT_FLOAT_ARRAY, time, private_init{}};
auto data = std::make_shared<std::vector<float>>(std::move(value));
val.m_val.data.arr_float.arr = data->data();
val.m_val.data.arr_float.size = data->size();
val.m_storage = std::move(data);
return val;
}
Value Value::MakeDoubleArray(std::span<const double> value, int64_t time) {
Value val{NT_DOUBLE_ARRAY, time, private_init{}};
auto data = std::make_shared<std::vector<double>>(value.begin(), value.end());
@@ -117,6 +144,15 @@ Value Value::MakeDoubleArray(std::span<const double> value, int64_t time) {
return val;
}
Value Value::MakeDoubleArray(std::vector<double>&& value, int64_t time) {
Value val{NT_DOUBLE_ARRAY, time, private_init{}};
auto data = std::make_shared<std::vector<double>>(std::move(value));
val.m_val.data.arr_double.arr = data->data();
val.m_val.data.arr_double.size = data->size();
val.m_storage = std::move(data);
return val;
}
Value Value::MakeStringArray(std::span<const std::string> value, int64_t time) {
Value val{NT_STRING_ARRAY, time, private_init{}};
auto data = std::make_shared<StringArrayStorage>(value);