MyGUI: MyGUI_GenericFactory.h Source File

MyGUI 3.2.2

MyGUI_GenericFactory.h
Go to the documentation of this file.
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
14 namespace MyGUI
15 {
16
17 template <typename Type>
18 class GenericFactory
19 {
20 public:
21 typedef delegates::CDelegate1<IObject*&> Delegate;
22 static typename Delegate::IDelegate* getFactory()
23 {
24 return newDelegate(createFromFactory);
25 }
26
27 private:
28 static void createFromFactory(IObject*& _instance)
29 {
30 _instance = new Type();
31 }
32 };
33
34 } // namespace MyGUI
35
36 #endif // MYGUI_GENERIC_FACTORY_H_
MyGUI_Delegate.h
MyGUI::GenericFactory::Delegate
delegates::CDelegate1< IObject *& > Delegate
Definition: MyGUI_GenericFactory.h:21
MyGUI::GenericFactory::getFactory
static Delegate::IDelegate * getFactory()
Definition: MyGUI_GenericFactory.h:22
MyGUI_Prerequest.h
MyGUI::IObject
Definition: MyGUI_IObject.h:16
MyGUI_Types.h
MyGUI::GenericFactory
Definition: MyGUI_GenericFactory.h:18
MyGUI
Definition: MyGUI_ActionController.h:14
newDelegate
MYGUI_TEMPLATE MYGUI_TEMPLATE_PARAMS delegates::IDelegateMYGUI_SUFFIX MYGUI_TEMPLATE_ARGS * newDelegate(void(*_func)(MYGUI_PARAMS))
Definition: MyGUI_DelegateImplement.h:117