[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: |
---|
[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] | 16 | protected: |
---|
[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] | 23 | protected: |
---|
[9671] | 24 | NewClassID _id; |
---|
| 25 | std::string _objectName; |
---|
| 26 | |
---|
[9672] | 27 | |
---|
[9671] | 28 | }; |
---|
[9678] | 29 | NewObjectListDefinition(NewBaseObject); |
---|
[9671] | 30 | |
---|
[9672] | 31 | |
---|
[9675] | 32 | class Test : |
---|
| 33 | public NewBaseObject |
---|
| 34 | // , |
---|
| 35 | // public BaseObject |
---|
[9671] | 36 | { |
---|
[9669] | 37 | public: |
---|
| 38 | Test(); |
---|
| 39 | ~Test(); |
---|
| 40 | |
---|
| 41 | |
---|
| 42 | NewObjectListDeclaration(Test); |
---|
| 43 | //ObjectListDeclaration(Test); |
---|
| 44 | }; |
---|
[9678] | 45 | NewObjectListDefinitionID(Test, -1); |
---|
[9669] | 46 | |
---|
| 47 | Test::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] | 55 | Test::~Test() |
---|
[9673] | 56 | { |
---|
[9674] | 57 | // std::cout << "~Test()\n"; |
---|
[9673] | 58 | } |
---|
[9669] | 59 | |
---|
[9679] | 60 | class Bone : public Test |
---|
[9669] | 61 | { |
---|
| 62 | public: |
---|
[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] | 77 | NewObjectListDefinitionID(Bone, -1); |
---|
[9669] | 78 | |
---|
| 79 | int 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 | |
---|