summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libadhocutil/factory.impl.h6
-rw-r--r--libadhocutil/plugins.impl.h18
-rw-r--r--libadhocutil/unittests/testFactory.cpp4
3 files changed, 15 insertions, 13 deletions
diff --git a/libadhocutil/factory.impl.h b/libadhocutil/factory.impl.h
index bbba002..c257884 100644
--- a/libadhocutil/factory.impl.h
+++ b/libadhocutil/factory.impl.h
@@ -25,13 +25,11 @@ namespace AdHoc {
#define INSTANTIATEVOIDFACTORY(Base) \
template class AdHoc::Factory<Base>; \
- typedef AdHoc::Factory<Base> FactoryType; \
- INSTANTIATEPLUGINOF(FactoryType)
+ INSTANTIATEPLUGINOF(AdHoc::Factory<Base>)
#define INSTANTIATEFACTORY(Base, ...) \
template class AdHoc::Factory<Base, __VA_ARGS__>; \
- typedef AdHoc::Factory<Base, __VA_ARGS__> FactoryType; \
- INSTANTIATEPLUGINOF(FactoryType)
+ INSTANTIATEPLUGINOF(AdHoc::Factory<Base, __VA_ARGS__>)
#endif
diff --git a/libadhocutil/plugins.impl.h b/libadhocutil/plugins.impl.h
index 1947845..8b64002 100644
--- a/libadhocutil/plugins.impl.h
+++ b/libadhocutil/plugins.impl.h
@@ -89,15 +89,15 @@ namespace AdHoc {
}
}
-#define INSTANTIATEPLUGINOF(T) \
- template class AdHoc::PluginOf<T>; \
- template void AdHoc::PluginManager::add<T>(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 T * AdHoc::PluginManager::getImplementation<T>(const std::string &) const; \
- template std::set<boost::shared_ptr<const AdHoc::PluginOf<T>>> AdHoc::PluginManager::getAll<T>() const; \
- template void AdHoc::PluginManager::addResolver<T>(const AdHoc::PluginManager::PluginResolver & f); \
- template void AdHoc::PluginManager::removeResolver<T>(); \
+#define INSTANTIATEPLUGINOF(...) \
+ template class AdHoc::PluginOf<__VA_ARGS__>; \
+ template void AdHoc::PluginManager::add<__VA_ARGS__>(__VA_ARGS__ *, const std::string &, const std::string &, int); \
+ template void AdHoc::PluginManager::remove<__VA_ARGS__>(const std::string &); \
+ template boost::shared_ptr<const AdHoc::PluginOf<__VA_ARGS__>> AdHoc::PluginManager::get<__VA_ARGS__>(const std::string &) const; \
+ template __VA_ARGS__ * AdHoc::PluginManager::getImplementation<__VA_ARGS__>(const std::string &) const; \
+ template std::set<boost::shared_ptr<const AdHoc::PluginOf<__VA_ARGS__>>> AdHoc::PluginManager::getAll<__VA_ARGS__>() const; \
+ template void AdHoc::PluginManager::addResolver<__VA_ARGS__>(const AdHoc::PluginManager::PluginResolver & f); \
+ template void AdHoc::PluginManager::removeResolver<__VA_ARGS__>(); \
#define PLUGINRESOLVER(T, F) \
namespace MAKE_UNIQUE(__plugin__) { \
diff --git a/libadhocutil/unittests/testFactory.cpp b/libadhocutil/unittests/testFactory.cpp
index 24f731f..7a94aa9 100644
--- a/libadhocutil/unittests/testFactory.cpp
+++ b/libadhocutil/unittests/testFactory.cpp
@@ -33,6 +33,10 @@ NAMEDFACTORY("a", ImplOfThing, BaseThingFactory);
FACTORY(OtherImplOfThing, BaseThingFactory);
INSTANTIATEFACTORY(BaseThing, int, std::string);
+// Multiple factories in one compilation unit
+INSTANTIATEFACTORY(BaseThing, std::string, std::string);
+// Factories of things with commas
+INSTANTIATEFACTORY(BaseThing, std::map<std::string, std::string>);
BOOST_AUTO_TEST_CASE( ready )
{