Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 10, 2007, 8:34:48 PM (17 years ago)
Author:
landauf
Message:

changed the class-hierarchy creation: call Factory::createClassHierarchy() to create the hierarchy.
until now it was automatically created at the program-start, but that could have been a problem in the future when classes depend on ogre, because ogre isn't already initialized at that program-start, so i've changed it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/objecthierarchy/src/orxonox/core/ClassFactory.h

    r453 r457  
    1010
    1111#include "Identifier.h"
    12 #include "Debug.h"
    1312
    1413namespace orxonox
     
    2221    {
    2322        public:
    24             static bool create();
     23            static bool create(const std::string& name);
    2524            BaseObject* fabricate();
    2625
     
    3433
    3534    /**
    36         @brief Adds the ClassFactory to the Identifier of the same type and creates a new object to retrieve the parents.
     35        @brief Adds the ClassFactory to the Identifier of the same type and the Identifier to the Factory.
    3736        @return Always true (this is needed because the compiler only allows assignments before main())
    3837    */
    3938    template <class T>
    40     bool ClassFactory<T>::create()
     39    bool ClassFactory<T>::create(const std::string& name)
    4140    {
    42         // Add the ClassFactory to the Classidentifier of type T
    4341        ClassIdentifier<T>::getIdentifier()->addFactory(new ClassFactory<T>);
    44 
    45         // To create the new branch of the class-hierarchy, we create a new object and delete it afterwards.
    46         ClassIdentifier<T>::getIdentifier()->startCreatingHierarchy();
    47         COUT(4) << "*** Create Factory -> Create Class\n";
    48         BaseObject* temp = ClassIdentifier<T>::getIdentifier()->fabricate();
    49         delete temp;
    50         ClassIdentifier<T>::getIdentifier()->stopCreatingHierarchy();
     42        Factory::add(name, ClassIdentifier<T>::getIdentifier());
    5143
    5244        return true;
Note: See TracChangeset for help on using the changeset viewer.