Changeset 2952
- Timestamp:
- 04/27/06 13:21:37 (3 years ago)
- Files:
-
- hydranode/hncgcomm/cgcomm.cpp (modified) (1 diff)
- hydranode/hncore/cgcomm/opcodes.h (modified) (1 diff)
- hydranode/hncore/cgcomm/sub_shared.cpp (modified) (2 diffs)
- hydranode/hncore/cgcomm/sub_shared.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
hydranode/hncgcomm/cgcomm.cpp
r2942 r2952 664 664 onRemoved(i->second); 665 665 m_list.erase(i); 666 } 667 return; 668 } else if (oc == OC_CHANGEID) { 669 uint32_t oldId = Utils::getVal<uint32_t>(packet); 670 uint32_t newId = Utils::getVal<uint32_t>(packet); 671 Iter i = m_list.find(oldId); 672 if (i != m_list.end()) { 673 SharedFilePtr obj = i->second; 674 m_list.erase(i); 675 obj->m_id = newId; 676 m_list[newId] = obj; 666 677 } 667 678 return; hydranode/hncore/cgcomm/opcodes.h
r2942 r2952 67 67 OC_CADDED = 0x1d, //!< Child was added to an object 68 68 OC_CREMOVED = 0x1e, //!< Child was removed from an object 69 OC_DESTROY = 0x1f //!< Object was destroyed70 69 OC_DESTROY = 0x1f, //!< Object was destroyed 70 OC_CHANGEID = 0x20 //!< Object ID was changed 71 71 }; 72 72 hydranode/hncore/cgcomm/sub_shared.cpp
r2938 r2952 222 222 (*it)->setZombie(); 223 223 } else if (it != m_cache.get<2>().end()) { 224 if (event == SF_METADATA_ADDED) { 225 changeId(it); 226 it = m_cache.get<2>().find(file); 227 CHECK_THROW(it != m_cache.get<2>().end()); 228 } 224 229 (*it)->update(file); 225 230 } … … 230 235 ); 231 236 } MSVC_ONLY(;) 237 238 void Shared::changeId(FIter c) { 239 if ((*c)->getId() == getFId((*c)->m_file)) { 240 return; 241 } 242 uint32_t oldId = (*c)->getId(); 243 uint32_t newId = getFId((*c)->m_file); 244 CacheEntry *cc = *c; 245 246 // preconditions 247 CHECK_THROW(m_cache.get<1>().find(newId) == m_cache.get<1>().end()); 248 249 m_cache.get<2>().modify( 250 c, boost::lambda::bind(&CacheEntry::m_id, __1) = newId 251 ); 252 253 // postconditions 254 CHECK_THROW(cc->getId() == newId); 255 CHECK_THROW(m_cache.get<1>().find(newId) != m_cache.get<1>().end()); 256 257 std::ostringstream tmp; 258 Utils::putVal<uint8_t>(tmp, OC_CHANGEID); 259 Utils::putVal<uint32_t>(tmp, oldId); 260 Utils::putVal<uint32_t>(tmp, newId); 261 sendPacket(tmp.str()); 262 } 232 263 233 264 void Shared::onMonitorTimer() try { hydranode/hncore/cgcomm/sub_shared.h
r2938 r2952 64 64 }; 65 65 private: 66 void monitor(std::istream &i);67 void addShared(std::istream &i);68 void remShared(std::istream &i);69 void sendList();70 void rebuildCache();71 void onEvent(SharedFile *file, int event);72 void onMonitorTimer();73 74 66 typedef boost::multi_index_container< 75 67 CacheEntry*, … … 94 86 typedef Cache::nth_index<1>::type::iterator IDIter; 95 87 typedef Cache::nth_index<2>::type::iterator FIter; 88 89 void monitor(std::istream &i); 90 void addShared(std::istream &i); 91 void remShared(std::istream &i); 92 void sendList(); 93 void rebuildCache(); 94 void onEvent(SharedFile *file, int event); 95 void onMonitorTimer(); 96 void changeId(FIter i); 97 96 98 Cache m_cache; 97 98 99 uint32_t m_updateTimer; 99 100 };
