Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: sync

File size: 2.2 KB
Line 
1#include "new_class_id.h"
2#include "new_object_list.h"
3#include <iostream>
4
5#include <base_object.h>
6
7class NewBaseObject
8{
9public:
10  //   void setName(const std::string& name) { this->_objectName = name; };
11     const std::string& getName() const { return _objectName; };
12  //   bool operator==(const std::string& name) const { return _objectName == name; };
13
14    NewObjectListDeclaration(NewBaseObject);
15
16protected:
17  NewBaseObject(const std::string& objectName = "") : _objectName(objectName)
18  {
19       this->registerObject(this, objectList);
20  };
21  template<class T>
22  inline void registerObject(T* object, NewObjectList<T>& objectList) { _id.registerObject(object, objectList); };
23protected:
24  NewClassID    _id;
25  std::string   _objectName;
26
27
28};
29NewObjectListDefinition(NewBaseObject);
30
31
32class Test :
33      public   NewBaseObject
34//    ,
35//      public BaseObject
36{
37public:
38  Test();
39  ~Test();
40
41
42  NewObjectListDeclaration(Test);
43  //ObjectListDeclaration(Test);
44};
45NewObjectListDefinitionID(Test, -1);
46
47Test::Test()
48{
49  this->registerObject(this, Test::objectList);
50
51
52//  this->setClassID(CL_PARENT_NODE, "Test");
53  // std::cout << "Test()\n";
54};
55Test::~Test()
56{
57  //  std::cout << "~Test()\n";
58}
59
60class Bone : public Test
61{
62public:
63  Bone()
64  {
65    this->registerObject(this, Bone::objectList);
66    //this->_id.listInheritance();
67    //std::cout << "LeafID:" << this->_id.leafClassID() << std::endl;
68
69    //std::cout << "Bone()\n";
70  };
71  ~Bone()
72  {
73    //  std::cout << "~Bone()\n";
74  };
75  NewObjectListDeclaration(Bone);
76};
77NewObjectListDefinitionID(Bone, -1);
78
79int main()
80{
81#define ITERATIONS 20
82#define COUNT 100
83  for (unsigned int i = 0; i < ITERATIONS; ++i)
84  {
85    std::cout<< i <<  std::endl ;
86    Bone* test = new Bone[COUNT];
87    delete []test;
88  }
89  //   char tmp[100];
90  //   for (unsigned int i = 0 ; i < 100; ++i)
91  //   {
92  //     sprintf(tmp, "Tmp_%d", i);
93  //     test[i].setName(tmp);
94  //   }
95  //   Test::objectList.debug();
96  //   //test->setName("Test-object");
97  //
98  //   std::cout << "Here is debug of all BaseObject\n";
99  //   BaseObject::objectList.debug();
100  // //   delete bone;
101  //   delete []test;
102  //   std::cout << "Again\n";
103  //   BaseObject::objectList.debug();
104
105}
106
Note: See TracBrowser for help on using the repository browser.