WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
ITable.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2015. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #ifndef ITABLE_H_
9 #define ITABLE_H_
10 
11 #include <memory>
12 
13 #include "llvm/StringRef.h"
14 #include "nt_Value.h"
15 #include "support/deprecated.h"
16 
17 class ITableListener;
18 
22 class ITable {
23  public:
30  virtual bool ContainsKey(llvm::StringRef key) const = 0;
31 
40  virtual bool ContainsSubTable(llvm::StringRef key) const = 0;
41 
48  virtual std::shared_ptr<ITable> GetSubTable(llvm::StringRef key) const = 0;
49 
54  virtual std::vector<std::string> GetKeys(int types = 0) const = 0;
55 
59  virtual std::vector<std::string> GetSubTables() const = 0;
60 
66  virtual void SetPersistent(llvm::StringRef key) = 0;
67 
74  virtual void ClearPersistent(llvm::StringRef key) = 0;
75 
82  virtual bool IsPersistent(llvm::StringRef key) const = 0;
83 
91  virtual void SetFlags(llvm::StringRef key, unsigned int flags) = 0;
92 
100  virtual void ClearFlags(llvm::StringRef key, unsigned int flags) = 0;
101 
108  virtual unsigned int GetFlags(llvm::StringRef key) const = 0;
109 
115  virtual void Delete(llvm::StringRef key) = 0;
116 
124  virtual std::shared_ptr<nt::Value> GetValue(llvm::StringRef key) const = 0;
125 
132  virtual bool SetDefaultValue(llvm::StringRef key,
133  std::shared_ptr<nt::Value> defaultValue) = 0;
134 
142  virtual bool PutValue(llvm::StringRef key,
143  std::shared_ptr<nt::Value> value) = 0;
144 
152  virtual bool PutNumber(llvm::StringRef key, double value) = 0;
153 
160  virtual bool SetDefaultNumber(llvm::StringRef key, double defaultValue) = 0;
161 
172  WPI_DEPRECATED(
173  "Raises an exception if key not found; "
174  "use GetNumber(StringRef key, double defaultValue) instead")
175  virtual double GetNumber(llvm::StringRef key) const = 0;
176 
185  virtual double GetNumber(llvm::StringRef key, double defaultValue) const = 0;
186 
194  virtual bool PutString(llvm::StringRef key, llvm::StringRef value) = 0;
195 
202  virtual bool SetDefaultString(llvm::StringRef key,
203  llvm::StringRef defaultValue) = 0;
204 
215  WPI_DEPRECATED(
216  "Raises an exception if key not found; "
217  "use GetString(StringRef key, StringRef defaultValue) instead")
218  virtual std::string GetString(llvm::StringRef key) const = 0;
219 
232  virtual std::string GetString(llvm::StringRef key,
233  llvm::StringRef defaultValue) const = 0;
234 
242  virtual bool PutBoolean(llvm::StringRef key, bool value) = 0;
243 
250  virtual bool SetDefaultBoolean(llvm::StringRef key, bool defaultValue) = 0;
251 
262  WPI_DEPRECATED(
263  "Raises an exception if key not found; "
264  "use GetBoolean(StringRef key, bool defaultValue) instead")
265  virtual bool GetBoolean(llvm::StringRef key) const = 0;
266 
276  virtual bool GetBoolean(llvm::StringRef key, bool defaultValue) const = 0;
277 
288  virtual bool PutBooleanArray(llvm::StringRef key,
289  llvm::ArrayRef<int> value) = 0;
290 
297  virtual bool SetDefaultBooleanArray(llvm::StringRef key,
298  llvm::ArrayRef<int> defaultValue) = 0;
299 
315  virtual std::vector<int> GetBooleanArray(
316  llvm::StringRef key, llvm::ArrayRef<int> defaultValue) const = 0;
317 
324  virtual bool PutNumberArray(llvm::StringRef key,
325  llvm::ArrayRef<double> value) = 0;
326 
333  virtual bool SetDefaultNumberArray(llvm::StringRef key,
334  llvm::ArrayRef<double> defaultValue) = 0;
335 
347  virtual std::vector<double> GetNumberArray(
348  llvm::StringRef key, llvm::ArrayRef<double> defaultValue) const = 0;
349 
356  virtual bool PutStringArray(llvm::StringRef key,
357  llvm::ArrayRef<std::string> value) = 0;
358 
365  virtual bool SetDefaultStringArray(
366  llvm::StringRef key, llvm::ArrayRef<std::string> defaultValue) = 0;
367 
379  virtual std::vector<std::string> GetStringArray(
380  llvm::StringRef key, llvm::ArrayRef<std::string> defaultValue) const = 0;
381 
388  virtual bool PutRaw(llvm::StringRef key, llvm::StringRef value) = 0;
389 
396  virtual bool SetDefaultRaw(llvm::StringRef key,
397  llvm::StringRef defaultValue) = 0;
398 
410  virtual std::string GetRaw(llvm::StringRef key,
411  llvm::StringRef defaultValue) const = 0;
412 
418  virtual void AddTableListener(ITableListener* listener) = 0;
419 
427  virtual void AddTableListener(ITableListener* listener,
428  bool immediateNotify) = 0;
429 
438  virtual void AddTableListenerEx(ITableListener* listener,
439  unsigned int flags) = 0;
440 
449  virtual void AddTableListener(llvm::StringRef key, ITableListener* listener,
450  bool immediateNotify) = 0;
451 
461  virtual void AddTableListenerEx(llvm::StringRef key, ITableListener* listener,
462  unsigned int flags) = 0;
463 
468  virtual void AddSubTableListener(ITableListener* listener) = 0;
469 
476  virtual void AddSubTableListener(ITableListener* listener,
477  bool localNotify) = 0;
478 
484  virtual void RemoveTableListener(ITableListener* listener) = 0;
485 };
486 
487 #endif // ITABLE_H_
virtual bool SetDefaultNumber(llvm::StringRef key, double defaultValue)=0
Gets the current value in the table, setting it if it does not exist.
virtual bool PutNumber(llvm::StringRef key, double value)=0
Put a number in the table.
virtual bool SetDefaultValue(llvm::StringRef key, std::shared_ptr< nt::Value > defaultValue)=0
Gets the current value in the table, setting it if it does not exist.
virtual bool PutNumberArray(llvm::StringRef key, llvm::ArrayRef< double > value)=0
Put a number array in the table.
A table whose values can be read and written to.
Definition: ITable.h:22
virtual void ClearPersistent(llvm::StringRef key)=0
Stop making a key's value persistent through program restarts.
virtual void AddTableListener(ITableListener *listener)=0
Add a listener for changes to the table.
virtual bool SetDefaultNumberArray(llvm::StringRef key, llvm::ArrayRef< double > defaultValue)=0
Gets the current value in the table, setting it if it does not exist.
virtual std::string GetRaw(llvm::StringRef key, llvm::StringRef defaultValue) const =0
Returns the raw value (byte array) the key maps to.
virtual bool PutBooleanArray(llvm::StringRef key, llvm::ArrayRef< int > value)=0
Put a boolean array in the table.
virtual std::shared_ptr< ITable > GetSubTable(llvm::StringRef key) const =0
Gets the subtable in this table for the given name.
virtual void Delete(llvm::StringRef key)=0
Deletes the specified key in this table.
virtual bool SetDefaultBooleanArray(llvm::StringRef key, llvm::ArrayRef< int > defaultValue)=0
Gets the current value in the table, setting it if it does not exist.
virtual bool SetDefaultString(llvm::StringRef key, llvm::StringRef defaultValue)=0
Gets the current value in the table, setting it if it does not exist.
virtual void AddSubTableListener(ITableListener *listener)=0
This will immediately notify the listener of all current sub tables.
virtual unsigned int GetFlags(llvm::StringRef key) const =0
Returns the flags for the specified key.
virtual bool ContainsKey(llvm::StringRef key) const =0
Determines whether the given key is in this table.
virtual bool PutStringArray(llvm::StringRef key, llvm::ArrayRef< std::string > value)=0
Put a string array in the table.
virtual std::vector< std::string > GetSubTables() const =0
virtual bool IsPersistent(llvm::StringRef key) const =0
Returns whether the value is persistent through program restarts.
virtual bool PutString(llvm::StringRef key, llvm::StringRef value)=0
Put a string in the table.
virtual std::vector< std::string > GetKeys(int types=0) const =0
virtual bool PutBoolean(llvm::StringRef key, bool value)=0
Put a boolean in the table.
virtual void RemoveTableListener(ITableListener *listener)=0
Remove a listener from receiving table events.
virtual std::shared_ptr< nt::Value > GetValue(llvm::StringRef key) const =0
Gets the value associated with a key as an object.
A listener that listens to changes in values in a ITable.
Definition: ITableListener.h:18
virtual void SetFlags(llvm::StringRef key, unsigned int flags)=0
Sets flags on the specified key in this table.
virtual std::vector< std::string > GetStringArray(llvm::StringRef key, llvm::ArrayRef< std::string > defaultValue) const =0
Returns the string array the key maps to.
virtual bool SetDefaultStringArray(llvm::StringRef key, llvm::ArrayRef< std::string > defaultValue)=0
Gets the current value in the table, setting it if it does not exist.
virtual std::vector< double > GetNumberArray(llvm::StringRef key, llvm::ArrayRef< double > defaultValue) const =0
Returns the number array the key maps to.
virtual bool SetDefaultRaw(llvm::StringRef key, llvm::StringRef defaultValue)=0
Gets the current value in the table, setting it if it does not exist.
virtual void ClearFlags(llvm::StringRef key, unsigned int flags)=0
Clears flags on the specified key in this table.
virtual bool ContainsSubTable(llvm::StringRef key) const =0
Determines whether there exists a non-empty subtable for this key in this table.
virtual bool PutValue(llvm::StringRef key, std::shared_ptr< nt::Value > value)=0
Put a value in the table.
virtual bool SetDefaultBoolean(llvm::StringRef key, bool defaultValue)=0
Gets the current value in the table, setting it if it does not exist.
virtual std::vector< int > GetBooleanArray(llvm::StringRef key, llvm::ArrayRef< int > defaultValue) const =0
Returns the boolean array the key maps to.
virtual void AddTableListenerEx(ITableListener *listener, unsigned int flags)=0
Add a listener for changes to the table.
virtual bool PutRaw(llvm::StringRef key, llvm::StringRef value)=0
Put a raw value (byte array) in the table.
virtual void SetPersistent(llvm::StringRef key)=0
Makes a key's value persistent through program restarts.