Now you can download a copy of these docs so you can use them offline! Download now
NetworkTable.h
1 #ifndef _NETWORKTABLE_H_
2 #define _NETWORKTABLE_H_
3 
4 class NetworkTable;
6 class EntryCache;
7 
8 #include <map>
9 #include <string>
10 #include "tables/ITable.h"
11 #include "tables/IRemote.h"
12 #include "networktables2/thread/NTThreadManager.h"
13 #include "networktables2/NetworkTableEntry.h"
14 #include "networktables2/util/StringCache.h"
15 #include "networktables/NetworkTableProvider.h"
16 #include "networktables/NetworkTableMode.h"
17 #include "networktables2/thread/DefaultThreadManager.h"
18 #include "networktables/NetworkTableConnectionListenerAdapter.h"
19 #include "networktables/NetworkTableListenerAdapter.h"
20 #include "tables/IRemoteConnectionListener.h"
21 
22 
23 
24 using namespace std;
25 
26 
27 
29 private:
30  const std::string path;
31 
32 public:
33  NetworkTableKeyCache(std::string path);
35 
36  std::string Calc(const std::string& key);
37 };
38 
39 
40 class EntryCache {
41 private:
42  map<std::string, NetworkTableEntry*> cache;
43  std::string& path;
44 public:
45  EntryCache(std::string& path);
46  ~EntryCache();
47 
48  NetworkTableEntry* Get(std::string& key);
49 };
50 
51 
52 
53 class NetworkTable : public ITable, IRemote {
54 
55 private:
56  static DefaultThreadManager threadManager;
57  static NetworkTableProvider* staticProvider;
58  static NetworkTableNode* staticNode;
59  static void* streamFactory;
60  static NetworkTableEntryTypeManager* typeManager;
61  static NetworkTableMode* mode;
62  static int port;
63  static std::string ipAddress;
64  static NTReentrantSemaphore STATIC_LOCK;
65 
66 
67 
68  std::string path;
69  EntryCache entryCache;
70  NetworkTableKeyCache absoluteKeyCache;
71  NetworkTableProvider& provider;
72  NetworkTableNode& node;
74 
75 
76  map<IRemoteConnectionListener*, NetworkTableConnectionListenerAdapter*> connectionListenerMap;
77  multimap<ITableListener*, ITableListener*> listenerMap;
78 
79  static void CheckInit();
80 
81  NetworkTableEntry* GetEntry(std::string key);
82 
83 public:
84 
85  static const char PATH_SEPARATOR_CHAR;
90  static const std::string PATH_SEPARATOR;
94  static const int DEFAULT_PORT;
95 
99  static void Initialize();
100  static void Shutdown();
101 
106  static void SetTableProvider(NetworkTableProvider* provider);
107 
112  static void SetClientMode();
113 
118  static void SetServerMode();
119 
125  static void SetTeam(int team);
129  static void SetIPAddress(const char* address);
138  static NetworkTable* GetTable(std::string key);
139 
140 
141  NetworkTable(std::string path, NetworkTableProvider& provider);
142  virtual ~NetworkTable();
143 
144  bool IsConnected();
145 
146  bool IsServer();
147 
148 
149 
150 
151 
152 
153 
154  void AddConnectionListener(IRemoteConnectionListener* listener, bool immediateNotify);
155 
156  void RemoveConnectionListener(IRemoteConnectionListener* listener);
157 
158 
159  void AddTableListener(ITableListener* listener);
160 
161 
162  void AddTableListener(ITableListener* listener, bool immediateNotify);
163  void AddTableListener(std::string key, ITableListener* listener, bool immediateNotify);
164  void AddSubTableListener(ITableListener* listener);
165 
166  void RemoveTableListener(ITableListener* listener);
167 
168 
169 
178  NetworkTable* GetSubTable(std::string key);
179 
180 
187  bool ContainsKey(std::string key);
188 
189  bool ContainsSubTable(std::string key);
190 
201  void PutNumber(std::string key, double value);
202 
212  double GetNumber(std::string key);
213 
224  double GetNumber(std::string key, double defaultValue);
225 
236  void PutString(std::string key, std::string value);
237 
247  std::string GetString(std::string key);
248 
259  std::string GetString(std::string key, std::string defaultValue);
260 
271  void PutBoolean(std::string key, bool value);
272 
282  bool GetBoolean(std::string key);
283 
294  bool GetBoolean(std::string key, bool defaultValue);
295 
296 
297  void PutValue(std::string key, NetworkTableEntryType* type, EntryValue value);
298 
299 
300  void RetrieveValue(std::string key, ComplexData& externalValue);
301 
310  void PutValue(std::string key, ComplexData& value);
311 
323  EntryValue GetValue(std::string key);
324 
337  EntryValue GetValue(std::string key, EntryValue defaultValue);
338 
339 };
340 
341 #endif
static const std::string PATH_SEPARATOR
Definition: NetworkTable.h:90
Definition: NetworkTable.h:40
Definition: ITable.h:26
static const int DEFAULT_PORT
Definition: NetworkTable.h:94
Definition: ITable.h:13

Generated on Sat Apr 26 2014 12:26:45 for WPILibC++ by doxygen 1.8.6