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