00001
00002 #ifndef _EXTERNALAPP_H_
00003 #define _EXTERNALAPP_H_
00004
00005 #include <map>
00006 #include <string>
00007
00008 namespace FD {
00009
00010 class ExternalApp;
00011
00012 class AppFactory {
00013 public:
00014 virtual ExternalApp *create()=0;
00015 };
00016
00017 template <class T>
00018 class _AppFactory : public AppFactory{
00019 public:
00020 ExternalApp *create() {return new T();}
00021 };
00022
00023 class ExternalApp {
00024 static std::map<std::string, AppFactory *> &factories();
00025 protected:
00026 public:
00027 static int addAppFactory(std::string name, AppFactory *f) {factories()[name] = f;}
00028 static ExternalApp *startApp(std::string name) {return factories()[name]->create();}
00029 };
00030
00031 }
00032 #endif