Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9556 for code/branches/core6


Ignore:
Timestamp:
Mar 23, 2013, 4:34:14 PM (12 years ago)
Author:
landauf
Message:

fabricate() should return OrxonoxClass*

Location:
code/branches/core6/src/libraries
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core6/src/libraries/core/ClassFactory.h

    r8858 r9556  
    5555        public:
    5656            virtual ~Factory() {};
    57             virtual BaseObject* fabricate(BaseObject* creator) = 0;
     57            virtual OrxonoxClass* fabricate(BaseObject* creator) = 0;
    5858    };
    5959
     
    8282                @return The new object
    8383            */
    84             inline BaseObject* fabricate(BaseObject* creator)
     84            inline OrxonoxClass* fabricate(BaseObject* creator)
    8585            {
    86                 return static_cast<BaseObject*>(new T(creator));
     86                return static_cast<OrxonoxClass*>(new T(creator));
    8787            }
    8888    };
  • code/branches/core6/src/libraries/core/Identifier.cc

    r8858 r9556  
    198198            if (it->second->hasFactory())
    199199            {
    200                 BaseObject* temp = it->second->fabricate(0);
     200                OrxonoxClass* temp = it->second->fabricate(0);
    201201                temp->destroy();
    202202            }
     
    234234        @return The new object
    235235    */
    236     BaseObject* Identifier::fabricate(BaseObject* creator)
     236    OrxonoxClass* Identifier::fabricate(BaseObject* creator)
    237237    {
    238238        if (this->factory_)
    239239        {
    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);
    241241        }
    242242        else
  • code/branches/core6/src/libraries/core/Identifier.h

    r8858 r9556  
    5656    object->getIdentifier()->getName();                                         // returns "MyClass"
    5757
    58     BaseObject* other = object->getIdentifier()->fabricate(0);                  // fabricates a new instance of MyClass
     58    OrxonoxClass* other = object->getIdentifier()->fabricate(0);                // fabricates a new instance of MyClass
    5959
    6060
     
    6262    ObjectListBase* objects = object->getIdentifier()->getObjects();            // get a pointer to the object-list
    6363    int count;
    64     for (Iterator<BaseObject> it = objects.begin(); it != objects.end(); ++it)  // iterate through the objects
     64    for (Iterator<MyClass> it = objects.begin(); it != objects.end(); ++it)     // iterate through the objects
    6565        ++count;
    6666    orxout() << count << endl;                                                  // prints "2" because we created 2 instances of MyClass so far
     
    133133            inline bool hasFactory() const { return (this->factory_ != 0); }
    134134
    135             BaseObject* fabricate(BaseObject* creator);
     135            OrxonoxClass* fabricate(BaseObject* creator);
    136136
    137137            /// Returns true if the class can be loaded through XML.
  • code/branches/core6/src/libraries/core/SubclassIdentifier.h

    r8858 r9556  
    5353    There are two possibilities to create an object out of a SubclassIdentifier: Either you just use
    5454    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 using
     55    returns a @c OrxonoxClass* pointer, or you use the function of SubclassIdentifier, this time by using
    5656    @c operator., which returns a @c BaseClass* pointer (@a BaseClass is the baseclass specified by the
    5757    template argument):
    5858    @code
    59     identifier->fabricate();    // calls Identifier::fabricate(), creates a SubClass, returns a BaseObject* pointer
     59    identifier->fabricate();    // calls Identifier::fabricate(), creates a SubClass, returns a OrxonoxClass* pointer
    6060
    6161    identifier.fabricate();     // calls SubclassIdentifier::fabricate(), creates a SubClass, returns a BaseClass* pointer
     
    165165            T* fabricate(BaseObject* creator) const
    166166            {
    167                 BaseObject* newObject = this->identifier_->fabricate(creator);
     167                OrxonoxClass* newObject = this->identifier_->fabricate(creator);
    168168
    169169                // Check if the creation was successful
  • code/branches/core6/src/libraries/core/XMLPort.cc

    r8858 r9556  
    8989                        orxout(verbose, context::xml) << object->getLoaderIndentation() << "fabricating " << child->Value() << "..." << endl;
    9090
    91                         BaseObject* newObject = identifier->fabricate(object);
     91                        BaseObject* newObject = orxonox_cast<BaseObject*>(identifier->fabricate(object));
    9292                        newObject->setLoaderIndentation(object->getLoaderIndentation() + "  ");
    9393
  • code/branches/core6/src/libraries/network/synchronisable/Synchronisable.cc

    r8858 r9556  
    156156    }
    157157    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));
    159159    assert(bo);
    160160    Synchronisable *no = orxonox_cast<Synchronisable*>(bo);
Note: See TracChangeset for help on using the changeset viewer.