Mantid
|
This factory takes a SymmetryOperation and generates the corresponding SymmetryElement. More...
#include <SymmetryElementFactory.h>
Public Member Functions | |
SymmetryElement_sptr | createSymElement (const SymmetryOperation &operation) |
Creates a SymmetryElement from a SymmetryOperation. More... | |
template<typename T > | |
void | subscribeSymmetryElementGenerator (const std::string &generatorClassName) |
Subscribes the generator of type T with its class name into the factory, throws std::runtime_error if a class with the same name has already been registered. More... | |
virtual | ~SymmetryElementFactoryImpl ()=default |
Protected Member Functions | |
SymmetryElement_sptr | createFromPrototype (const std::string &identifier) const |
Creates a SymmetryElement from an internally stored prototype. More... | |
AbstractSymmetryElementGenerator_sptr | getGenerator (const SymmetryOperation &operation) const |
Returns a generator that can process the supplied symmetry operation or an invalid pointer if no appropriate generator is found. More... | |
void | insertPrototype (const std::string &identifier, const SymmetryElement_sptr &prototype) |
Inserts the provided prototype into the factory. More... | |
bool | isSubscribed (const std::string &generatorClassName) const |
Checks whether a generator with that class name is already subscribed. More... | |
void | subscribe (const AbstractSymmetryElementGenerator_sptr &generator, const std::string &generatorClassName) |
Subscribes a generator and stores its class name for later checks. More... | |
Protected Attributes | |
std::unordered_set< std::string > | m_generatorNames |
std::vector< AbstractSymmetryElementGenerator_sptr > | m_generators |
std::map< std::string, SymmetryElement_sptr > | m_prototypes |
Friends | |
struct | Mantid::Kernel::CreateUsingNew< SymmetryElementFactoryImpl > |
This factory takes a SymmetryOperation and generates the corresponding SymmetryElement.
It determines what type of element it is (rotation, mirror or glide plane, ...) and creates the correct object. An example would be this:
Please see also the additional documentation for SymmetryElement.
The factory itself stores generators that can generate a SymmetryElement from a provided SymmetryOperation. Each time createSymElement is called, the factory checks if an operation with that identifier-string has been processed before. If that's not the case, it tries to find an AbstractSymmetryElementGenerator that is able to process that operation. The SymmetryElement that is generated by the generator is not returned directly, instead it is stored as a prototype object, so that subsequent calls with the same SymmetryOperation do not have to go through the derivation algorithm again. Finally a clone of the now available prototype is returned. This way, symmetry elements are only derived once.
Definition at line 188 of file SymmetryElementFactory.h.
|
virtualdefault |
|
protected |
Creates a SymmetryElement from an internally stored prototype.
Definition at line 339 of file SymmetryElementFactory.cpp.
References m_prototypes.
Referenced by createSymElement().
SymmetryElement_sptr Mantid::Geometry::SymmetryElementFactoryImpl::createSymElement | ( | const SymmetryOperation & | operation | ) |
Creates a SymmetryElement from a SymmetryOperation.
As detailed in the class description, the method checks whether there is already a prototype SymmetryElement for the provided SymmetryOperation. If not, it tries to find an appropriate generator and uses that to create the prototype. Then it returns a clone of the prototype.
operation | :: SymmetryOperation for which to generate the element. |
Definition at line 306 of file SymmetryElementFactory.cpp.
References createFromPrototype(), getGenerator(), Mantid::Geometry::SymmetryOperation::identifier(), and insertPrototype().
Referenced by export_SymmetryElementFactory().
|
protected |
Returns a generator that can process the supplied symmetry operation or an invalid pointer if no appropriate generator is found.
Definition at line 352 of file SymmetryElementFactory.cpp.
References m_generators.
Referenced by createSymElement().
|
protected |
Inserts the provided prototype into the factory.
Definition at line 359 of file SymmetryElementFactory.cpp.
References m_prototypes.
Referenced by createSymElement().
|
protected |
Checks whether a generator with that class name is already subscribed.
Definition at line 327 of file SymmetryElementFactory.cpp.
References m_generatorNames.
|
protected |
Subscribes a generator and stores its class name for later checks.
Definition at line 332 of file SymmetryElementFactory.cpp.
References m_generatorNames, and m_generators.
|
inline |
Subscribes the generator of type T with its class name into the factory, throws std::runtime_error if a class with the same name has already been registered.
Definition at line 197 of file SymmetryElementFactory.h.
|
friend |
Definition at line 217 of file SymmetryElementFactory.h.
|
protected |
Definition at line 216 of file SymmetryElementFactory.h.
Referenced by isSubscribed(), and subscribe().
|
protected |
Definition at line 215 of file SymmetryElementFactory.h.
Referenced by getGenerator(), and subscribe().
|
protected |
Definition at line 217 of file SymmetryElementFactory.h.
Referenced by createFromPrototype(), and insertPrototype().