MyGUI: MyGUI_GenericFactory.h Source File

MyGUI 3.4.2

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files
- Examples

- File List
- Globals

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#include "MyGUI_IObject.h"
14
15namespace MyGUI
16{
17
18 template <typename Type>
19 class GenericFactory
20 {
21 public:
22 using Delegate = delegates::CDelegate1<IObject*&>;
23 static typename Delegate::IDelegate* getFactory()
24 {
25 return newDelegate(createFromFactory);
26 }
27
28 private:
29 static void createFromFactory(IObject*& _instance)
30 {
31 _instance = new Type();
32 }
33 };
34
35} // namespace MyGUI
36
37#endif // MYGUI_GENERIC_FACTORY_H_
MyGUI_Delegate.h
MyGUI_IObject.h
MyGUI_Prerequest.h
MyGUI_Types.h
MyGUI::GenericFactory
Definition MyGUI_GenericFactory.h:20
MyGUI::GenericFactory::getFactory
static Delegate::IDelegate * getFactory()
Definition MyGUI_GenericFactory.h:23
MyGUI::IObject
Definition MyGUI_IObject.h:17
MyGUI::delegates::DelegateFunction
Definition MyGUI_Delegate.h:42
MyGUI::delegates::Delegate
Definition MyGUI_Delegate.h:136
MyGUI
Definition MyGUI_ActionController.h:15
MyGUI::newDelegate
delegates::DelegateFunction< Args... > * newDelegate(void(*_func)(Args... args))
Definition MyGUI_Delegate.h:99