Mantid
Loading...
Searching...
No Matches
PointGroupFactory.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2014 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
11#include "MantidGeometry/DllConfig.h"
14
15#include <boost/regex.hpp>
16
17namespace Mantid {
18namespace Geometry {
19
20class MANTID_GEOMETRY_DLL PointGroupGenerator {
21public:
22 PointGroupGenerator(std::string hmSymbol, std::string generatorInformation, std::string description);
23
24 inline std::string getHMSymbol() const { return m_hmSymbol; }
25 inline std::string getGeneratorString() const { return m_generatorString; }
26 inline std::string getDescription() const { return m_description; }
27
28 PointGroup_sptr getPrototype();
29
30private:
31 inline bool hasValidPrototype() const { return static_cast<bool>(m_prototype); }
32
33 PointGroup_sptr generatePrototype();
34
35 std::string m_hmSymbol;
36 std::string m_generatorString;
37 std::string m_description;
38
40};
41
42using PointGroupGenerator_sptr = std::shared_ptr<PointGroupGenerator>;
43
60class MANTID_GEOMETRY_DLL PointGroupFactoryImpl {
61public:
62 PointGroup_sptr createPointGroup(const std::string &hmSymbol);
63 PointGroup_sptr createPointGroupFromSpaceGroup(const SpaceGroup_const_sptr &spaceGroup);
64 PointGroup_sptr createPointGroupFromSpaceGroup(const SpaceGroup &spaceGroup);
65
66 bool isSubscribed(const std::string &hmSymbol) const;
67
68 std::vector<std::string> getAllPointGroupSymbols() const;
69 std::vector<std::string> getPointGroupSymbols(const PointGroup::CrystalSystem &crystalSystem);
70
71 void subscribePointGroup(const std::string &hmSymbol, const std::string &generatorString,
72 const std::string &description);
73
75 void unsubscribePointGroup(const std::string &hmSymbol) { m_generatorMap.erase(hmSymbol); }
76
77private:
79
81
82 std::string pointGroupSymbolFromSpaceGroupSymbol(const std::string &spaceGroupSymbol) const;
83
84 PointGroup_sptr getPrototype(const std::string &hmSymbol);
85 void subscribe(const PointGroupGenerator_sptr &generator);
86 PointGroup_sptr constructFromPrototype(const PointGroup_sptr &prototype) const;
87
88 std::map<std::string, PointGroupGenerator_sptr> m_generatorMap;
89 std::map<std::string, PointGroup::CrystalSystem> m_crystalSystemMap;
90
91 boost::regex m_screwAxisRegex;
92 boost::regex m_glidePlaneRegex;
93 boost::regex m_centeringRegex;
94 boost::regex m_originChoiceRegex;
95};
96
98
99} // namespace Geometry
100} // namespace Mantid
101
102namespace Mantid {
103namespace Kernel {
104EXTERN_MANTID_GEOMETRY template class MANTID_GEOMETRY_DLL
106}
107} // namespace Mantid
108
109#define PGF_CONCAT_IMPL(x, y) x##y
110#define PGF_CONCAT(x, y) PGF_CONCAT_IMPL(x, y)
111
112#define DECLARE_POINTGROUP(hmSymbol, generators, description) \
113 namespace { \
114 Mantid::Kernel::RegistrationHelper PGF_CONCAT(register_pointgroup, __COUNTER__)( \
115 ((Mantid::Geometry::PointGroupFactory::Instance().subscribePointGroup(hmSymbol, generators, description)), 0)); \
116 }
std::map< std::string, PointGroup::CrystalSystem > m_crystalSystemMap
std::map< std::string, PointGroupGenerator_sptr > m_generatorMap
A class for representing space groups, inheriting from Group.
Definition: SpaceGroup.h:46
Manage the lifetime of a class intended to be a singleton.
std::shared_ptr< PointGroupGenerator > PointGroupGenerator_sptr
std::shared_ptr< PointGroup > PointGroup_sptr
Shared pointer to a PointGroup.
Definition: PointGroup.h:67
std::shared_ptr< const SpaceGroup > SpaceGroup_const_sptr
Definition: SpaceGroup.h:82
Helper class which provides the Collimation Length for SANS instruments.
Policy class controlling creation of the singleton Implementation classes should mark their default c...