Adds SetDefault methods to NetworkTables (#54)

There was no way to atomically check for a key in the table,
and then setting if it if non existant. Back before persistent
this was not a problem, however now it is, as its possible for
values to be added before team's robot programs start. This makes
the old method of calling Put*** methods in RobotInit invalid.
This adds SetDefault methods, which do this atomically.
This commit is contained in:
Thad House
2016-07-13 00:31:03 -07:00
committed by Peter Johnson
parent 6615a34e99
commit 58092c5190
15 changed files with 785 additions and 1 deletions

View File

@@ -96,6 +96,17 @@ struct RpcCallInfo {
*/
std::shared_ptr<Value> GetEntryValue(StringRef name);
/** Set Default Entry Value
* Returns copy of current entry value if it exists.
* Otherwise, sets passed in value, and returns set value.
* Note that one of the type options is "unassigned".
*
* @param name entry name (UTF-8 string)
* @param value value to be set if name does not exist
* @return False on error (value not set), True on success
*/
bool SetDefaultEntryValue(StringRef name, std::shared_ptr<Value> value);
/** Set Entry Value.
* Sets new entry value. If type of new value differs from the type of the
* currently stored entry, returns error and does not update value.