|
Mantid
|
The dynamic factory is a base dynamic factory for serving up objects in response to requests from other classes. More...
#include <Kernel/DynamicFactory.h>
Public Types | |
| using | AbstractFactory = AbstractInstantiator< Base > |
| A typedef for the instantiator. | |
| using | DynamicFactoryNotification = Mantid::Kernel::DynamicFactoryNotification |
| enum | NotificationStatus { Enabled , Disabled } |
| Defines the whether notifications are dispatched. More... | |
| enum | SubscribeAction { ErrorIfExists , OverwriteCurrent } |
| Defines replacement behaviour. More... | |
| using | UpdateNotification = Mantid::Kernel::DynamicFactoryUpdateNotification |
Public Member Functions | |
| virtual std::shared_ptr< Base > | create (const std::string &className) const |
| Creates a new instance of the class with the given name. | |
| virtual Base * | createUnwrapped (const std::string &className) const |
| Creates a new instance of the class with the given name, which is not wrapped in a boost shared_ptr. | |
| void | disableNotifications () |
| Disable notifications. | |
| DynamicFactory (const DynamicFactory &)=delete | |
| void | enableNotifications () |
| Enable notifications. | |
| bool | exists (const std::string &className) const |
| Returns true if the given class is currently registered. | |
| virtual const std::vector< std::string > | getKeys () const |
| Returns the keys in the map. | |
| DynamicFactory & | operator= (const DynamicFactory &)=delete |
| template<class C > | |
| void | subscribe (const std::string &className) |
| Registers the instantiator for the given class with the DynamicFactory. | |
| void | subscribe (const std::string &className, std::unique_ptr< AbstractFactory > pAbstractFactory, SubscribeAction replace=ErrorIfExists) |
| Registers the instantiator for the given class with the DynamicFactory. | |
| void | unsubscribe (const std::string &className) |
| Unregisters the given class and deletes the instantiator for the class. | |
| virtual | ~DynamicFactory ()=default |
| Destroys the DynamicFactory and deletes the instantiators for all registered classes. | |
Public Attributes | |
| Poco::NotificationCenter | notificationCenter |
| Sends notifications to observers. | |
Protected Member Functions | |
| DynamicFactory () | |
| Protected constructor for base class. | |
Private Types | |
| using | FactoryMap = std::map< std::string, std::unique_ptr< AbstractFactory >, Comparator > |
| A typedef for the map of registered classes. | |
Private Member Functions | |
| void | sendUpdateNotification () |
| Send an update notification. | |
| void | sendUpdateNotificationIfEnabled () |
| Send an update notification if they are enabled. | |
Private Attributes | |
| FactoryMap | _map |
| The map holding the registered class names and their instantiators. | |
| NotificationStatus | m_notifyStatus |
| Flag marking whether we should dispatch notifications. | |
The dynamic factory is a base dynamic factory for serving up objects in response to requests from other classes.
Definition at line 64 of file DynamicFactory.h.
| using Mantid::Kernel::DynamicFactory< Base, Comparator >::AbstractFactory = AbstractInstantiator<Base> |
A typedef for the instantiator.
Definition at line 88 of file DynamicFactory.h.
| using Mantid::Kernel::DynamicFactory< Base, Comparator >::DynamicFactoryNotification = Mantid::Kernel::DynamicFactoryNotification |
Definition at line 74 of file DynamicFactory.h.
|
private |
A typedef for the map of registered classes.
Definition at line 210 of file DynamicFactory.h.
| using Mantid::Kernel::DynamicFactory< Base, Comparator >::UpdateNotification = Mantid::Kernel::DynamicFactoryUpdateNotification |
Definition at line 75 of file DynamicFactory.h.
| enum Mantid::Kernel::DynamicFactory::NotificationStatus |
Defines the whether notifications are dispatched.
| Enumerator | |
|---|---|
| Enabled | |
| Disabled | |
Definition at line 68 of file DynamicFactory.h.
| enum Mantid::Kernel::DynamicFactory::SubscribeAction |
Defines replacement behaviour.
| Enumerator | |
|---|---|
| ErrorIfExists | |
| OverwriteCurrent | |
Definition at line 70 of file DynamicFactory.h.
|
delete |
|
virtualdefault |
Destroys the DynamicFactory and deletes the instantiators for all registered classes.
|
inlineprotected |
Protected constructor for base class.
Definition at line 198 of file DynamicFactory.h.
|
inlinevirtual |
Creates a new instance of the class with the given name.
The class must have been registered with subscribe() (typically done via a macro). If the class name is unknown, a NotFoundException is thrown.
| className | :: the name of the class you wish to create |
Reimplemented in Mantid::API::ImplicitFunctionFactoryImpl, Mantid::MDAlgorithms::MDTransfFactoryImpl, Mantid::API::ColumnFactoryImpl, Mantid::API::TransformScaleFactoryImpl, Mantid::API::ImplicitFunctionParameterParserFactoryImpl, and Mantid::API::ImplicitFunctionParserFactoryImpl.
Definition at line 99 of file DynamicFactory.h.
References Mantid::Kernel::DynamicFactory< Base, Comparator >::_map.
Referenced by Mantid::API::LiveListenerFactoryImpl::create(), Mantid::MDAlgorithms::MDTransfFactoryImpl::create(), Mantid::API::ColumnFactoryImpl::create(), Mantid::API::TransformScaleFactoryImpl::create(), and Mantid::API::AlgorithmFactoryImpl::createAlgorithm().
|
inlinevirtual |
Creates a new instance of the class with the given name, which is not wrapped in a boost shared_ptr.
This should be used with extreme care (or, better, not used)! The caller owns the returned instance. The class must have been registered with subscribe() (typically done via a macro). If the class name is unknown, a NotFoundException is thrown.
| className | :: the name of the class you wish to create |
Reimplemented in Mantid::API::LiveListenerFactoryImpl, Mantid::API::TransformScaleFactoryImpl, MantidQt::API::UserSubWindowFactoryImpl, and Mantid::API::ImplicitFunctionFactoryImpl.
Definition at line 116 of file DynamicFactory.h.
References Mantid::Kernel::DynamicFactory< Base, Comparator >::_map.
Referenced by MantidQt::API::UserSubWindowFactoryImpl::createUnwrapped().
|
inline |
Disable notifications.
Definition at line 85 of file DynamicFactory.h.
References Mantid::Kernel::DynamicFactory< Base, Comparator >::Disabled, and Mantid::Kernel::DynamicFactory< Base, Comparator >::m_notifyStatus.
|
inline |
Enable notifications.
Definition at line 80 of file DynamicFactory.h.
References Mantid::Kernel::DynamicFactory< Base, Comparator >::Enabled, and Mantid::Kernel::DynamicFactory< Base, Comparator >::m_notifyStatus.
|
inline |
Returns true if the given class is currently registered.
| className | :: the name of the class you wish to check |
Definition at line 177 of file DynamicFactory.h.
References Mantid::Kernel::DynamicFactory< Base, Comparator >::_map.
Referenced by Mantid::API::AlgorithmFactoryImpl::exists().
|
inlinevirtual |
Returns the keys in the map.
Reimplemented in Mantid::API::AlgorithmFactoryImpl.
Definition at line 181 of file DynamicFactory.h.
References Mantid::Kernel::DynamicFactory< Base, Comparator >::_map.
Referenced by Mantid::API::AlgorithmFactoryImpl::getKeys().
|
delete |
|
inlineprivate |
Send an update notification.
Definition at line 207 of file DynamicFactory.h.
References Mantid::Kernel::DynamicFactory< Base, Comparator >::notificationCenter.
Referenced by Mantid::Kernel::DynamicFactory< Base, Comparator >::sendUpdateNotificationIfEnabled().
|
inlineprivate |
Send an update notification if they are enabled.
Definition at line 202 of file DynamicFactory.h.
References Mantid::Kernel::DynamicFactory< Base, Comparator >::Enabled, Mantid::Kernel::DynamicFactory< Base, Comparator >::m_notifyStatus, and Mantid::Kernel::DynamicFactory< Base, Comparator >::sendUpdateNotification().
Referenced by Mantid::Kernel::DynamicFactory< Base, Comparator >::subscribe(), and Mantid::Kernel::DynamicFactory< Base, Comparator >::unsubscribe().
|
inline |
Registers the instantiator for the given class with the DynamicFactory.
The DynamicFactory takes ownership of the instantiator and deletes it when it's no longer used. If the class has already been registered, an ExistsException is thrown and the instantiator is deleted.
| className | :: the name of the class you wish to subscribe |
Definition at line 130 of file DynamicFactory.h.
References Mantid::Kernel::DynamicFactory< Base, Comparator >::subscribe().
Referenced by Mantid::Kernel::DynamicFactory< Base, Comparator >::subscribe(), and Mantid::API::FunctionFactoryImpl::subscribe().
|
inline |
Registers the instantiator for the given class with the DynamicFactory.
The DynamicFactory takes ownership of the instantiator and deletes it when it's no longer used. If the class has already been registered, an ExistsException is thrown and the instantiator is deleted.
| className | :: the name of the class you wish to subscribe |
| pAbstractFactory | :: A pointer to an abstractFactory for this class |
| replace | :: If ReplaceExisting then the given AbstractFactory replaces any existing factory with the same className, else throws std::runtime_error (default=ThrowOnExisting) |
Definition at line 145 of file DynamicFactory.h.
References Mantid::Kernel::DynamicFactory< Base, Comparator >::_map, Mantid::Kernel::DynamicFactory< Base, Comparator >::OverwriteCurrent, and Mantid::Kernel::DynamicFactory< Base, Comparator >::sendUpdateNotificationIfEnabled().
|
inline |
Unregisters the given class and deletes the instantiator for the class.
Throws a NotFoundException if the class has not been registered.
| className | :: the name of the class you wish to unsubscribe |
Definition at line 164 of file DynamicFactory.h.
References Mantid::Kernel::DynamicFactory< Base, Comparator >::_map, and Mantid::Kernel::DynamicFactory< Base, Comparator >::sendUpdateNotificationIfEnabled().
Referenced by Mantid::API::AlgorithmFactoryImpl::unsubscribe(), and Mantid::API::FunctionFactoryImpl::unsubscribe().
|
private |
The map holding the registered class names and their instantiators.
Definition at line 212 of file DynamicFactory.h.
Referenced by Mantid::Kernel::DynamicFactory< Base, Comparator >::create(), Mantid::Kernel::DynamicFactory< Base, Comparator >::createUnwrapped(), Mantid::Kernel::DynamicFactory< Base, Comparator >::exists(), Mantid::Kernel::DynamicFactory< Base, Comparator >::getKeys(), Mantid::Kernel::DynamicFactory< Base, Comparator >::subscribe(), and Mantid::Kernel::DynamicFactory< Base, Comparator >::unsubscribe().
|
private |
Flag marking whether we should dispatch notifications.
Definition at line 214 of file DynamicFactory.h.
Referenced by Mantid::Kernel::DynamicFactory< Base, Comparator >::disableNotifications(), Mantid::Kernel::DynamicFactory< Base, Comparator >::enableNotifications(), and Mantid::Kernel::DynamicFactory< Base, Comparator >::sendUpdateNotificationIfEnabled().
| Poco::NotificationCenter Mantid::Kernel::DynamicFactory< Base, Comparator >::notificationCenter |
Sends notifications to observers.
Observers can subscribe to notificationCenter using Poco::NotificationCenter::addObserver(...)
Definition at line 194 of file DynamicFactory.h.
Referenced by Mantid::Kernel::DynamicFactory< Base, Comparator >::sendUpdateNotification().