Mantid
Loading...
Searching...
No Matches
NexusDescriptor.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 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 "MantidNexus/DllConfig.h"
10
11#include <map>
12#include <set>
13#include <string>
14#include <unordered_set>
15#include <vector>
16
17// from NexusFile_fwd.h
18enum class NXaccess : unsigned int;
19
20namespace Mantid {
21namespace Nexus {
22
23class MANTID_NEXUS_DLL NexusDescriptor {
24
25public:
30 NexusDescriptor(std::string const &filename);
31
32 NexusDescriptor(std::string const &filename, NXaccess access);
33
34 NexusDescriptor() = delete;
35
37
38 NexusDescriptor(NexusDescriptor const &nd) = default;
39
43 ~NexusDescriptor() = default;
44
49 const std::string &filename() const noexcept;
50
56 inline const std::string &extension() const { return m_extension; }
57
59 const std::pair<std::string, std::string> &firstEntryNameType() const { return m_firstEntryNameType; };
60
62 bool hasRootAttr(const std::string &name) const;
63
74 const std::map<std::string, std::set<std::string>> &getAllEntries() const noexcept { return m_allEntries; }
75
83 bool isEntry(const std::string &entryName, const std::string &groupClass) const noexcept;
84
90 bool isEntry(const std::string &entryName) const noexcept;
91
97 std::set<std::string> allAddressesOfType(const std::string &type) const {
98 auto it = m_allEntries.find(type);
99 if (it != m_allEntries.cend()) {
100 return it->second;
101 } else {
102 return std::set<std::string>();
103 }
104 }
105
111 std::map<std::string, std::string> allAddressesAtLevel(const std::string &level) const;
112
114 bool classTypeExists(const std::string &classType) const;
115
120 std::string classTypeForName(std::string const &name) const;
121
129 void addEntry(const std::string &entryName, const std::string &groupClass);
130
131 void addRootAttr(const std::string &name);
132
133private:
138 std::map<std::string, std::set<std::string>> initAllEntries();
139
141 std::string m_filename;
143 std::string m_extension;
145 std::pair<std::string, std::string> m_firstEntryNameType;
147 std::unordered_set<std::string> m_rootAttrs;
148
157 std::map<std::string, std::set<std::string>> m_allEntries;
158};
159
160} // namespace Nexus
161} // namespace Mantid
std::string name
Definition Run.cpp:60
NXaccess
Nexus file access codes.
std::set< std::string > allAddressesOfType(const std::string &type) const
const std::map< std::string, std::set< std::string > > & getAllEntries() const noexcept
Returns a const reference of the internal map holding all entries in the Nexus HDF5 file.
NexusDescriptor(NexusDescriptor const &nd)=default
std::pair< std::string, std::string > m_firstEntryNameType
First entry name/type.
const std::pair< std::string, std::string > & firstEntryNameType() const
Returns the name & type of the first entry in the file.
~NexusDescriptor()=default
Using RAII components, no need to deallocate explicitly.
std::string m_filename
Nexus HDF5 file name.
std::string m_extension
Extension.
NexusDescriptor & operator=(NexusDescriptor const &nd)=default
std::unordered_set< std::string > m_rootAttrs
Root attributes.
std::map< std::string, std::set< std::string > > m_allEntries
All entries metadata.
Helper class which provides the Collimation Length for SANS instruments.
STL namespace.