Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9677 in orxonox.OLD for trunk/src/lib


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

orxonox/trunk: much better ID nutrition

Location:
trunk/src/lib/lang
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/lang/Makefile.am

    r9674 r9677  
    2929                test_object_list.cc
    3030
     31test_object_list_DEPENDENCIES = libORXlang.a
     32
    3133test_object_list_LDADD = \
    3234                $(MAINSRCDIR)/util/libORXutils.a \
  • 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/**
  • trunk/src/lib/lang/new_object_list.h

    r9676 r9677  
    1919#define NewObjectListDefinition(ClassName) \
    2020   NewObjectList<ClassName> ClassName::objectList(#ClassName)
     21
     22#define NewObjectListDefinitionID(ClassName, ID) \
     23   NewObjectList<ClassName> ClassName::objectList(#ClassName, ID)
    2124
    2225
  • trunk/src/lib/lang/test_object_list.cc

    r9675 r9677  
    4343  //ObjectListDeclaration(Test);
    4444};
    45 NewObjectListDefinition(Test);
     45NewObjectListDefinitionID(Test, 0);
    4646
    4747Test::Test()
     
    7070  NewObjectListDeclaration(Bone);
    7171};
    72 NewObjectListDefinition(Bone);
     72NewObjectListDefinitionID(Bone, -1);
    7373
    7474int main()
Note: See TracChangeset for help on using the changeset viewer.