Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9807 in orxonox.OLD for branches/new_class_id


Ignore:
Timestamp:
Sep 24, 2006, 11:26:48 PM (18 years ago)
Author:
bensch
Message:

some more DEBUG-functionality to the ObjectList… something is not quite right… i wonder, what this might be…

Location:
branches/new_class_id/src/lib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/lang/base_object.cc

    r9806 r9807  
    3232  this->objectName = objectName;
    3333  this->xmlElem = NULL;
     34  this->registerObject(this, BaseObject::_objectList);
    3435}
    3536
     
    4041{
    4142  /// Remove from the ObjectLists
    42   ClassList::iterator it;
     43  ClassEntries::iterator it;
     44  printf("Deleting Object of type %s::%s\n", this->getClassCName(), getCName());
    4345  for (it = this->_classes.begin(); it != this->_classes.end(); ++it)
    4446  {
     47    assert((*it)._objectList->checkIteratorInList((*it)._iterator) || (*it)._objectList->checkObjectInList(this));
    4548    (*it)._objectList->unregisterObject((*it)._iterator);
    4649    delete (*it)._iterator;
     
    8790bool BaseObject::isA(const ObjectListBase& objectList) const
    8891{
    89   ClassList::const_iterator it;
     92  ClassEntries::const_iterator it;
    9093  for (it = this->_classes.begin(); it != this->_classes.end(); ++it)
    9194    if ((*it)._objectList == &objectList)
     
    102105bool BaseObject::isA(const ClassID& classID) const
    103106{
    104   ClassList::const_iterator it;
     107  ClassEntries::const_iterator it;
    105108  for (it = this->_classes.begin(); it != this->_classes.end(); ++it)
    106109    if (*(*it)._objectList == classID)
     
    116119bool BaseObject::isA(int classID) const
    117120{
    118   ClassList::const_iterator it;
     121  ClassEntries::const_iterator it;
    119122  for (it = this->_classes.begin(); it != this->_classes.end(); ++it)
    120123    if (*(*it)._objectList == classID)
     124
    121125      return true;
    122126  return false;
     
    130134bool BaseObject::isA(const std::string& className) const
    131135{
    132   ClassList::const_iterator it;
     136  ClassEntries::const_iterator it;
    133137  for (it = this->_classes.begin(); it != this->_classes.end(); ++it)
    134138    if (*(*it)._objectList == className)
     
    146150{
    147151  PRINT(0)("Listing inheritance diagram for %s::%s: ", getClassCName(), getCName());
    148   ClassList::const_iterator it;
     152  ClassEntries::const_iterator it;
    149153  for (it = this->_classes.begin(); it != this->_classes.end(); ++it)
    150154    PRINT(0)(" -> %s(id:%d)", (*it)._objectList->name().c_str(), (*it)._objectList->id());
  • branches/new_class_id/src/lib/lang/base_object.h

    r9724 r9807  
    8484    /** Simple Constuctor @param objectList the ObjectList, @param iterator the (intrusive) Iterator inside of the ObjectList */
    8585    inline ClassEntry (ObjectListBase* objectList, ObjectListBase::IteratorBase* iterator) : _objectList(objectList), _iterator(iterator) {}
    86     ObjectListBase*                _objectList;  //!< A ObjectList this Object is part of
     86    ObjectListBase*                _objectList;  //!< An ObjectList this Object is part of
    8787    ObjectListBase::IteratorBase*  _iterator;    //!< An iterator pointing to the position of the Object inside of the List.
    8888  };
    89   typedef std::list<ClassEntry>        ClassList;   //!< Type definition for the List.
     89  typedef std::list<ClassEntry>       ClassEntries;   //!< Type definition for the List.
    9090
    9191  std::string                         className;    //!< the name of the class
    92   ClassList                           _classes;     //!< All Classes this object is part of.
     92  ClassEntries                        _classes;     //!< All Classes this object is part of.
    9393};
    9494
  • branches/new_class_id/src/lib/lang/object_list.h

    r9757 r9807  
    104104  //! Only used to unsubscribe a BaseObject. (just try to make a valid iterator, stupid :))
    105105  virtual void                          unregisterObject(IteratorBase* _iterators) = 0;
     106  //! Only for debug purposes
     107  virtual bool                          checkIteratorInList(IteratorBase* _iterator) const = 0;
     108  virtual bool                          checkObjectInList(BaseObject* obj) const = 0;
    106109
    107110protected:
     
    226229  ObjectListBase::IteratorBase*      registerObject(T* object);
    227230  virtual void                       unregisterObject(IteratorBase* iterator);
    228 
     231  bool                               checkIteratorInList(IteratorBase* iterator) const;
     232  bool                               checkObjectInList(BaseObject* obj) const;
    229233protected:
    230234  virtual void                       getBaseObjectList(ObjectListBase::base_list* list) const;
     
    345349}
    346350
     351template <class T>
     352bool ObjectList<T>::checkIteratorInList(IteratorBase* iterator) const
     353{
     354  const_iterator it;
     355  for (it = this->_objects.begin(); it != this->_objects.end(); ++it)
     356    if (static_cast<Iterator*>(iterator)->it() == it)
     357      return true;
     358  printf("ObjectList:: checkIteratorInList:: ITERATOR NOT IN THE LIST '%s' (UN-SYNC SHOULD NOT HAPPEN!!)\n", this->name().c_str());
     359  return false;
     360}
     361
     362template <class T>
     363bool ObjectList<T>::checkObjectInList(BaseObject* obj) const
     364{
     365  T* object = dynamic_cast<T*>(obj);
     366  if (object != NULL)
     367  {
     368    printf("EXTREME BUG: Object does not exist anymore!! (or a bug in ObjectList)\n");
     369    return false;;
     370  }
     371
     372  const_iterator it;
     373  for (it = this->_objects.begin(); it != this->_objects.end(); ++it)
     374  {
     375    if (*it == object)
     376      return true;
     377  }
     378  printf("ObjectList:: checkObjectInList:: OBJECT NOT IN THE LIST '%s' (UN-SYNC SHOULD NOT HAPPEN!!)\n", this->name().c_str());
     379  return false;
     380}
     381
     382
    347383#endif /* _OBJECT_LIST_H */
  • branches/new_class_id/src/lib/sound/sound_buffer.cc

    r9806 r9807  
    2828      : data(new SoundBufferData)
    2929  {
    30     this->registerObject(this, SoundBuffer::_objectList);
     30//     this->registerObject(this, SoundBuffer::_objectList);
    3131  }
    3232  /**
     
    3737      : data(new SoundBufferData)
    3838  {
    39     this->registerObject(this, SoundBuffer::_objectList);
     39//     this->registerObject(this, SoundBuffer::_objectList);
    4040    this->load(fileName);
    4141  }
     
    4444      : data(buffer.data)
    4545  {
    46     this->registerObject(this, SoundBuffer::_objectList);
     46//     this->registerObject(this, SoundBuffer::_objectList);
    4747  }
    4848
     
    5050      : data(dataPointer)
    5151  {
    52     this->registerObject(this, SoundBuffer::_objectList);
     52//     this->registerObject(this, SoundBuffer::_objectList);
    5353  };
    5454
    5555  SoundBuffer::~SoundBuffer()
    5656  {
    57     printf("Deleting Object of type SoundBuffer\n");
    5857  }
    5958
Note: See TracChangeset for help on using the changeset viewer.