1 /*
2  * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3  * Distributed under the MIT License
4  * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5  */
6 
7 #ifndef MYGUI_GENERIC_FACTORY_H_
8 #define MYGUI_GENERIC_FACTORY_H_
9 
10 #include "MyGUI_Prerequest.h"
11 #include "MyGUI_Types.h"
12 #include "MyGUI_Delegate.h"
13 #include "MyGUI_IObject.h"
14 
15 namespace MyGUI
16 {
17 
18 	template <typename Type>
19 	class GenericFactory
20 	{
21 	public:
22 		using Delegate = delegates::CDelegate1<IObject*&>;
getFactory()23 		static typename Delegate::IDelegate* getFactory()
24 		{
25 			return newDelegate(createFromFactory);
26 		}
27 
28 	private:
createFromFactory(IObject * & _instance)29 		static void createFromFactory(IObject*& _instance)
30 		{
31 			_instance = new Type();
32 		}
33 	};
34 
35 } // namespace MyGUI
36 
37 #endif // MYGUI_GENERIC_FACTORY_H_
38