Mantid
Loading...
Searching...
No Matches
NexusDescriptorLazy.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"
11
12#include <map>
13#include <shared_mutex>
14#include <string>
15#include <unordered_set>
16#include <vector>
17
18namespace Mantid {
19namespace Nexus {
20
21class MANTID_NEXUS_DLL NexusDescriptorLazy {
22
23public:
28 NexusDescriptorLazy(std::string const &filename);
29
31
32 // there is no reason to copy this object
35 // there is no reason to move this object
38
43
48 inline std::string const &filename() const noexcept { return m_filename; }
49
55 inline std::string const &extension() const noexcept { return m_extension; }
56
58 std::pair<std::string, std::string> const &firstEntryNameType() const noexcept { return m_firstEntryNameType; };
59
61 bool hasRootAttr(std::string const &name) const;
62
72 std::map<std::string, std::string> const &getAllEntries() const noexcept { return m_allEntries; }
73
81 bool isEntry(std::string const &entryName, std::string const &groupClass) const {
82 if (isEntry(entryName)) {
83 return m_allEntries.at(entryName) == groupClass;
84 } else {
85 return false;
86 }
87 }
88
94 bool isEntry(std::string const &entryName) const;
95
97 bool classTypeExists(std::string const &classType) const;
98
101 bool classTypeExistsChild(const std::string &parentPath, const std::string &classType) const;
102
106 std::string getStrData(std::string const &address);
107
108private:
113 std::map<std::string, std::string> initAllEntries();
114 void loadGroups(std::map<std::string, std::string> &allEntries, std::string const &address, unsigned int depth,
115 const unsigned int maxDepth);
116
118 std::string const m_filename;
120 std::string const m_extension;
123
125 mutable std::unordered_set<std::string> m_rootAttrs;
126
127 std::pair<std::string, std::string> m_firstEntryNameType;
128
136 mutable std::map<std::string, std::string> m_allEntries;
137
139 mutable std::shared_mutex m_readNexusMutex;
140
142 mutable std::unordered_set<std::string> m_allMisses;
143};
144
145} // namespace Nexus
146} // namespace Mantid
std::string name
Definition Run.cpp:60
std::string const m_filename
Nexus HDF5 file name.
NexusDescriptorLazy & operator=(NexusDescriptorLazy const &nd)=delete
std::string const & filename() const noexcept
Returns a constant reference to the current file name.
~NexusDescriptorLazy()=default
Using RAII components, no need to deallocate explicitly.
std::unordered_set< std::string > m_allMisses
the set of non-existent entries that have been checked
std::pair< std::string, std::string > m_firstEntryNameType
std::string const & extension() const noexcept
Access the file extension.
std::map< std::string, std::string > const & getAllEntries() const noexcept
Returns a const reference of the internal map holding all entries in the Nexus HDF5 file.
std::shared_mutex m_readNexusMutex
mutex to protect reading from file after initialization in const methods
std::unordered_set< std::string > m_rootAttrs
Root attributes cache.
bool isEntry(std::string const &entryName, std::string const &groupClass) const
Checks if a full-address entry exists for a particular groupClass in a Nexus dataset.
NexusDescriptorLazy(NexusDescriptorLazy &&nd)=delete
std::string const m_extension
Extension.
std::pair< std::string, std::string > const & firstEntryNameType() const noexcept
Returns the name & type of the first entry in the file.
NexusDescriptorLazy(NexusDescriptorLazy const &nd)=delete
std::map< std::string, std::string > m_allEntries
All entries metadata.
UniqueID<&H5Fclose > m_fileID
HDF5 File Handle.
NexusDescriptorLazy & operator=(NexusDescriptorLazy &&nd)=delete
A wrapper class for managing HDF5 object handles (hid_t).
Definition UniqueID.h:92
Helper class which provides the Collimation Length for SANS instruments.