34 os <<
"key: " << entry.
key <<
" addr: " << entry.
addr
43 Stream <<
"Value: " << entry.
value;
46 Stream <<
"Endtime: " << entry.
ttlMessage->getArrivalTime();
64 error(
"This module doesn't handle messages!");
69 map<BinaryValue, P2pnsCacheEntry>::iterator iter;
70 for( iter = cache.begin(); iter != cache.end(); iter++ ) {
71 cancelAndDelete(iter->second.ttlMessage);
84 if (cache.size() == 0)
92 P2pnsIdCache::iterator it = idCache.find(key);
94 if (it != idCache.end()) {
104 P2pnsIdCache::iterator it = idCache.find(key);
106 if (it == idCache.end()) {
110 if (payload != NULL) {
114 it->second.lastUsage = simTime();
126 std::map<BinaryValue, P2pnsCacheEntry>::iterator it = cache.find(name);
128 if (it == cache.end())
131 return it->second.value;
137 std::map<BinaryValue, P2pnsCacheEntry>::iterator it = cache.find(name);
139 if (it == cache.end())
142 return it->second.ttlMessage;
148 if (pos >= cache.size()) {
149 error(
"Index out of bound (P2pnsCache, getDataAtPos())");
152 std::map<BinaryValue, P2pnsCacheEntry>::iterator it = cache.begin();
153 for (uint32_t i= 0; i < pos; i++) {
156 return it->second.value;
158 return it->second.value;
169 cache.insert(make_pair(name, entry));
184 if (cache.size() == 1) {
185 sprintf(buf,
"1 data item");
187 sprintf(buf,
"%zi data items", cache.size());
190 getDisplayString().setTagArg(
"t", 0, buf);
191 getDisplayString().setTagArg(
"t", 2,
"blue");
199 std::stringstream str;
200 for (uint32_t i = 0; i < cache.size(); i++) {
201 str << getDataAtPos(i);
203 if ( i != cache.size() - 1 )
209 sprintf(buf,
"%s", str.str().c_str());
210 getDisplayString().setTagArg(
"tt", 0, buf);
216 cout <<
"Content of P2pnsCache:" << endl;
217 for (std::map<BinaryValue, P2pnsCacheEntry>::iterator it = cache.begin();
218 it != cache.end(); it++) {
219 cout <<
"name: " << it->first <<
" Value: " << it->second.value <<
"End-time: " << it->second.ttlMessage->getArrivalTime() << endl;