Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9671 in orxonox.OLD for trunk/src/lib/lang/test_object_list.cc


Ignore:
Timestamp:
Aug 21, 2006, 4:14:57 PM (18 years ago)
Author:
bensch
Message:

trunk: just realized, that polimorphism again is the evil part of classes.
Classes, that derive say from PNode and Element2D force that Element2D is registered after PNode, which means, that Element2D is interpretet as being derived from PNode in my implmentational idea…
hmm… now go for some new approach, this cannot and will not be the end of this…

File:
1 edited

Legend:

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

    r9669 r9671  
    33#include <iostream>
    44
    5 class Test
     5class BaseObject
     6{
     7  public:
     8    void setName(const std::string& name) { this->_objectName = name; };
     9  const std::string& name() const { return _objectName; };
     10  bool operator==(const std::string& name) const { return _objectName == name; };
     11
     12protected:
     13  template<class T>
     14      inline void registerObject(T* object, NewObjectList<T>& objectList) { _id.registerObject(object, objectList); };
     15  private:
     16  NewClassID    _id;
     17  std::string   _objectName;
     18
     19};
     20
     21class Test : public BaseObject
    622{
    723public:
     
    1632
    1733Test::Test()
    18 {  std::cout << "Test()\n"; };
     34{
     35  this->registerObject(this, Test::objectList);
     36  std::cout << "Test()\n";
     37};
    1938Test::~Test()
    2039{ std::cout << "~Test()\n"; }
    2140
    22 class Bone
     41class Bone : public BaseObject
    2342{
    2443public:
    25   Bone() { std::cout << "Bone()\n"; };
     44  Bone() {
     45    this->registerObject(this, Bone::objectList);
     46    std::cout << "Bone()\n"; };
    2647  ~Bone() { std::cout << "~Bone()\n"; };
    2748  NewObjectListDeclaration(Bone);
     
    3253{
    3354  Test* test = new Test();
     55  test->setName("Testing");
    3456
    35   NewClassID id;
    36   id.registerObject(test, Test::objectList);
     57  Test::objectList.debug();
    3758
    3859  delete test;
     60
     61  Test::objectList.debug();
    3962  Bone* bone = new Bone();
    4063  delete bone;
     64
     65
    4166
    4267  std::cout << NewObjectListBase::classCount() << std::endl;
Note: See TracChangeset for help on using the changeset viewer.