1 | #include "new_class_id.h" |
---|
2 | #include "new_object_list.h" |
---|
3 | #include <iostream> |
---|
4 | |
---|
5 | #include <base_object.h> |
---|
6 | |
---|
7 | class NewBaseObject |
---|
8 | { |
---|
9 | public: |
---|
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 | |
---|
16 | protected: |
---|
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); }; |
---|
23 | private: |
---|
24 | NewClassID _id; |
---|
25 | std::string _objectName; |
---|
26 | |
---|
27 | |
---|
28 | }; |
---|
29 | NewObjectListDefinition(NewBaseObject); |
---|
30 | |
---|
31 | |
---|
32 | class Test : public NewBaseObject |
---|
33 | { |
---|
34 | public: |
---|
35 | Test(); |
---|
36 | ~Test(); |
---|
37 | |
---|
38 | |
---|
39 | NewObjectListDeclaration(Test); |
---|
40 | //ObjectListDeclaration(Test); |
---|
41 | }; |
---|
42 | NewObjectListDefinition(Test); |
---|
43 | |
---|
44 | Test::Test() |
---|
45 | { |
---|
46 | // this->setClassID(CL_PARENT_NODE, "Test"); |
---|
47 | this->registerObject(this, Test::objectList); |
---|
48 | // std::cout << "Test()\n"; |
---|
49 | }; |
---|
50 | Test::~Test() |
---|
51 | { |
---|
52 | // std::cout << "~Test()\n"; |
---|
53 | } |
---|
54 | |
---|
55 | class Bone : public BaseObject |
---|
56 | { |
---|
57 | public: |
---|
58 | Bone() |
---|
59 | { |
---|
60 | // this->registerObject(this, Bone::objectList); |
---|
61 | //std::cout << "Bone()\n"; |
---|
62 | }; |
---|
63 | ~Bone() |
---|
64 | { |
---|
65 | // std::cout << "~Bone()\n"; |
---|
66 | }; |
---|
67 | NewObjectListDeclaration(Bone); |
---|
68 | }; |
---|
69 | NewObjectListDefinition(Bone); |
---|
70 | |
---|
71 | int main() |
---|
72 | { |
---|
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(); |
---|
94 | |
---|
95 | } |
---|
96 | |
---|