WPILibC++  2019.1.1-beta-1-31-g81d10bc
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
ITable.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2015-2018 FIRST. 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 NTCORE_TABLES_ITABLE_H_
9 #define NTCORE_TABLES_ITABLE_H_
10 
11 #include <memory>
12 #include <string>
13 #include <vector>
14 
15 #include <wpi/StringRef.h>
16 #include <wpi/Twine.h>
17 #include <wpi/deprecated.h>
18 
19 #include "networktables/NetworkTableValue.h"
20 
21 namespace nt {
22 class NetworkTable;
23 } // namespace nt
24 
25 class ITableListener;
26 
30 class WPI_DEPRECATED("Use NetworkTable directly") ITable {
31  public:
38  virtual bool ContainsKey(const wpi::Twine& key) const = 0;
39 
48  virtual bool ContainsSubTable(const wpi::Twine& key) const = 0;
49 
56  virtual std::shared_ptr<nt::NetworkTable> GetSubTable(
57  const wpi::Twine& key) const = 0;
58 
63  virtual std::vector<std::string> GetKeys(int types = 0) const = 0;
64 
68  virtual std::vector<std::string> GetSubTables() const = 0;
69 
75  virtual void SetPersistent(wpi::StringRef key) = 0;
76 
83  virtual void ClearPersistent(wpi::StringRef key) = 0;
84 
91  virtual bool IsPersistent(wpi::StringRef key) const = 0;
92 
100  virtual void SetFlags(wpi::StringRef key, unsigned int flags) = 0;
101 
109  virtual void ClearFlags(wpi::StringRef key, unsigned int flags) = 0;
110 
117  virtual unsigned int GetFlags(wpi::StringRef key) const = 0;
118 
124  virtual void Delete(const wpi::Twine& key) = 0;
125 
133  virtual std::shared_ptr<nt::Value> GetValue(const wpi::Twine& key) const = 0;
134 
141  virtual bool SetDefaultValue(const wpi::Twine& key,
142  std::shared_ptr<nt::Value> defaultValue) = 0;
143 
151  virtual bool PutValue(const wpi::Twine& key,
152  std::shared_ptr<nt::Value> value) = 0;
153 
161  virtual bool PutNumber(wpi::StringRef key, double value) = 0;
162 
169  virtual bool SetDefaultNumber(wpi::StringRef key, double defaultValue) = 0;
170 
179  virtual double GetNumber(wpi::StringRef key, double defaultValue) const = 0;
180 
188  virtual bool PutString(wpi::StringRef key, wpi::StringRef value) = 0;
189 
196  virtual bool SetDefaultString(wpi::StringRef key,
197  wpi::StringRef defaultValue) = 0;
198 
211  virtual std::string GetString(wpi::StringRef key,
212  wpi::StringRef defaultValue) const = 0;
213 
221  virtual bool PutBoolean(wpi::StringRef key, bool value) = 0;
222 
229  virtual bool SetDefaultBoolean(wpi::StringRef key, bool defaultValue) = 0;
230 
240  virtual bool GetBoolean(wpi::StringRef key, bool defaultValue) const = 0;
241 
252  virtual bool PutBooleanArray(wpi::StringRef key,
253  wpi::ArrayRef<int> value) = 0;
254 
261  virtual bool SetDefaultBooleanArray(wpi::StringRef key,
262  wpi::ArrayRef<int> defaultValue) = 0;
263 
279  virtual std::vector<int> GetBooleanArray(
280  wpi::StringRef key, wpi::ArrayRef<int> defaultValue) const = 0;
281 
288  virtual bool PutNumberArray(wpi::StringRef key,
289  wpi::ArrayRef<double> value) = 0;
290 
297  virtual bool SetDefaultNumberArray(wpi::StringRef key,
298  wpi::ArrayRef<double> defaultValue) = 0;
299 
311  virtual std::vector<double> GetNumberArray(
312  wpi::StringRef key, wpi::ArrayRef<double> defaultValue) const = 0;
313 
320  virtual bool PutStringArray(wpi::StringRef key,
321  wpi::ArrayRef<std::string> value) = 0;
322 
329  virtual bool SetDefaultStringArray(
330  wpi::StringRef key, wpi::ArrayRef<std::string> defaultValue) = 0;
331 
343  virtual std::vector<std::string> GetStringArray(
344  wpi::StringRef key, wpi::ArrayRef<std::string> defaultValue) const = 0;
345 
352  virtual bool PutRaw(wpi::StringRef key, wpi::StringRef value) = 0;
353 
360  virtual bool SetDefaultRaw(wpi::StringRef key,
361  wpi::StringRef defaultValue) = 0;
362 
374  virtual std::string GetRaw(wpi::StringRef key,
375  wpi::StringRef defaultValue) const = 0;
376 
382  virtual void AddTableListener(ITableListener* listener) = 0;
383 
391  virtual void AddTableListener(ITableListener* listener,
392  bool immediateNotify) = 0;
393 
402  virtual void AddTableListenerEx(ITableListener* listener,
403  unsigned int flags) = 0;
404 
413  virtual void AddTableListener(wpi::StringRef key, ITableListener* listener,
414  bool immediateNotify) = 0;
415 
425  virtual void AddTableListenerEx(wpi::StringRef key, ITableListener* listener,
426  unsigned int flags) = 0;
427 
432  virtual void AddSubTableListener(ITableListener* listener) = 0;
433 
440  virtual void AddSubTableListener(ITableListener* listener,
441  bool localNotify) = 0;
442 
448  virtual void RemoveTableListener(ITableListener* listener) = 0;
449 
453  virtual wpi::StringRef GetPath() const = 0;
454 };
455 
456 #endif // NTCORE_TABLES_ITABLE_H_
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: ArrayRef.h:41
NetworkTables (ntcore) namespace.
Definition: ITable.h:21
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
A network table that knows its subtable path.
Definition: NetworkTable.h:51
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:79