Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 11, 2013, 4:23:41 PM (11 years ago)
Author:
landauf
Message:

removed constructor arguments from ClassFactories. use the helper-function registerClass() to add the factory to the corresponding identifier

File:
1 edited

Legend:

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

    r9635 r9637  
    4343
    4444#include "util/Output.h"
    45 #include "core/class/Identifier.h"
    4645
    4746namespace orxonox
     
    5453    {
    5554        public:
    56             virtual ~Factory() {};
     55            virtual ~Factory() {}
    5756            virtual Identifiable* fabricate(Context* context) = 0;
    5857    };
     
    6160    // ###      ClassFactory       ###
    6261    // ###############################
    63     /// The ClassFactory is able to create new objects of a specific class that require no constructor arguments.
     62    /// The ClassFactory is the base-class of all class-spezific factories
    6463    template <class T>
    6564    class ClassFactory : public Factory
    6665    {
     66    };
     67
     68    // ###############################
     69    // ###   ClassFactoryNoArgs    ###
     70    // ###############################
     71    /// The ClassFactoryNoArgs is able to create new objects of a specific class that require no constructor arguments.
     72    template <class T>
     73    class ClassFactoryNoArgs : public ClassFactory<T>
     74    {
    6775        public:
    68             /**
    69                 @brief Constructor: Adds the ClassFactory to the Identifier of the same type.
    70                 @param name The name of the class
    71                 @param bLoadable True if the class can be loaded through XML
    72             */
    73             ClassFactory(const std::string& name, bool bLoadable = true)
    74             {
    75                 orxout(verbose, context::misc::factory) << "Create entry for " << name << " in Factory." << endl;
    76                 ClassIdentifier<T>::getIdentifier(name)->setFactory(this);
    77                 ClassIdentifier<T>::getIdentifier()->setLoadable(bLoadable);
    78             }
    79 
    8076            /**
    8177                @brief Creates and returns a new object of class T.
     
    9389    /// The ClassFactoryWithContext is able to create new objects of a specific class that require a context as constructor argument
    9490    template <class T>
    95     class ClassFactoryWithContext : public Factory
     91    class ClassFactoryWithContext : public ClassFactory<T>
    9692    {
    9793        public:
    98             /**
    99                 @brief Constructor: Adds the ClassFactory to the Identifier of the same type.
    100                 @param name The name of the class
    101                 @param bLoadable True if the class can be loaded through XML
    102             */
    103             ClassFactoryWithContext(const std::string& name, bool bLoadable = true)
    104             {
    105                 orxout(verbose, context::misc::factory) << "Create entry for " << name << " in Factory." << endl;
    106                 ClassIdentifier<T>::getIdentifier(name)->setFactory(this);
    107                 ClassIdentifier<T>::getIdentifier()->setLoadable(bLoadable);
    108             }
    109 
    11094            /**
    11195                @brief Creates and returns a new object of class T.
Note: See TracChangeset for help on using the changeset viewer.