mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-27 02:01:42 +00:00
Implement local notification.
The default behavior is to only notify remote changes, but for some applications (e.g. GUI's) it's advantageous to know about local changes as well. This is (slightly) optimized in that local changes only result in additional resources being consumed if (any) local listeners have been created.
This commit is contained in:
@@ -137,9 +137,14 @@ class NetworkTable : public ITable {
|
||||
|
||||
void AddTableListener(ITableListener* listener);
|
||||
void AddTableListener(ITableListener* listener, bool immediateNotify);
|
||||
void AddTableListener(ITableListener* listener, bool immediateNotify,
|
||||
bool localNotify);
|
||||
void AddTableListener(llvm::StringRef key, ITableListener* listener,
|
||||
bool immediateNotify);
|
||||
void AddTableListener(llvm::StringRef key, ITableListener* listener,
|
||||
bool immediateNotify, bool localNotify);
|
||||
void AddSubTableListener(ITableListener* listener);
|
||||
void AddSubTableListener(ITableListener* listener, bool localNotify);
|
||||
void RemoveTableListener(ITableListener* listener);
|
||||
|
||||
/**
|
||||
|
||||
@@ -266,7 +266,7 @@ typedef void (*NT_ConnectionListenerCallback)(
|
||||
|
||||
unsigned int NT_AddEntryListener(const char *prefix, size_t prefix_len,
|
||||
void *data, NT_EntryListenerCallback callback,
|
||||
int immediate_notify);
|
||||
int immediate_notify, int local_notify);
|
||||
void NT_RemoveEntryListener(unsigned int entry_listener_uid);
|
||||
unsigned int NT_AddConnectionListener(void *data,
|
||||
NT_ConnectionListenerCallback callback,
|
||||
|
||||
@@ -189,7 +189,7 @@ typedef std::function<void(unsigned int uid, bool connected,
|
||||
ConnectionListenerCallback;
|
||||
|
||||
unsigned int AddEntryListener(StringRef prefix, EntryListenerCallback callback,
|
||||
bool immediate_notify);
|
||||
bool immediate_notify, bool local_notify);
|
||||
void RemoveEntryListener(unsigned int entry_listener_uid);
|
||||
unsigned int AddConnectionListener(ConnectionListenerCallback callback,
|
||||
bool immediate_notify);
|
||||
|
||||
@@ -209,6 +209,18 @@ class ITable {
|
||||
virtual void AddTableListener(ITableListener* listener,
|
||||
bool immediateNotify) = 0;
|
||||
|
||||
/**
|
||||
* Add a listener for changes to the table
|
||||
*
|
||||
* @param listener the listener to add
|
||||
* @param immediateNotify if true then this listener will be notified of all
|
||||
* current entries (marked as new)
|
||||
* @param localNotify if true then this listener will be notified of all
|
||||
* local changes in addition to all remote changes
|
||||
*/
|
||||
virtual void AddTableListener(ITableListener* listener, bool immediateNotify,
|
||||
bool localNotify) = 0;
|
||||
|
||||
/**
|
||||
* Add a listener for changes to a specific key the table
|
||||
*
|
||||
@@ -220,12 +232,34 @@ class ITable {
|
||||
virtual void AddTableListener(llvm::StringRef key, ITableListener* listener,
|
||||
bool immediateNotify) = 0;
|
||||
|
||||
/**
|
||||
* Add a listener for changes to a specific key the table
|
||||
*
|
||||
* @param key the key to listen for
|
||||
* @param listener the listener to add
|
||||
* @param immediateNotify if true then this listener will be notified of all
|
||||
* current entries (marked as new)
|
||||
* @param localNotify if true then this listener will be notified of all
|
||||
* local changes in addition to all remote changes
|
||||
*/
|
||||
virtual void AddTableListener(llvm::StringRef key, ITableListener* listener,
|
||||
bool immediateNotify, bool localNotify) = 0;
|
||||
|
||||
/**
|
||||
* This will immediately notify the listener of all current sub tables
|
||||
* @param listener the listener to add
|
||||
*/
|
||||
virtual void AddSubTableListener(ITableListener* listener) = 0;
|
||||
|
||||
/**
|
||||
* This will immediately notify the listener of all current sub tables
|
||||
* @param listener the listener to add
|
||||
* @param localNotify if true then this listener will be notified of all
|
||||
* local changes in addition to all remote changes
|
||||
*/
|
||||
virtual void AddSubTableListener(ITableListener* listener,
|
||||
bool localNotify) = 0;
|
||||
|
||||
/**
|
||||
* Remove a listener from receiving table events
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user