13#ifndef RTCTK_COMPONENTFRAMEWORK_FACTORYREGISTRY_HPP
14#define RTCTK_COMPONENTFRAMEWORK_FACTORYREGISTRY_HPP
46template <
class BaseIf>
145 static std::shared_ptr<FactoryRegistry<BaseIf>>
GetInstance();
155 mutable std::mutex m_mutex;
158 std::vector<const FactoryIf*> m_factories;
187template <
class BaseIf,
class Factory>
202 std::shared_ptr<FactoryRegistry<BaseIf>> m_registry;
The base class for all factory objects that are registered in the FactoryRegistry.
Definition: factoryRegistry.hpp:57
typename BaseIf::AdapterIdType AdapterIdType
Definition: factoryRegistry.hpp:59
virtual std::unique_ptr< BaseIf > CreateInstance(const AdapterIdType &id) const =0
Create a new adapter instance to access the service specified by the given identifier.
virtual ~FactoryIf()=default
virtual bool CanHandle(const AdapterIdType &id) const =0
Check if this factory is compatible with the given service identifier.
A simple registry of various factory objects.
Definition: factoryRegistry.hpp:47
void Register(const FactoryIf *factory)
Register the factory if it was not already registered.
Definition: factoryRegistry.ipp:37
void Deregister(const FactoryIf *factory) noexcept
Remove the factory from the registry if it was already registered.
Definition: factoryRegistry.ipp:48
FactoryRegistry()=default
~FactoryRegistry()
Definition: factoryRegistry.ipp:24
static std::shared_ptr< FactoryRegistry< BaseIf > > GetInstance()
Returns the registry singleton.
Definition: factoryRegistry.ipp:71
const FactoryIf * FindCompatibleFactory(const AdapterIdType &id) const noexcept
Finds the first factory that can handle the given identifier.
Definition: factoryRegistry.ipp:60
typename BaseIf::AdapterIdType AdapterIdType
Definition: factoryRegistry.hpp:49
A helper class used to perform registration and deregistration of a factory.
Definition: factoryRegistry.hpp:188
RegisterFactory()
Definition: factoryRegistry.ipp:103
~RegisterFactory()
Definition: factoryRegistry.ipp:109
Implementation file for FactoryRegistry and related helper template classes.
Definition: commandReplier.cpp:22