diff options
author | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2012-11-02 15:36:19 +0000 |
---|---|---|
committer | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2012-11-02 15:36:19 +0000 |
commit | c823b2bf3165990a556d50990adf4da5cee95593 (patch) | |
tree | 733f3d3a6ed7a5e8f80d4b4553299902d89b58b8 /packages/noncvs/windows/extra/Gem/dev/plugins/PluginFactory.h | |
parent | 2c0b722536a4ec2f723c289b695b983741c678f8 (diff) |
commit Gem 0.93.3 from http://gem.iem.at/releases/0.93.3/Gem-0.93.3-W32-i686.zip
svn path=/trunk/; revision=16521
Diffstat (limited to 'packages/noncvs/windows/extra/Gem/dev/plugins/PluginFactory.h')
-rw-r--r-- | packages/noncvs/windows/extra/Gem/dev/plugins/PluginFactory.h | 210 |
1 files changed, 105 insertions, 105 deletions
diff --git a/packages/noncvs/windows/extra/Gem/dev/plugins/PluginFactory.h b/packages/noncvs/windows/extra/Gem/dev/plugins/PluginFactory.h index 5755748e..87ea7cf3 100644 --- a/packages/noncvs/windows/extra/Gem/dev/plugins/PluginFactory.h +++ b/packages/noncvs/windows/extra/Gem/dev/plugins/PluginFactory.h @@ -1,105 +1,105 @@ -#ifndef _INCLUDE__GEM_PLUGINS_PLUGINFACTORY_H_ -#define _INCLUDE__GEM_PLUGINS_PLUGINFACTORY_H_ - -#include "Gem/ExportDef.h" - - -#include <map> -#include <vector> -#include <string> - -#include <typeinfo> -#include <iostream> - -namespace gem { - - class GEM_EXTERN BasePluginFactory { - public: - int doLoadPlugins(std::string basename, std::string path); - protected: - BasePluginFactory(); - virtual ~BasePluginFactory(void); - - std::vector<std::string>get(void); - void*get(std::string); - void set(std::string, void*); - - private: - class Pimpl; - Pimpl*m_pimpl; - }; - - template<class Class> - class GEM_EXPORT PluginFactory : public BasePluginFactory { - public: - - /** - * constructor function type (without arguments) - */ - typedef Class*(ctor_t)(void); - - /** - * register a a constructor associated with a given ID - */ - static void registerClass(std::string id, ctor_t*c); - /** - * get an instance of class constructed by the constructor associated with the given ID - */ - static Class*getInstance(std::string id); - - /** - * get a list of all IDs currently registered with this factory - */ - static std::vector<std::string>getIDs(void); - - /** - * load more plugins - */ - static int loadPlugins(std::string basename, std::string path=std::string("")); - - private: - static PluginFactory<Class>*s_factory; - static PluginFactory<Class>*getPluginFactory(); - - void doRegisterClass(std::string id, ctor_t*c); - Class*doGetInstance(std::string id); - std::vector<std::string>doGetIDs(void); - }; - - - namespace PluginFactoryRegistrar { - /** - * creates a new ChildClass and returns it as a (pointer to) an instance of BaseClass - */ - template<class ChildClass, class BaseClass> - static BaseClass* allocator(void); - - /** - * registers a ChildClass with a certain ID in the BaseClass factory - * - * example: - * static gem::PluginFactoryRegistrar<Child, Base, std::string > basefac_childreg("childID"); // register Child as 'childID' - * Base*instance=gem::PluginFactory<Base>::getInstance("childID"); // returns an instance of Child - */ - template<class ChildClass, class BaseClass> - struct registrar { - registrar(std::string ID); - }; - - /** - * registers a dummy constructor with a default ID - */ - template<class BaseClass> - struct dummy { - dummy(void); - }; - }; - -/* include the actual implementation */ -#include "PluginFactoryTimple.h" - - -}; // namespace gem - - -#endif /* _INCLUDE__GEM_PLUGINS_PLUGINFACTORY_H_ */ +#ifndef _INCLUDE__GEM_PLUGINS_PLUGINFACTORY_H_
+#define _INCLUDE__GEM_PLUGINS_PLUGINFACTORY_H_
+
+#include "Gem/ExportDef.h"
+
+
+#include <map>
+#include <vector>
+#include <string>
+
+#include <typeinfo>
+#include <iostream>
+
+namespace gem {
+
+ class GEM_EXTERN BasePluginFactory {
+ public:
+ int doLoadPlugins(std::string basename, std::string path);
+ protected:
+ BasePluginFactory();
+ virtual ~BasePluginFactory(void);
+
+ std::vector<std::string>get(void);
+ void*get(std::string);
+ void set(std::string, void*);
+
+ private:
+ class Pimpl;
+ Pimpl*m_pimpl;
+ };
+
+ template<class Class>
+ class GEM_EXPORT PluginFactory : public BasePluginFactory {
+ public:
+
+ /**
+ * constructor function type (without arguments)
+ */
+ typedef Class*(ctor_t)(void);
+
+ /**
+ * register a a constructor associated with a given ID
+ */
+ static void registerClass(std::string id, ctor_t*c);
+ /**
+ * get an instance of class constructed by the constructor associated with the given ID
+ */
+ static Class*getInstance(std::string id);
+
+ /**
+ * get a list of all IDs currently registered with this factory
+ */
+ static std::vector<std::string>getIDs(void);
+
+ /**
+ * load more plugins
+ */
+ static int loadPlugins(std::string basename, std::string path=std::string(""));
+
+ private:
+ static PluginFactory<Class>*s_factory;
+ static PluginFactory<Class>*getPluginFactory();
+
+ void doRegisterClass(std::string id, ctor_t*c);
+ Class*doGetInstance(std::string id);
+ std::vector<std::string>doGetIDs(void);
+ };
+
+
+ namespace PluginFactoryRegistrar {
+ /**
+ * creates a new ChildClass and returns it as a (pointer to) an instance of BaseClass
+ */
+ template<class ChildClass, class BaseClass>
+ static BaseClass* allocator(void);
+
+ /**
+ * registers a ChildClass with a certain ID in the BaseClass factory
+ *
+ * example:
+ * static gem::PluginFactoryRegistrar<Child, Base, std::string > basefac_childreg("childID"); // register Child as 'childID'
+ * Base*instance=gem::PluginFactory<Base>::getInstance("childID"); // returns an instance of Child
+ */
+ template<class ChildClass, class BaseClass>
+ struct registrar {
+ registrar(std::string ID);
+ };
+
+ /**
+ * registers a dummy constructor with a default ID
+ */
+ template<class BaseClass>
+ struct dummy {
+ dummy(void);
+ };
+ };
+
+/* include the actual implementation */
+#include "PluginFactoryTimple.h"
+
+
+}; // namespace gem
+
+
+#endif /* _INCLUDE__GEM_PLUGINS_PLUGINFACTORY_H_ */
|