Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/lang/test_object_list.cc @ 9671

Last change on this file since 9671 was 9671, checked in by bensch, 18 years ago

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 size: 1.3 KB
Line 
1#include "new_class_id.h"
2#include "new_object_list.h"
3#include <iostream>
4
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
22{
23public:
24  Test();
25  ~Test();
26
27
28  NewObjectListDeclaration(Test);
29  //ObjectListDeclaration(Test);
30};
31NewObjectListDefinition(Test);
32
33Test::Test()
34{
35  this->registerObject(this, Test::objectList);
36  std::cout << "Test()\n";
37};
38Test::~Test()
39{ std::cout << "~Test()\n"; }
40
41class Bone : public BaseObject
42{
43public:
44  Bone() {
45    this->registerObject(this, Bone::objectList);
46    std::cout << "Bone()\n"; };
47  ~Bone() { std::cout << "~Bone()\n"; };
48  NewObjectListDeclaration(Bone);
49};
50NewObjectListDefinition(Bone);
51
52int main()
53{
54  Test* test = new Test();
55  test->setName("Testing");
56
57  Test::objectList.debug();
58
59  delete test;
60
61  Test::objectList.debug();
62  Bone* bone = new Bone();
63  delete bone;
64
65
66
67  std::cout << NewObjectListBase::classCount() << std::endl;
68}
69
Note: See TracBrowser for help on using the repository browser.