diff options
| author | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-07-12 22:10:48 +0100 | 
|---|---|---|
| committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-07-12 22:10:53 +0100 | 
| commit | 8d8f64a447300a98db0449cf30c6d3fbc10e351a (patch) | |
| tree | a529380f77580667d700ab002f18b63b27d69783 | |
| parent | Service creation refactor (diff) | |
| download | icetray-8d8f64a447300a98db0449cf30c6d3fbc10e351a.tar.bz2 icetray-8d8f64a447300a98db0449cf30c6d3fbc10e351a.tar.xz icetray-8d8f64a447300a98db0449cf30c6d3fbc10e351a.zip | |
Assert there is only one service factory and use it regardless of name.
Removes hardcoded requirement for a factory unintuatively called 'default'
| -rw-r--r-- | icetray/icetray/icetrayService.cpp | 4 | ||||
| -rw-r--r-- | icetray/unittests/testService.cpp | 2 | 
2 files changed, 4 insertions, 2 deletions
| diff --git a/icetray/icetray/icetrayService.cpp b/icetray/icetray/icetrayService.cpp index d206c57..518eeaa 100644 --- a/icetray/icetray/icetrayService.cpp +++ b/icetray/icetray/icetrayService.cpp @@ -29,7 +29,9 @@ namespace IceTray {  	Service *  	Service::create(Ice::CommunicatorPtr)  	{ -		return IceTray::ServiceFactory::createNew("default"); +		auto serviceFactories = AdHoc::PluginManager::getDefault()->getAll<IceTray::ServiceFactory>(); +		BOOST_ASSERT(serviceFactories.size() == 1); +		return serviceFactories.begin()->get()->implementation()->create();  	}  	void Service::start(const std::string & name, const Ice::CommunicatorPtr & ic, const Ice::StringSeq & args) diff --git a/icetray/unittests/testService.cpp b/icetray/unittests/testService.cpp index 88a61e9..8f678b0 100644 --- a/icetray/unittests/testService.cpp +++ b/icetray/unittests/testService.cpp @@ -8,5 +8,5 @@ TestService::addObjects(const std::string &, const Ice::CommunicatorPtr &, const  	IceTray::OptionsResolver<TestOptions> myOpts;  } -NAMEDFACTORY("default", TestService, IceTray::ServiceFactory); +FACTORY(TestService, IceTray::ServiceFactory); | 
