Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9677 in orxonox.OLD for trunk/src/lib/lang/new_object_list.cc


Ignore:
Timestamp:
Aug 21, 2006, 11:40:41 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: much better ID nutrition

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/lang/new_object_list.cc

    r9676 r9677  
    2323    : _name(className)
    2424{
     25
     26
    2527  if (NewObjectListBase::_classesByID == NULL)
    2628  {
     
    3335  if (id != -1)
    3436  {
    35     assert(!NewObjectListBase::classIDExists(id) && "Classes should only be included once, and no two classes should have the same ID (key value)");
     37    this->_id = id;
    3638  }
    3739  else
    3840  {
    3941    this->_id = NewObjectListBase::_classesByID->size();
     42    // searching for a free ID
     43    while (NewObjectListBase::classIDExists(_id)) ++id;
    4044  }
     45  assert(!NewObjectListBase::classIDExists(id) && "Classes should only be included once, and no two classes should have the same ID (key value)");
     46
     47  /// Some Output, that will fall out later
     48  std::cout << "register new ObjectList " << className << " ID: " << this->_id << std::endl;
    4149
    4250  (*NewObjectListBase::_classesByID)[this->_id] = this;
     
    5260NewObjectListBase::~NewObjectListBase()
    5361{
     62  assert (NewObjectListBase::_classesByName != NULL && NewObjectListBase::_classesByID != NULL);
     63
     64  std::cout << "Erasing: " << this->_name << " "<< this->_id  << std::endl;
     65
     66  std::cout << "SIZE OF _classByID: " << NewObjectListBase::_classesByID->size() << std::endl;
     67  std::cout << "SIZE OF _classByName: " << NewObjectListBase::_classesByName->size() << std::endl;
     68
    5469  NewObjectListBase::_classesByName->erase(this->_name);
    5570  NewObjectListBase::_classesByID->erase(this->_id);
     
    6782NewObjectListBase::classIDMap* NewObjectListBase::_classesByID = NULL;
    6883NewObjectListBase::classNameMap* NewObjectListBase::_classesByName = NULL;
    69 
    70 
    7184
    7285/**
Note: See TracChangeset for help on using the changeset viewer.