Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 1, 2008, 7:04:09 PM (16 years ago)
Author:
landauf
Message:

merged objecthierarchy branch back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/core/ClassFactory.h

    r1747 r2087  
    5555    {
    5656        public:
    57             static bool create(const std::string& name);
    58             BaseObject* fabricate();
     57            static bool create(const std::string& name, bool bLoadable = true);
     58            BaseObject* fabricate(BaseObject* creator);
    5959
    6060        private:
     
    6363            virtual ~ClassFactory() {}                      // Don't delete
    6464
    65             static T* createNewObject();
     65            static T* createNewObject(BaseObject* creator);
    6666    };
    6767
    6868    /**
    6969        @brief Adds the ClassFactory to the Identifier of the same type and the Identifier to the Factory.
     70        @param name The name of the class
     71        @param bLoadable True if the class can be loaded through XML
    7072        @return Always true (this is needed because the compiler only allows assignments before main())
    7173    */
    7274    template <class T>
    73     bool ClassFactory<T>::create(const std::string& name)
     75    bool ClassFactory<T>::create(const std::string& name, bool bLoadable)
    7476    {
    7577        COUT(4) << "*** ClassFactory: Create entry for " << name << " in Factory." << std::endl;
    7678        ClassIdentifier<T>::getIdentifier(name)->addFactory(new ClassFactory<T>);
     79        ClassIdentifier<T>::getIdentifier()->setLoadable(bLoadable);
    7780        Factory::add(name, ClassIdentifier<T>::getIdentifier());
    7881
     
    8588    */
    8689    template <class T>
    87     BaseObject* ClassFactory<T>::fabricate()
     90    BaseObject* ClassFactory<T>::fabricate(BaseObject* creator)
    8891    {
    89         return ClassFactory<T>::createNewObject();
     92        return ClassFactory<T>::createNewObject(creator);
    9093    }
    9194
     
    9598    */
    9699    template <class T>
    97     T* ClassFactory<T>::createNewObject()
     100    T* ClassFactory<T>::createNewObject(BaseObject* creator)
    98101    {
    99         return new T;
     102        return new T(creator);
    100103    }
    101104}
Note: See TracChangeset for help on using the changeset viewer.