diff options
author | Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl> | 2015-07-23 11:43:47 +0200 |
---|---|---|
committer | Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl> | 2015-07-23 11:52:05 +0200 |
commit | 9e077994b382b2df63e4b79dd2afebc50366d419 (patch) | |
tree | e13a50a670ad12b4eed70d6faefd663618c4ea5b /include | |
parent | 2f800d5c1a305a23906783ecaa075e3d5274ef26 (diff) | |
download | astra-9e077994b382b2df63e4b79dd2afebc50366d419.tar.gz astra-9e077994b382b2df63e4b79dd2afebc50366d419.tar.bz2 astra-9e077994b382b2df63e4b79dd2afebc50366d419.tar.xz astra-9e077994b382b2df63e4b79dd2afebc50366d419.zip |
Add hooks for plugin support to AstraObjectFactory
To use these hooks, add a specialization of findPlugin for the
desired type of object (e.g., Algorithms).
Diffstat (limited to 'include')
-rw-r--r-- | include/astra/AstraObjectFactory.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/astra/AstraObjectFactory.h b/include/astra/AstraObjectFactory.h index c935a7c..356acf9 100644 --- a/include/astra/AstraObjectFactory.h +++ b/include/astra/AstraObjectFactory.h @@ -73,6 +73,13 @@ public: */ T* create(const Config& _cfg); + /** Find a plugin. + * + * @param _sType Name of plugin to find. + * @return Pointer to a new, uninitialized object, or NULL if not found. + */ + T* findPlugin(std::string _sType); + }; @@ -93,6 +100,15 @@ CAstraObjectFactory<T, TypeList>::~CAstraObjectFactory() } + +//---------------------------------------------------------------------------------------- +// Hook for finding plugin in registered plugins. +template <typename T, typename TypeList> +T* CAstraObjectFactory<T, TypeList>::findPlugin(std::string _sType) +{ + return NULL; +} + //---------------------------------------------------------------------------------------- // Create template <typename T, typename TypeList> @@ -101,6 +117,9 @@ T* CAstraObjectFactory<T, TypeList>::create(std::string _sType) functor_find<T> finder = functor_find<T>(); finder.tofind = _sType; CreateObject<TypeList>::find(finder); + if (finder.res == NULL) { + finder.res = findPlugin(_sType); + } return finder.res; } |