Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Aug 20, 2006, 7:50:38 PM (18 years ago)
Author:
bensch
Message:

some more thoughts… but it looks like a hard one

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

Legend:

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

    r9660 r9664  
    2626 */
    2727NewClassID::NewClassID ()
    28     : _className("")
     28    : _objectList(NULL)
    2929{}
    3030
     
    3535NewClassID::~NewClassID ()
    3636{
    37   // delete what has to be deleted here
     37  assert(_objectList != NULL);
     38
     39  //  _objectList->unregister(this);
    3840}
    3941
  • trunk/src/lib/lang/new_class_id.h

    r9663 r9664  
    99
    1010#include "type_info.h"
    11 #include <set>
    1211#include <string>
    1312
     
    2120  ~NewClassID();
    2221
    23   void registerObject(NewObjectListBase* object);
     22  template<class T> void registerObject(T* object, NewObjectList<T>& list);
    2423
    2524private:
    26   std::string                   _className;
    27 
     25  NewObjectListBase*            _objectList;
    2826};
    2927
    3028
     29template<class T> void NewClassID::registerObject(T* object, NewObjectList<T>& objectList)
     30{
     31  this->_objectList = &objectList;
     32  objectList.registerObject(object);
     33}
     34
    3135#endif /* _NEW_CLASS_ID_H */
  • trunk/src/lib/lang/new_object_list.cc

    r9663 r9664  
    2929  this->_id = NewObjectListBase::_idCounter++;
    3030
    31 
    3231}
    3332
  • trunk/src/lib/lang/new_object_list.h

    r9663 r9664  
    3232  bool compareName(const NewObjectListBase& more) { return this->_name < more.name(); };
    3333  bool compareID(const NewObjectListBase& more) { return this->_id < more.id(); };
    34 
    3534
    3635  static unsigned int                   classCount() { return _idCounter; };
     
    7574  typedef typename list::iterator     iterator;
    7675
    77 
    7876public:
    7977  NewObjectList(const std::string& name);
     
    8381  inline const list&      objects() const { return _objects; };
    8482
     83  void registerObject(T* object);
     84  void unregisterObject(T* object);
    8585
    8686private:
     
    112112}
    113113
     114template <class T>
     115void NewObjectList<T>::registerObject(T* object)
     116{
     117  this->_objects.push_back(object);
     118}
     119
     120template <class T>
     121void NewObjectList<T>::unregisterObject(T* object)
     122{
     123  _objects.erase(std::find(_objects.begin(), _objects.end(), object));
     124}
     125
     126
    114127#endif /* _NEW_OBJECT_LIST_H */
Note: See TracChangeset for help on using the changeset viewer.