Mantid
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Mantid::Geometry::SymmetryElementFactoryImpl Class Reference

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_sptrm_generators
 
std::map< std::string, SymmetryElement_sptrm_prototypes
 

Friends

struct Mantid::Kernel::CreateUsingNew< SymmetryElementFactoryImpl >
 

Detailed Description

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:

// Mirror plane perpendicular to z-axis
SymmetryOperation mirrorZ("x,y,-z");
SymmetryElementFactor::Instance().createSymElement(mirrorZ);
// Prints "m"
std::cout << element->hmSymbol() << '\n';
std::dynamic_pointer_cast<SymmetryElementMirror>(element);
// Prints [0,0,1]
std::cout << mirrorElement->getAxis() << '\n';
Crystallographic symmetry operations are composed of a rotational component, which is represented by ...
std::shared_ptr< SymmetryElementMirror > SymmetryElementMirror_sptr
std::shared_ptr< SymmetryElement > SymmetryElement_sptr

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.

Author
Michael Wedel, Paul Scherrer Institut - SINQ
Date
25/02/2015

Definition at line 188 of file SymmetryElementFactory.h.

Constructor & Destructor Documentation

◆ ~SymmetryElementFactoryImpl()

virtual Mantid::Geometry::SymmetryElementFactoryImpl::~SymmetryElementFactoryImpl ( )
virtualdefault

Member Function Documentation

◆ createFromPrototype()

SymmetryElement_sptr Mantid::Geometry::SymmetryElementFactoryImpl::createFromPrototype ( const std::string &  identifier) const
protected

Creates a SymmetryElement from an internally stored prototype.

Definition at line 339 of file SymmetryElementFactory.cpp.

References m_prototypes.

Referenced by createSymElement().

◆ 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.

Parameters
operation:: SymmetryOperation for which to generate the element.
Returns
SymmetryElement for the supplied operation.

Definition at line 306 of file SymmetryElementFactory.cpp.

References createFromPrototype(), getGenerator(), Mantid::Geometry::SymmetryOperation::identifier(), and insertPrototype().

Referenced by export_SymmetryElementFactory().

◆ getGenerator()

AbstractSymmetryElementGenerator_sptr Mantid::Geometry::SymmetryElementFactoryImpl::getGenerator ( const SymmetryOperation operation) const
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().

◆ insertPrototype()

void Mantid::Geometry::SymmetryElementFactoryImpl::insertPrototype ( const std::string &  identifier,
const SymmetryElement_sptr prototype 
)
protected

Inserts the provided prototype into the factory.

Definition at line 359 of file SymmetryElementFactory.cpp.

References m_prototypes.

Referenced by createSymElement().

◆ isSubscribed()

bool Mantid::Geometry::SymmetryElementFactoryImpl::isSubscribed ( const std::string &  generatorClassName) const
protected

Checks whether a generator with that class name is already subscribed.

Definition at line 327 of file SymmetryElementFactory.cpp.

References m_generatorNames.

◆ subscribe()

void Mantid::Geometry::SymmetryElementFactoryImpl::subscribe ( const AbstractSymmetryElementGenerator_sptr generator,
const std::string &  generatorClassName 
)
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.

◆ subscribeSymmetryElementGenerator()

template<typename T >
void Mantid::Geometry::SymmetryElementFactoryImpl::subscribeSymmetryElementGenerator ( const std::string &  generatorClassName)
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.

Friends And Related Function Documentation

◆ Mantid::Kernel::CreateUsingNew< SymmetryElementFactoryImpl >

Definition at line 217 of file SymmetryElementFactory.h.

Member Data Documentation

◆ m_generatorNames

std::unordered_set<std::string> Mantid::Geometry::SymmetryElementFactoryImpl::m_generatorNames
protected

Definition at line 216 of file SymmetryElementFactory.h.

Referenced by isSubscribed(), and subscribe().

◆ m_generators

std::vector<AbstractSymmetryElementGenerator_sptr> Mantid::Geometry::SymmetryElementFactoryImpl::m_generators
protected

Definition at line 215 of file SymmetryElementFactory.h.

Referenced by getGenerator(), and subscribe().

◆ m_prototypes

std::map<std::string, SymmetryElement_sptr> Mantid::Geometry::SymmetryElementFactoryImpl::m_prototypes
protected

Definition at line 217 of file SymmetryElementFactory.h.

Referenced by createFromPrototype(), and insertPrototype().


The documentation for this class was generated from the following files: