WPILibC++  2019.3.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
nt::NetworkTableEntry Class Referencefinal

NetworkTables Entry. More...

#include <NetworkTableEntry.h>

Public Types

enum  Flags { kPersistent = NT_PERSISTENT }
 Flag values (as returned by GetFlags()).
 

Public Member Functions

 NetworkTableEntry ()
 Construct invalid instance.
 
 NetworkTableEntry (NT_Entry handle)
 Construct from native handle. More...
 
 operator bool () const
 Determines if the native handle is valid. More...
 
NT_Entry GetHandle () const
 Gets the native handle for the entry. More...
 
NetworkTableInstance GetInstance () const
 Gets the instance for the entry. More...
 
bool Exists () const
 Determines if the entry currently exists. More...
 
std::string GetName () const
 Gets the name of the entry (the key). More...
 
NetworkTableType GetType () const
 Gets the type of the entry. More...
 
unsigned int GetFlags () const
 Returns the flags. More...
 
uint64_t GetLastChange () const
 Gets the last time the entry's value was changed. More...
 
EntryInfo GetInfo () const
 Gets combined information about the entry. More...
 
std::shared_ptr< ValueGetValue () const
 Gets the entry's value. More...
 
bool GetBoolean (bool defaultValue) const
 Gets the entry's value as a boolean. More...
 
double GetDouble (double defaultValue) const
 Gets the entry's value as a double. More...
 
std::string GetString (StringRef defaultValue) const
 Gets the entry's value as a string. More...
 
std::string GetRaw (StringRef defaultValue) const
 Gets the entry's value as a raw. More...
 
std::vector< int > GetBooleanArray (ArrayRef< int > defaultValue) const
 Gets the entry's value as a boolean array. More...
 
std::vector< double > GetDoubleArray (ArrayRef< double > defaultValue) const
 Gets the entry's value as a double array. More...
 
std::vector< std::string > GetStringArray (ArrayRef< std::string > defaultValue) const
 Gets the entry's value as a string array. More...
 
bool SetDefaultValue (std::shared_ptr< Value > value)
 Sets the entry's value if it does not exist. More...
 
bool SetDefaultBoolean (bool defaultValue)
 Sets the entry's value if it does not exist. More...
 
bool SetDefaultDouble (double defaultValue)
 Sets the entry's value if it does not exist. More...
 
bool SetDefaultString (const Twine &defaultValue)
 Sets the entry's value if it does not exist. More...
 
bool SetDefaultRaw (StringRef defaultValue)
 Sets the entry's value if it does not exist. More...
 
bool SetDefaultBooleanArray (ArrayRef< int > defaultValue)
 Sets the entry's value if it does not exist. More...
 
bool SetDefaultDoubleArray (ArrayRef< double > defaultValue)
 Sets the entry's value if it does not exist. More...
 
bool SetDefaultStringArray (ArrayRef< std::string > defaultValue)
 Sets the entry's value if it does not exist. More...
 
bool SetValue (std::shared_ptr< Value > value)
 Sets the entry's value. More...
 
bool SetBoolean (bool value)
 Sets the entry's value. More...
 
bool SetDouble (double value)
 Sets the entry's value. More...
 
bool SetString (const Twine &value)
 Sets the entry's value. More...
 
bool SetRaw (StringRef value)
 Sets the entry's value. More...
 
bool SetBooleanArray (ArrayRef< int > value)
 Sets the entry's value. More...
 
bool SetDoubleArray (ArrayRef< double > value)
 Sets the entry's value. More...
 
bool SetStringArray (ArrayRef< std::string > value)
 Sets the entry's value. More...
 
void ForceSetValue (std::shared_ptr< Value > value)
 Sets the entry's value. More...
 
void ForceSetBoolean (bool value)
 Sets the entry's value. More...
 
void ForceSetDouble (double value)
 Sets the entry's value. More...
 
void ForceSetString (const Twine &value)
 Sets the entry's value. More...
 
void ForceSetRaw (StringRef value)
 Sets the entry's value. More...
 
void ForceSetBooleanArray (ArrayRef< int > value)
 Sets the entry's value. More...
 
void ForceSetDoubleArray (ArrayRef< double > value)
 Sets the entry's value. More...
 
void ForceSetStringArray (ArrayRef< std::string > value)
 Sets the entry's value. More...
 
void SetFlags (unsigned int flags)
 Sets flags. More...
 
void ClearFlags (unsigned int flags)
 Clears flags. More...
 
void SetPersistent ()
 Make value persistent through program restarts.
 
void ClearPersistent ()
 Stop making value persistent through program restarts.
 
bool IsPersistent () const
 Returns whether the value is persistent through program restarts. More...
 
void Delete ()
 Deletes the entry.
 
void CreateRpc (std::function< void(const RpcAnswer &answer)> callback)
 Create a callback-based RPC entry point. More...
 
void CreatePolledRpc ()
 Create a polled RPC entry point. More...
 
RpcCall CallRpc (StringRef params)
 Call a RPC function. More...
 
NT_EntryListener AddListener (std::function< void(const EntryNotification &event)> callback, unsigned int flags) const
 Add a listener for changes to this entry. More...
 
void RemoveListener (NT_EntryListener entry_listener)
 Remove an entry listener. More...
 
bool operator== (const NetworkTableEntry &oth) const
 Equality operator. More...
 
bool operator!= (const NetworkTableEntry &oth) const
 Inequality operator. More...
 

Protected Attributes

NT_Entry m_handle
 

Detailed Description

NetworkTables Entry.

Constructor & Destructor Documentation

nt::NetworkTableEntry::NetworkTableEntry ( NT_Entry  handle)
inlineexplicit

Construct from native handle.

Parameters
handleNative handle

Member Function Documentation

NT_EntryListener nt::NetworkTableEntry::AddListener ( std::function< void(const EntryNotification &event)>  callback,
unsigned int  flags 
) const
inline

Add a listener for changes to this entry.

Parameters
callbacklistener to add
flagsNotifyKind bitmask
Returns
Listener handle
RpcCall nt::NetworkTableEntry::CallRpc ( StringRef  params)
inline

Call a RPC function.

May be used on either the client or server. This function is non-blocking. Either RpcCall::GetResult() or RpcCall::CancelResult() must be called on the return value to either get or ignore the result of the call.

Parameters
paramsparameter
Returns
RPC call object.
void nt::NetworkTableEntry::ClearFlags ( unsigned int  flags)
inline

Clears flags.

Parameters
flagsthe flags to clear (bitmask)
void nt::NetworkTableEntry::CreatePolledRpc ( )

Create a polled RPC entry point.

Only valid to use on the server. The caller is responsible for calling NetworkTableInstance::PollRpc() to poll for servicing incoming RPC calls. This function creates RPC version 0 definitions (raw data in and out).

void nt::NetworkTableEntry::CreateRpc ( std::function< void(const RpcAnswer &answer)>  callback)
inline

Create a callback-based RPC entry point.

Only valid to use on the server. The callback function will be called when the RPC is called. This function creates RPC version 0 definitions (raw data in and out).

Parameters
callbackcallback function
bool nt::NetworkTableEntry::Exists ( ) const
inline

Determines if the entry currently exists.

Returns
True if the entry exists, false otherwise.
void nt::NetworkTableEntry::ForceSetBoolean ( bool  value)
inline

Sets the entry's value.

If the value is of different type, the type is changed to match the new value.

Parameters
valuethe value to set
void nt::NetworkTableEntry::ForceSetBooleanArray ( ArrayRef< int >  value)
inline

Sets the entry's value.

If the value is of different type, the type is changed to match the new value.

Parameters
valuethe value to set
void nt::NetworkTableEntry::ForceSetDouble ( double  value)
inline

Sets the entry's value.

If the value is of different type, the type is changed to match the new value.

Parameters
valuethe value to set
void nt::NetworkTableEntry::ForceSetDoubleArray ( ArrayRef< double >  value)
inline

Sets the entry's value.

If the value is of different type, the type is changed to match the new value.

Parameters
valuethe value to set
void nt::NetworkTableEntry::ForceSetRaw ( StringRef  value)
inline

Sets the entry's value.

If the value is of different type, the type is changed to match the new value.

Parameters
valuethe value to set
void nt::NetworkTableEntry::ForceSetString ( const Twine value)
inline

Sets the entry's value.

If the value is of different type, the type is changed to match the new value.

Parameters
valuethe value to set
void nt::NetworkTableEntry::ForceSetStringArray ( ArrayRef< std::string >  value)
inline

Sets the entry's value.

If the value is of different type, the type is changed to match the new value.

Parameters
valuethe value to set
void nt::NetworkTableEntry::ForceSetValue ( std::shared_ptr< Value value)
inline

Sets the entry's value.

If the value is of different type, the type is changed to match the new value.

Parameters
valuethe value to set
bool nt::NetworkTableEntry::GetBoolean ( bool  defaultValue) const
inline

Gets the entry's value as a boolean.

If the entry does not exist or is of different type, it will return the default value.

Parameters
defaultValuethe value to be returned if no value is found
Returns
the entry's value or the given default value
std::vector< int > nt::NetworkTableEntry::GetBooleanArray ( ArrayRef< int >  defaultValue) const
inline

Gets the entry's value as a boolean array.

If the entry does not exist or is of different type, it will return the default value.

Parameters
defaultValuethe value to be returned if no value is found
Returns
the entry's value or the given default value
Note
This makes a copy of the array. If the overhead of this is a concern, use GetValue() instead.
The returned array is std::vector<int> instead of std::vector<bool> because std::vector<bool> is special-cased in C++. 0 is false, any non-zero value is true.
double nt::NetworkTableEntry::GetDouble ( double  defaultValue) const
inline

Gets the entry's value as a double.

If the entry does not exist or is of different type, it will return the default value.

Parameters
defaultValuethe value to be returned if no value is found
Returns
the entry's value or the given default value
std::vector< double > nt::NetworkTableEntry::GetDoubleArray ( ArrayRef< double >  defaultValue) const
inline

Gets the entry's value as a double array.

If the entry does not exist or is of different type, it will return the default value.

Parameters
defaultValuethe value to be returned if no value is found
Returns
the entry's value or the given default value
Note
This makes a copy of the array. If the overhead of this is a concern, use GetValue() instead.
unsigned int nt::NetworkTableEntry::GetFlags ( ) const
inline

Returns the flags.

Returns
the flags (bitmask)
NT_Entry nt::NetworkTableEntry::GetHandle ( ) const
inline

Gets the native handle for the entry.

Returns
Native handle
EntryInfo nt::NetworkTableEntry::GetInfo ( ) const
inline

Gets combined information about the entry.

Returns
Entry information
NetworkTableInstance nt::NetworkTableEntry::GetInstance ( ) const

Gets the instance for the entry.

Returns
Instance
uint64_t nt::NetworkTableEntry::GetLastChange ( ) const
inline

Gets the last time the entry's value was changed.

Returns
Entry last change time
std::string nt::NetworkTableEntry::GetName ( ) const
inline

Gets the name of the entry (the key).

Returns
the entry's name
std::string nt::NetworkTableEntry::GetRaw ( StringRef  defaultValue) const
inline

Gets the entry's value as a raw.

If the entry does not exist or is of different type, it will return the default value.

Parameters
defaultValuethe value to be returned if no value is found
Returns
the entry's value or the given default value
std::string nt::NetworkTableEntry::GetString ( StringRef  defaultValue) const
inline

Gets the entry's value as a string.

If the entry does not exist or is of different type, it will return the default value.

Parameters
defaultValuethe value to be returned if no value is found
Returns
the entry's value or the given default value
std::vector< std::string > nt::NetworkTableEntry::GetStringArray ( ArrayRef< std::string >  defaultValue) const
inline

Gets the entry's value as a string array.

If the entry does not exist or is of different type, it will return the default value.

Parameters
defaultValuethe value to be returned if no value is found
Returns
the entry's value or the given default value
Note
This makes a copy of the array. If the overhead of this is a concern, use GetValue() instead.
NetworkTableType nt::NetworkTableEntry::GetType ( ) const
inline

Gets the type of the entry.

Returns
the entry's type
std::shared_ptr< Value > nt::NetworkTableEntry::GetValue ( ) const
inline

Gets the entry's value.

If the entry does not exist, returns nullptr.

Returns
the entry's value or nullptr if it does not exist.
bool nt::NetworkTableEntry::IsPersistent ( ) const
inline

Returns whether the value is persistent through program restarts.

Returns
True if the value is persistent.
nt::NetworkTableEntry::operator bool ( ) const
inlineexplicit

Determines if the native handle is valid.

Returns
True if the native handle is valid, false otherwise.
bool nt::NetworkTableEntry::operator!= ( const NetworkTableEntry oth) const
inline

Inequality operator.

bool nt::NetworkTableEntry::operator== ( const NetworkTableEntry oth) const
inline

Equality operator.

Returns true if both instances refer to the same native handle.

void nt::NetworkTableEntry::RemoveListener ( NT_EntryListener  entry_listener)
inline

Remove an entry listener.

Parameters
entry_listenerListener handle to remove
bool nt::NetworkTableEntry::SetBoolean ( bool  value)
inline

Sets the entry's value.

Parameters
valuethe value to set
Returns
False if the entry exists with a different type
bool nt::NetworkTableEntry::SetBooleanArray ( ArrayRef< int >  value)
inline

Sets the entry's value.

Parameters
valuethe value to set
Returns
False if the entry exists with a different type
bool nt::NetworkTableEntry::SetDefaultBoolean ( bool  defaultValue)
inline

Sets the entry's value if it does not exist.

Parameters
defaultValuethe default value to set
Returns
False if the entry exists with a different type
bool nt::NetworkTableEntry::SetDefaultBooleanArray ( ArrayRef< int >  defaultValue)
inline

Sets the entry's value if it does not exist.

Parameters
defaultValuethe default value to set
Returns
False if the entry exists with a different type
bool nt::NetworkTableEntry::SetDefaultDouble ( double  defaultValue)
inline

Sets the entry's value if it does not exist.

Parameters
defaultValuethe default value to set
Returns
False if the entry exists with a different type
bool nt::NetworkTableEntry::SetDefaultDoubleArray ( ArrayRef< double >  defaultValue)
inline

Sets the entry's value if it does not exist.

Parameters
defaultValuethe default value to set
Returns
False if the entry exists with a different type
bool nt::NetworkTableEntry::SetDefaultRaw ( StringRef  defaultValue)
inline

Sets the entry's value if it does not exist.

Parameters
defaultValuethe default value to set
Returns
False if the entry exists with a different type
bool nt::NetworkTableEntry::SetDefaultString ( const Twine defaultValue)
inline

Sets the entry's value if it does not exist.

Parameters
defaultValuethe default value to set
Returns
False if the entry exists with a different type
bool nt::NetworkTableEntry::SetDefaultStringArray ( ArrayRef< std::string >  defaultValue)
inline

Sets the entry's value if it does not exist.

Parameters
defaultValuethe default value to set
Returns
False if the entry exists with a different type
bool nt::NetworkTableEntry::SetDefaultValue ( std::shared_ptr< Value value)
inline

Sets the entry's value if it does not exist.

Parameters
defaultValuethe default value to set
Returns
False if the entry exists with a different type
bool nt::NetworkTableEntry::SetDouble ( double  value)
inline

Sets the entry's value.

Parameters
valuethe value to set
Returns
False if the entry exists with a different type
bool nt::NetworkTableEntry::SetDoubleArray ( ArrayRef< double >  value)
inline

Sets the entry's value.

Parameters
valuethe value to set
Returns
False if the entry exists with a different type
void nt::NetworkTableEntry::SetFlags ( unsigned int  flags)
inline

Sets flags.

Parameters
flagsthe flags to set (bitmask)
bool nt::NetworkTableEntry::SetRaw ( StringRef  value)
inline

Sets the entry's value.

Parameters
valuethe value to set
Returns
False if the entry exists with a different type
bool nt::NetworkTableEntry::SetString ( const Twine value)
inline

Sets the entry's value.

Parameters
valuethe value to set
Returns
False if the entry exists with a different type
bool nt::NetworkTableEntry::SetStringArray ( ArrayRef< std::string >  value)
inline

Sets the entry's value.

Parameters
valuethe value to set
Returns
False if the entry exists with a different type
bool nt::NetworkTableEntry::SetValue ( std::shared_ptr< Value value)
inline

Sets the entry's value.

Parameters
valuethe value to set
Returns
False if the entry exists with a different type

The documentation for this class was generated from the following files: