diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-09-17 19:04:55 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-09-17 19:04:55 +0100 |
commit | 0c1b1f8eac847ada60e702533ff44aec7c16da41 (patch) | |
tree | 160d0edb452ff0a6d0203a4856fce270f70986c6 | |
parent | Add doxygen comments (diff) | |
download | libadhocutil-0c1b1f8eac847ada60e702533ff44aec7c16da41.tar.bz2 libadhocutil-0c1b1f8eac847ada60e702533ff44aec7c16da41.tar.xz libadhocutil-0c1b1f8eac847ada60e702533ff44aec7c16da41.zip |
Add instantiation macros
-rw-r--r-- | libadhocutil/factory.impl.h | 6 | ||||
-rw-r--r-- | libadhocutil/plugins.impl.h | 8 | ||||
-rw-r--r-- | libadhocutil/unittests/testFactory.cpp | 3 |
3 files changed, 17 insertions, 0 deletions
diff --git a/libadhocutil/factory.impl.h b/libadhocutil/factory.impl.h index 4e34310..5aefba4 100644 --- a/libadhocutil/factory.impl.h +++ b/libadhocutil/factory.impl.h @@ -2,6 +2,7 @@ #define ADHOCUTIL_FACTORY_IMPL_H #include "factory.h" +#include "plugins.impl.h" namespace AdHoc { template <typename Base, typename ... Params> @@ -21,5 +22,10 @@ namespace AdHoc { return get(name)->create(p...); } } + +#define INSTANIATEFACTORY(Base, ...) \ + template class AdHoc::Factory<Base, __VA_ARGS__>; \ + INSTANIATEPLUGINOF(Base) + #endif diff --git a/libadhocutil/plugins.impl.h b/libadhocutil/plugins.impl.h index 44b6dab..aad6b2d 100644 --- a/libadhocutil/plugins.impl.h +++ b/libadhocutil/plugins.impl.h @@ -75,5 +75,13 @@ namespace AdHoc { } } +#define INSTANIATEPLUGINOF(T) \ + template class AdHoc::PluginOf<T>; \ + template void AdHoc::PluginManager::add<T>(const T *, const std::string &, const std::string &, int); \ + template void AdHoc::PluginManager::remove<T>(const std::string &); \ + template boost::shared_ptr<const AdHoc::PluginOf<T>> AdHoc::PluginManager::get<T>(const std::string &) const; \ + template const T * AdHoc::PluginManager::getImplementation<T>(const std::string &) const; \ + template std::set<boost::shared_ptr<const AdHoc::PluginOf<T>>> AdHoc::PluginManager::getAll<T>() const; \ + #endif diff --git a/libadhocutil/unittests/testFactory.cpp b/libadhocutil/unittests/testFactory.cpp index 9b463f1..6c0a5d5 100644 --- a/libadhocutil/unittests/testFactory.cpp +++ b/libadhocutil/unittests/testFactory.cpp @@ -11,6 +11,7 @@ using namespace AdHoc; class BaseThing { public: BaseThing(int, const std::string &){} + virtual ~BaseThing() = default; virtual void execute() const = 0; }; @@ -31,6 +32,8 @@ typedef AdHoc::Factory<BaseThing, int, std::string> BaseThingFactory; NAMEDFACTORY("a", ImplOfThing, BaseThingFactory); FACTORY(OtherImplOfThing, BaseThingFactory); +INSTANIATEFACTORY(BaseThing, int, std::string); + BOOST_AUTO_TEST_CASE( ready ) { BOOST_REQUIRE_EQUAL(2, PluginManager::getDefault()->count()); |