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
RevLine 
[9669]1#include "new_class_id.h"
2#include "new_object_list.h"
3#include <iostream>
4
[9674]5#include <base_object.h>
6
7class NewBaseObject
[9669]8{
[9673]9public:
[9675]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; };
[9671]13
[9678]14    NewObjectListDeclaration(NewBaseObject);
[9672]15
[9671]16protected:
[9674]17  NewBaseObject(const std::string& objectName = "") : _objectName(objectName)
18  {
[9678]19       this->registerObject(this, objectList);
[9674]20  };
[9671]21  template<class T>
[9673]22  inline void registerObject(T* object, NewObjectList<T>& objectList) { _id.registerObject(object, objectList); };
[9678]23protected:
[9671]24  NewClassID    _id;
25  std::string   _objectName;
26
[9672]27
[9671]28};
[9678]29NewObjectListDefinition(NewBaseObject);
[9671]30
[9672]31
[9675]32class Test :
33      public   NewBaseObject
34//    ,
35//      public BaseObject
[9671]36{
[9669]37public:
38  Test();
39  ~Test();
40
41
42  NewObjectListDeclaration(Test);
43  //ObjectListDeclaration(Test);
44};
[9678]45NewObjectListDefinitionID(Test, -1);
[9669]46
47Test::Test()
[9671]48{
[9675]49  this->registerObject(this, Test::objectList);
[9678]50
51
[9674]52//  this->setClassID(CL_PARENT_NODE, "Test");
53  // std::cout << "Test()\n";
[9671]54};
[9669]55Test::~Test()
[9673]56{
[9674]57  //  std::cout << "~Test()\n";
[9673]58}
[9669]59
[9679]60class Bone : public Test
[9669]61{
62public:
[9673]63  Bone()
64  {
[9679]65    this->registerObject(this, Bone::objectList);
[9681]66    //this->_id.listInheritance();
[9682]67    //std::cout << "LeafID:" << this->_id.leafClassID() << std::endl;
[9679]68
[9673]69    //std::cout << "Bone()\n";
70  };
[9674]71  ~Bone()
72  {
73    //  std::cout << "~Bone()\n";
[9673]74  };
[9669]75  NewObjectListDeclaration(Bone);
76};
[9677]77NewObjectListDefinitionID(Bone, -1);
[9669]78
79int main()
80{
[9681]81#define ITERATIONS 20
82#define COUNT 100
83  for (unsigned int i = 0; i < ITERATIONS; ++i)
[9674]84  {
[9680]85    std::cout<< i <<  std::endl ;
[9681]86    Bone* test = new Bone[COUNT];
[9682]87    delete []test;
[9674]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();
[9669]104
105}
106
Note: See TracBrowser for help on using the repository browser.