Changeset 9909 in orxonox.OLD for branches/network/src/lib/lang/object_list.cc
- Timestamp:
- Oct 30, 2006, 10:35:23 PM (18 years ago)
- File:
-
- 1 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 }
Note: See TracChangeset
for help on using the changeset viewer.