Mantid
Loading...
Searching...
No Matches
SampleEnvironmentSpecParser.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2016 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
9#include "MantidDataHandling/DllConfig.h"
13#include <iosfwd>
14#include <unordered_map>
15
16namespace Poco {
17namespace XML {
18class Element;
19}
20} // namespace Poco
21
22namespace Mantid {
23namespace DataHandling {
24
29class MANTID_DATAHANDLING_DLL SampleEnvironmentSpecParser {
30public:
31 static constexpr const char *ROOT_TAG = "environmentspec";
32
33public:
34 SampleEnvironmentSpec_uptr parse(const std::string &name, const std::string &filename, std::istream &istr);
35 SampleEnvironmentSpec_uptr parse(const std::string &name, Poco::XML::Element *element);
36
37private:
38 // Convenience definitions
39 using MaterialsIndex = std::unordered_map<std::string, Kernel::Material>;
40
41 // Methods
42 void validateRootElement(Poco::XML::Element *element) const;
43 void parseMaterials(Poco::XML::Element *element);
44 void parseAndAddComponents(SampleEnvironmentSpec *spec, Poco::XML::Element *element) const;
45 void loadFullSpecification(SampleEnvironmentSpec *spec, Poco::XML::Element *element);
46 void parseAndAddContainers(SampleEnvironmentSpec *spec, Poco::XML::Element *element) const;
47 Geometry::Container_const_sptr parseContainer(Poco::XML::Element *element) const;
48 std::shared_ptr<Geometry::IObject> parseComponent(Poco::XML::Element *element) const;
49 std::shared_ptr<Geometry::MeshObject> loadMeshFromSTL(Poco::XML::Element *stlFileElement) const;
50 void LoadOptionalDoubleFromXML(Poco::XML::Element *componentElement, const std::string &elementName,
51 double &targetVariable) const;
52 std::vector<double> parseTranslationVector(const std::string &translationVectorStr) const;
53 std::string findFile(const std::string &filename) const;
54 // Members
56 std::string m_filepath;
57};
58
59} // namespace DataHandling
60} // namespace Mantid
Read an XML definition of a SampleEnvironmentSpec and produce a new SampleEnvironmentSpec object.
std::unordered_map< std::string, Kernel::Material > MaterialsIndex
Defines the properties of a named SampleEnvironment setup.
std::unique_ptr< SampleEnvironmentSpec > SampleEnvironmentSpec_uptr
unique_ptr to a SampleEnvironmentSpec
std::shared_ptr< const Container > Container_const_sptr
Typdef for a shared pointer to a const object.
Definition: Container.h:107
Helper class which provides the Collimation Length for SANS instruments.
Definition: Algorithm.h:30