/** * Stores the given value under the given name and queues it for * transmission to the server. * * @param name The name under which to store the given value. * @param type The type of the given value. * @param value The value to store. * @throws TableKeyExistsWithDifferentTypeException Thrown if an * entry already exists with the given name and is of a different type. */ void AbstractNetworkTableEntryStore::PutOutgoing(std::string& name, NetworkTableEntryType* type, EntryValue value){ { NTSynchronized sync(LOCK); std::map<std::string, NetworkTableEntry*>::iterator index = namedEntries.find(name); NetworkTableEntry* tableEntry; if(index == namedEntries.end())//if the name does not exist in the current entries { tableEntry = new NetworkTableEntry(name, type, value); if(addEntry(tableEntry)) { tableEntry->FireListener(listenerManager); outgoingReceiver->offerOutgoingAssignment(tableEntry); } } else { tableEntry = index->second; if(tableEntry->GetType()->id != type->id){ throw TableKeyExistsWithDifferentTypeException(name, tableEntry->GetType()); } EntryValue oldValue = tableEntry->GetValue(); if(!type->areEqual(value, oldValue)){ if(updateEntry(tableEntry, (SequenceNumber)(tableEntry->GetSequenceNumber() + 1), value)){ outgoingReceiver->offerOutgoingUpdate(tableEntry); } tableEntry->FireListener(listenerManager); } } } }
void AbstractNetworkTableEntryStore::offerIncomingAssignment(NetworkTableEntry* entry){ { NTSynchronized sync(LOCK); std::map<std::string, NetworkTableEntry*>::iterator itr = namedEntries.find(entry->name); NetworkTableEntry* tableEntry; if(addEntry(entry)){ if(itr != namedEntries.end()){ tableEntry = itr->second; } else{ tableEntry = entry; } tableEntry->FireListener(listenerManager);//if we didnt have a pointer, then the copy of the version in the list would call this method, however with the pointer we are updating the version in the list incomingReceiver->offerOutgoingAssignment(tableEntry); } else delete entry; } }