00001
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 }
00035
00036 #endif // __MYGUI_GENERIC_FACTORY_H__