MyGUI  3.2.1
MyGUI_GenericFactory.h
Go to the documentation of this file.
00001 /*
00002  * This source file is part of MyGUI. For the latest info, see http://mygui.info/
00003  * Distributed under the MIT License
00004  * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
00005  */
00006 
00007 #ifndef __MYGUI_GENERIC_FACTORY_H__
00008 #define __MYGUI_GENERIC_FACTORY_H__
00009 
00010 #include "MyGUI_Prerequest.h"
00011 #include "MyGUI_Types.h"
00012 #include "MyGUI_Delegate.h"
00013 
00014 namespace MyGUI
00015 {
00016 
00017     template <typename Type>
00018     class GenericFactory
00019     {
00020     public:
00021         typedef delegates::CDelegate1<IObject*&> Delegate;
00022         static typename Delegate::IDelegate* getFactory()
00023         {
00024             return newDelegate(createFromFactory);
00025         }
00026 
00027     private:
00028         static void createFromFactory(IObject*& _instance)
00029         {
00030             _instance = new Type();
00031         }
00032     };
00033 
00034 } // namespace MyGUI
00035 
00036 #endif // __MYGUI_GENERIC_FACTORY_H__