Changeset 9556
- Timestamp:
- Mar 23, 2013, 4:34:14 PM (12 years ago)
- Location:
- code/branches/core6/src/libraries
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core6/src/libraries/core/ClassFactory.h
r8858 r9556 55 55 public: 56 56 virtual ~Factory() {}; 57 virtual BaseObject* fabricate(BaseObject* creator) = 0;57 virtual OrxonoxClass* fabricate(BaseObject* creator) = 0; 58 58 }; 59 59 … … 82 82 @return The new object 83 83 */ 84 inline BaseObject* fabricate(BaseObject* creator)84 inline OrxonoxClass* fabricate(BaseObject* creator) 85 85 { 86 return static_cast< BaseObject*>(new T(creator));86 return static_cast<OrxonoxClass*>(new T(creator)); 87 87 } 88 88 }; -
code/branches/core6/src/libraries/core/Identifier.cc
r8858 r9556 198 198 if (it->second->hasFactory()) 199 199 { 200 BaseObject* temp = it->second->fabricate(0);200 OrxonoxClass* temp = it->second->fabricate(0); 201 201 temp->destroy(); 202 202 } … … 234 234 @return The new object 235 235 */ 236 BaseObject* Identifier::fabricate(BaseObject* creator)236 OrxonoxClass* Identifier::fabricate(BaseObject* creator) 237 237 { 238 238 if (this->factory_) 239 239 { 240 return this->factory_->fabricate(creator); // We have to return a BaseObject, because we don't know the exact type.240 return this->factory_->fabricate(creator); 241 241 } 242 242 else -
code/branches/core6/src/libraries/core/Identifier.h
r8858 r9556 56 56 object->getIdentifier()->getName(); // returns "MyClass" 57 57 58 BaseObject* other = object->getIdentifier()->fabricate(0);// fabricates a new instance of MyClass58 OrxonoxClass* other = object->getIdentifier()->fabricate(0); // fabricates a new instance of MyClass 59 59 60 60 … … 62 62 ObjectListBase* objects = object->getIdentifier()->getObjects(); // get a pointer to the object-list 63 63 int count; 64 for (Iterator< BaseObject> it = objects.begin(); it != objects.end(); ++it)// iterate through the objects64 for (Iterator<MyClass> it = objects.begin(); it != objects.end(); ++it) // iterate through the objects 65 65 ++count; 66 66 orxout() << count << endl; // prints "2" because we created 2 instances of MyClass so far … … 133 133 inline bool hasFactory() const { return (this->factory_ != 0); } 134 134 135 BaseObject* fabricate(BaseObject* creator);135 OrxonoxClass* fabricate(BaseObject* creator); 136 136 137 137 /// Returns true if the class can be loaded through XML. -
code/branches/core6/src/libraries/core/SubclassIdentifier.h
r8858 r9556 53 53 There are two possibilities to create an object out of a SubclassIdentifier: Either you just use 54 54 the @c fabricate() function of the assigned Identifier through the overloaded @c operator->, which 55 returns a @c BaseObject* pointer, or you use the function of SubclassIdentifier, this time by using55 returns a @c OrxonoxClass* pointer, or you use the function of SubclassIdentifier, this time by using 56 56 @c operator., which returns a @c BaseClass* pointer (@a BaseClass is the baseclass specified by the 57 57 template argument): 58 58 @code 59 identifier->fabricate(); // calls Identifier::fabricate(), creates a SubClass, returns a BaseObject* pointer59 identifier->fabricate(); // calls Identifier::fabricate(), creates a SubClass, returns a OrxonoxClass* pointer 60 60 61 61 identifier.fabricate(); // calls SubclassIdentifier::fabricate(), creates a SubClass, returns a BaseClass* pointer … … 165 165 T* fabricate(BaseObject* creator) const 166 166 { 167 BaseObject* newObject = this->identifier_->fabricate(creator);167 OrxonoxClass* newObject = this->identifier_->fabricate(creator); 168 168 169 169 // Check if the creation was successful -
code/branches/core6/src/libraries/core/XMLPort.cc
r8858 r9556 89 89 orxout(verbose, context::xml) << object->getLoaderIndentation() << "fabricating " << child->Value() << "..." << endl; 90 90 91 BaseObject* newObject = identifier->fabricate(object);91 BaseObject* newObject = orxonox_cast<BaseObject*>(identifier->fabricate(object)); 92 92 newObject->setLoaderIndentation(object->getLoaderIndentation() + " "); 93 93 -
code/branches/core6/src/libraries/network/synchronisable/Synchronisable.cc
r8858 r9556 156 156 } 157 157 assert(getSynchronisable(header.getObjectID())==0); //make sure no object with this id exists 158 BaseObject *bo = id->fabricate(creator);158 BaseObject *bo = orxonox_cast<BaseObject*>(id->fabricate(creator)); 159 159 assert(bo); 160 160 Synchronisable *no = orxonox_cast<Synchronisable*>(bo);
Note: See TracChangeset
for help on using the changeset viewer.