8 #include "networktables2/NetworkTableNode.h"
9 #include "networktables2/TableKeyExistsWithDifferentTypeException.h"
10 #include "networktables2/type/DefaultEntryTypes.h"
11 #include "tables/TableKeyNotDefinedException.h"
17 entryStore(_entryStore){
20 NetworkTableNode::~NetworkTableNode(){}
28 void NetworkTableNode::PutBoolean(std::string& name,
bool value){
31 PutValue(name, &DefaultEntryTypes::BOOLEAN, eValue);
33 bool NetworkTableNode::GetBoolean(std::string& name){
37 return entry->GetValue().b;
40 void NetworkTableNode::PutDouble(std::string& name,
double value){
43 PutValue(name, &DefaultEntryTypes::DOUBLE, eValue);
45 double NetworkTableNode::GetDouble(std::string& name){
49 return entry->GetValue().f;
52 void NetworkTableNode::PutString(std::string& name, std::string& value){
55 PutValue(name, &DefaultEntryTypes::STRING, eValue);
57 std::string& NetworkTableNode::GetString(std::string& name) {
61 return *(std::string*)(entry->GetValue().ptr);
64 void NetworkTableNode::PutComplex(std::string& name,
ComplexData& value){
70 void NetworkTableNode::retrieveValue(std::string& name,
ComplexData& externalData){
80 complexType->
exportValue(name, entry->GetValue(), externalData);
93 entryStore.
PutOutgoing(entry, entryType->internalizeValue(entry->
name, *complexData, entry->GetValue()));
96 EntryValue entryValue = entryType->internalizeValue(name, *complexData, nullValue);
119 EntryValue NetworkTableNode::GetValue(std::string& name){
125 return entry->GetValue();
131 return entryStore.GetEntry(key)!=NULL;
135 remoteListeners.push_back(listener);
142 std::vector<IRemoteConnectionListener*>::iterator listenerPosition = std::find(remoteListeners.begin(), remoteListeners.end(), listener);
143 if(listenerPosition!=remoteListeners.end())
144 remoteListeners.erase(listenerPosition);
147 for(
unsigned int i = 0; i<remoteListeners.size(); ++i)
148 remoteListeners.at(i)->Connected(
this);
151 for(
unsigned int i = 0; i<remoteListeners.size(); ++i)
152 remoteListeners.at(i)->Disconnected(
this);
156 void NetworkTableNode::AddTableListener(
ITableListener* listener,
bool immediateNotify) {
157 tableListeners.push_back(listener);
161 void NetworkTableNode::RemoveTableListener(
ITableListener* listener) {
162 std::vector<ITableListener*>::iterator listenerPosition = std::find(tableListeners.begin(), tableListeners.end(), listener);
163 if(listenerPosition!=tableListeners.end())
164 tableListeners.erase(listenerPosition);
166 void NetworkTableNode::FireTableListeners(std::string& key,
EntryValue value,
bool isNew){
167 for(
unsigned int i = 0; i<tableListeners.size(); ++i)
168 tableListeners.at(i)->ValueChanged(NULL, key, value, isNew);
void notifyEntries(ITable *table, ITableListener *listener)
void PutValue(std::string &name, NetworkTableEntryType *type, EntryValue value)
AbstractNetworkTableEntryStore & GetEntryStore()
virtual void Connected(IRemote *remote)=0
virtual void exportValue(std::string &key, EntryValue internalData, ComplexData &externalRepresentation)=0
void AddConnectionListener(IRemoteConnectionListener *listener, bool immediateNotify)
virtual void Disconnected(IRemote *remote)=0
virtual EntryValue internalizeValue(std::string &key, ComplexData &externalRepresentation, EntryValue currentInteralValue)=0
void FireConnectedEvent()
void PutOutgoing(std::string &name, NetworkTableEntryType *type, EntryValue value)
ComplexEntryType & GetType()
virtual bool IsConnected()=0
void RemoveConnectionListener(IRemoteConnectionListener *listener)
bool ContainsKey(std::string &key)
void FireDisconnectedEvent()
virtual void deleteValue(EntryValue value)