Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: nicer output

File size: 2.1 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);
66    this->_id.listInheritance();
[9680]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{
[9674]81  for (unsigned int i = 0; i < 20; ++i)
82  {
[9680]83    std::cout<< i <<  std::endl ;
[9679]84    Bone* test = new Bone[10000];
[9675]85    // delete[]test;
[9674]86  }
87  //   char tmp[100];
88  //   for (unsigned int i = 0 ; i < 100; ++i)
89  //   {
90  //     sprintf(tmp, "Tmp_%d", i);
91  //     test[i].setName(tmp);
92  //   }
93  //   Test::objectList.debug();
94  //   //test->setName("Test-object");
95  //
96  //   std::cout << "Here is debug of all BaseObject\n";
97  //   BaseObject::objectList.debug();
98  // //   delete bone;
99  //   delete []test;
100  //   std::cout << "Again\n";
101  //   BaseObject::objectList.debug();
[9669]102
103}
104
Note: See TracBrowser for help on using the repository browser.