Changeset 9909 in orxonox.OLD for branches/network
- Timestamp:
- Oct 30, 2006, 10:35:23 PM (18 years ago)
- Location:
- branches/network/src/lib
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/lang/object_list.cc
r9869 r9909 330 330 return -1; 331 331 } 332 333 334 /** 335 * replace all ids. list must contain all (and no more) ids 336 * @param str2id list: string -> newId 337 */ 338 void ObjectListBase::replaceIDMap( const std::map< std::string, int >& str2id ) 339 { 340 if ( str2id.size() != _classesByID->size() ) 341 { 342 assert( false && "size of str2id does not match" ); 343 } 344 345 IDMap * map = new IDMap(); 346 347 std::map< std::string, int >::const_iterator it; 348 for ( it = str2id.begin(); it != str2id.end(); it++ ) 349 { 350 assert( _classesByName->find( it->first ) != _classesByName->end() ); 351 (*map)[ it->second ] = (*_classesByName)[it->first]; 352 } 353 354 delete _classesByID; 355 _classesByID = map; 356 } 357 358 /** 359 * 360 * @return 361 */ 362 std::map< std::string, int > * ObjectListBase::createStrToId( ) 363 { 364 std::map< std::string, int > * res = new std::map< std::string, int >(); 365 366 NameMap::const_iterator it; 367 for ( it = _classesByName->begin(); it != _classesByName->end(); it++ ) 368 { 369 IDMap::const_iterator it2; 370 int id = -1; 371 for ( it2 = _classesByID->begin(); it2 != _classesByID->end(); it2++ ) 372 { 373 if ( it->second == it2->second ) 374 { 375 id = it2->first; 376 break; 377 } 378 } 379 380 assert( id != -1 ); 381 (*res)[ it->first ] = id; 382 } 383 384 return res; 385 } -
branches/network/src/lib/lang/object_list.h
r9869 r9909 133 133 static NameMap* _classesByName; //!< A Map of all the classes in existance. 134 134 static std::list<std::string> _classNames; //!< A list of all the registered ClassNames. 135 136 public: 137 static void replaceIDMap( const std::map<std::string, int>& str2id ); 138 static std::map<std::string, int>* createStrToId(); 135 139 }; 136 140 -
branches/network/src/lib/network/Makefile.am
r9906 r9909 44 44 synchronizeable_var/synchronizeable_ip.cc \ 45 45 synchronizeable_var/synchronizeable_classid.cc \ 46 synchronizeable_var/synchronizeable_classid_list.cc \ 46 47 \ 47 48 ip.cc … … 96 97 synchronizeable_var/synchronizeable_ip.h \ 97 98 synchronizeable_var/synchronizeable_classid.h \ 99 synchronizeable_var/synchronizeable_classid_list.h \ 98 100 \ 99 101 ip.h -
branches/network/src/lib/network/handshake.cc
r9869 r9909 22 22 #include "debug.h" 23 23 24 #include "synchronizeable_var/synchronizeable_classid_list.h" 25 26 std::map< std::string, int >* Handshake::classIdList = NULL; 24 27 25 28 ObjectListDefinition(Handshake); … … 32 35 this->registerObject(this, Handshake::_objectList); 33 36 37 if ( !Handshake::classIdList ) 38 { 39 //TODO who else? 40 if ( SharedNetworkData::getInstance()->isMasterServer() ) 41 { 42 Handshake::classIdList = ObjectListBase::createStrToId(); 43 } 44 else 45 { 46 Handshake::classIdList = new std::map< std::string, int >(); 47 } 48 } 34 49 35 50 // register all variable handlers … … 52 67 registerVar( new SynchronizeableIP( &this->proxy2, &this->proxy2, "proxy server 2", PERMISSION_MASTER_SERVER ) ); 53 68 registerVar( new SynchronizeableInt( &this->redirectProxy, &this->redirectProxy, "proxy server redirection flag", PERMISSION_MASTER_SERVER ) ); 69 70 registerVar( new SynchronizeableClassIDList( Handshake::classIdList, Handshake::classIdList, "classId List", PERMISSION_MASTER_SERVER ) ); 54 71 55 72 -
branches/network/src/lib/network/handshake.h
r9901 r9909 118 118 IP proxy1; //!< ip address of the first proxy (0.0.0.0 of not available) 119 119 IP proxy2; //!< ip address of the second proxy (0.0.0.0 of not available) 120 121 static std::map< std::string, int >* classIdList; 122 public: 123 std::map< std::string, int >* getClassIdList(){ return classIdList; } 120 124 }; 121 125 -
branches/network/src/lib/network/network_stream.cc
r9908 r9909 716 716 // init the new message manager 717 717 MessageManager::getInstance()->setUniqueID( it->second.handshake->getMessageManagerId() ); 718 ObjectListBase::replaceIDMap( *(it->second.handshake->getClassIdList()) ); 718 719 } 719 720
Note: See TracChangeset
for help on using the changeset viewer.