Changeset 9671 in orxonox.OLD for trunk/src/lib/lang/test_object_list.cc
- Timestamp:
- Aug 21, 2006, 4:14:57 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/lang/test_object_list.cc
r9669 r9671 3 3 #include <iostream> 4 4 5 class Test 5 class BaseObject 6 { 7 public: 8 void setName(const std::string& name) { this->_objectName = name; }; 9 const std::string& name() const { return _objectName; }; 10 bool operator==(const std::string& name) const { return _objectName == name; }; 11 12 protected: 13 template<class T> 14 inline void registerObject(T* object, NewObjectList<T>& objectList) { _id.registerObject(object, objectList); }; 15 private: 16 NewClassID _id; 17 std::string _objectName; 18 19 }; 20 21 class Test : public BaseObject 6 22 { 7 23 public: … … 16 32 17 33 Test::Test() 18 { std::cout << "Test()\n"; }; 34 { 35 this->registerObject(this, Test::objectList); 36 std::cout << "Test()\n"; 37 }; 19 38 Test::~Test() 20 39 { std::cout << "~Test()\n"; } 21 40 22 class Bone 41 class Bone : public BaseObject 23 42 { 24 43 public: 25 Bone() { std::cout << "Bone()\n"; }; 44 Bone() { 45 this->registerObject(this, Bone::objectList); 46 std::cout << "Bone()\n"; }; 26 47 ~Bone() { std::cout << "~Bone()\n"; }; 27 48 NewObjectListDeclaration(Bone); … … 32 53 { 33 54 Test* test = new Test(); 55 test->setName("Testing"); 34 56 35 NewClassID id; 36 id.registerObject(test, Test::objectList); 57 Test::objectList.debug(); 37 58 38 59 delete test; 60 61 Test::objectList.debug(); 39 62 Bone* bone = new Bone(); 40 63 delete bone; 64 65 41 66 42 67 std::cout << NewObjectListBase::classCount() << std::endl;
Note: See TracChangeset
for help on using the changeset viewer.