Mantid
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Mantid::Nexus::NexusDescriptorLazy Class Reference

#include <NexusDescriptorLazy.h>

Public Member Functions

bool classTypeExists (std::string const &classType) const
 Query if a given type exists somewhere in the file.
 
bool classTypeExistsChild (const std::string &parentPath, const std::string &classType) const
 Query if a given type exists as a decendant of the supplied parentPath.
 
std::string const & extension () const noexcept
 Access the file extension.
 
std::string const & filename () const noexcept
 Returns a constant reference to the current file name.
 
std::pair< std::string, std::string > const & firstEntryNameType () const noexcept
 Returns the name & type of the first entry in the file.
 
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::string getStrData (std::string const &address)
 Get string data from a dataset at address.
 
bool hasRootAttr (std::string const &name) const
 Query if the given attribute exists on the root node.
 
bool isEntry (std::string const &entryName) const
 Checks if a full-address entry exists in a Nexus dataset.
 
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 ()=delete
 
 NexusDescriptorLazy (NexusDescriptorLazy &&nd)=delete
 
 NexusDescriptorLazy (NexusDescriptorLazy const &nd)=delete
 
 NexusDescriptorLazy (std::string const &filename)
 Unique constructor.
 
NexusDescriptorLazyoperator= (NexusDescriptorLazy &&nd)=delete
 
NexusDescriptorLazyoperator= (NexusDescriptorLazy const &nd)=delete
 
 ~NexusDescriptorLazy ()=default
 Using RAII components, no need to deallocate explicitly.
 

Private Member Functions

std::map< std::string, std::string > initAllEntries ()
 Sets m_allEntries, called in HDF5 constructor.
 
void loadGroups (std::map< std::string, std::string > &allEntries, std::string const &address, unsigned int depth, const unsigned int maxDepth)
 

Private Attributes

std::map< std::string, std::string > m_allEntries
 All entries metadata.
 
std::unordered_set< std::string > m_allMisses
 the set of non-existent entries that have been checked
 
std::string const m_extension
 Extension.
 
UniqueID<&H5Fclosem_fileID
 HDF5 File Handle.
 
std::string const m_filename
 Nexus HDF5 file name.
 
std::pair< std::string, std::string > m_firstEntryNameType
 
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.
 

Detailed Description

Definition at line 21 of file NexusDescriptorLazy.h.

Constructor & Destructor Documentation

◆ NexusDescriptorLazy() [1/4]

Mantid::Nexus::NexusDescriptorLazy::NexusDescriptorLazy ( std::string const &  filename)

Unique constructor.

Parameters
filenameinput HDF5 Nexus file name

Definition at line 63 of file NexusDescriptorLazy.cpp.

◆ NexusDescriptorLazy() [2/4]

Mantid::Nexus::NexusDescriptorLazy::NexusDescriptorLazy ( )
delete

◆ NexusDescriptorLazy() [3/4]

Mantid::Nexus::NexusDescriptorLazy::NexusDescriptorLazy ( NexusDescriptorLazy const &  nd)
delete

◆ NexusDescriptorLazy() [4/4]

Mantid::Nexus::NexusDescriptorLazy::NexusDescriptorLazy ( NexusDescriptorLazy &&  nd)
delete

◆ ~NexusDescriptorLazy()

Mantid::Nexus::NexusDescriptorLazy::~NexusDescriptorLazy ( )
default

Using RAII components, no need to deallocate explicitly.

Member Function Documentation

◆ classTypeExists()

bool Mantid::Nexus::NexusDescriptorLazy::classTypeExists ( std::string const &  classType) const

Query if a given type exists somewhere in the file.

Check if a class type exists in the file.

Parameters
classTypethe NX_class type to check for
Returns
true if the class type exists anywhere in the file

Definition at line 112 of file NexusDescriptorLazy.cpp.

References m_allEntries, and m_readNexusMutex.

Referenced by Mantid::DataHandling::LoadEventNexus::confidence(), and Mantid::MDAlgorithms::LoadMD::confidence().

◆ classTypeExistsChild()

bool Mantid::Nexus::NexusDescriptorLazy::classTypeExistsChild ( const std::string &  parentPath,
const std::string &  classType 
) const

Query if a given type exists as a decendant of the supplied parentPath.

It is expected to be used only to check for direct children.

Definition at line 119 of file NexusDescriptorLazy.cpp.

References isEntry(), m_allEntries, m_readNexusMutex, and name.

Referenced by Mantid::DataHandling::LoadTOFRawNexus::confidence().

◆ extension()

std::string const & Mantid::Nexus::NexusDescriptorLazy::extension ( ) const
inlinenoexcept

Access the file extension.

Defined as the string after and including the last period character

Returns
A reference to a const string containing the file extension

Definition at line 55 of file NexusDescriptorLazy.h.

Referenced by Mantid::DataHandling::LoadEMUHdf::confidence(), Mantid::DataHandling::NXcanSAS::LoadNXcanSAS::confidence(), and Mantid::DataHandling::LoadPLN::confidence().

◆ filename()

std::string const & Mantid::Nexus::NexusDescriptorLazy::filename ( ) const
inlinenoexcept

Returns a constant reference to the current file name.

Returns
A reference to a const string containing the file name

Definition at line 48 of file NexusDescriptorLazy.h.

◆ firstEntryNameType()

std::pair< std::string, std::string > const & Mantid::Nexus::NexusDescriptorLazy::firstEntryNameType ( ) const
inlinenoexcept

Returns the name & type of the first entry in the file.

Definition at line 58 of file NexusDescriptorLazy.h.

Referenced by Mantid::DataHandling::LoadMcStasNexus::confidence(), and Mantid::DataHandling::LoadEmptyInstrument::runLoadIDFFromNexus().

◆ getAllEntries()

std::map< std::string, std::string > const & Mantid::Nexus::NexusDescriptorLazy::getAllEntries ( ) const
inlinenoexcept

Returns a const reference of the internal map holding all entries in the Nexus HDF5 file.

Returns
map holding all entries by group class
  key: group address (absolute entry name, e.g., /entry/log)
  value: group class (e.g., NXentry, NXlog)

Definition at line 72 of file NexusDescriptorLazy.h.

Referenced by Mantid::DataHandling::NXcanSAS::LoadNXcanSAS::confidence(), and Mantid::DataHandling::LoadNXSPE::confidence().

◆ getStrData()

std::string Mantid::Nexus::NexusDescriptorLazy::getStrData ( std::string const &  address)

Get string data from a dataset at address.

Parameters
addressFull HDF5 address of the dataset
Returns
string data at this address, if it is string dataset, else empty

Definition at line 160 of file NexusDescriptorLazy.cpp.

References isEntry(), m_fileID, and Mantid::Nexus::SCIENTIFIC_DATA_SET().

Referenced by Mantid::DataHandling::LoadMcStas::confidence(), Mantid::DataHandling::NXcanSAS::LoadNXcanSAS::confidence(), and Mantid::DataHandling::LoadNXSPE::confidence().

◆ hasRootAttr()

bool Mantid::Nexus::NexusDescriptorLazy::hasRootAttr ( std::string const &  name) const

Query if the given attribute exists on the root node.

Definition at line 138 of file NexusDescriptorLazy.cpp.

References m_fileID, m_readNexusMutex, m_rootAttrs, and name.

◆ initAllEntries()

std::map< std::string, std::string > Mantid::Nexus::NexusDescriptorLazy::initAllEntries ( )
private

◆ isEntry() [1/2]

bool Mantid::Nexus::NexusDescriptorLazy::isEntry ( std::string const &  entryName) const

Checks if a full-address entry exists in a Nexus dataset.

Parameters
entryNamefull address for an entry name /entry/NXlogs
Returns
true: entryName exists, otherwise false

Definition at line 68 of file NexusDescriptorLazy.cpp.

References m_allEntries, m_allMisses, m_fileID, m_readNexusMutex, and Mantid::Nexus::SCIENTIFIC_DATA_SET().

◆ isEntry() [2/2]

bool Mantid::Nexus::NexusDescriptorLazy::isEntry ( std::string const &  entryName,
std::string const &  groupClass 
) const
inline

◆ loadGroups()

void Mantid::Nexus::NexusDescriptorLazy::loadGroups ( std::map< std::string, std::string > &  allEntries,
std::string const &  address,
unsigned int  depth,
const unsigned int  maxDepth 
)
private

◆ operator=() [1/2]

NexusDescriptorLazy & Mantid::Nexus::NexusDescriptorLazy::operator= ( NexusDescriptorLazy &&  nd)
delete

◆ operator=() [2/2]

NexusDescriptorLazy & Mantid::Nexus::NexusDescriptorLazy::operator= ( NexusDescriptorLazy const &  nd)
delete

Member Data Documentation

◆ m_allEntries

std::map<std::string, std::string> Mantid::Nexus::NexusDescriptorLazy::m_allEntries
mutableprivate

All entries metadata.

The map is mutable because additional values can be added lazily.

  key: group address
  value: group class (e.g. NXentry, NXlog)

Definition at line 136 of file NexusDescriptorLazy.h.

Referenced by classTypeExists(), classTypeExistsChild(), and isEntry().

◆ m_allMisses

std::unordered_set<std::string> Mantid::Nexus::NexusDescriptorLazy::m_allMisses
mutableprivate

the set of non-existent entries that have been checked

Definition at line 142 of file NexusDescriptorLazy.h.

Referenced by isEntry().

◆ m_extension

std::string const Mantid::Nexus::NexusDescriptorLazy::m_extension
private

Extension.

Definition at line 120 of file NexusDescriptorLazy.h.

◆ m_fileID

UniqueID<&H5Fclose> Mantid::Nexus::NexusDescriptorLazy::m_fileID
private

HDF5 File Handle.

Definition at line 122 of file NexusDescriptorLazy.h.

Referenced by getStrData(), hasRootAttr(), initAllEntries(), isEntry(), and loadGroups().

◆ m_filename

std::string const Mantid::Nexus::NexusDescriptorLazy::m_filename
private

Nexus HDF5 file name.

Definition at line 118 of file NexusDescriptorLazy.h.

Referenced by initAllEntries().

◆ m_firstEntryNameType

std::pair<std::string, std::string> Mantid::Nexus::NexusDescriptorLazy::m_firstEntryNameType
private

Definition at line 127 of file NexusDescriptorLazy.h.

Referenced by initAllEntries().

◆ m_readNexusMutex

std::shared_mutex Mantid::Nexus::NexusDescriptorLazy::m_readNexusMutex
mutableprivate

mutex to protect reading from file after initialization in const methods

Definition at line 139 of file NexusDescriptorLazy.h.

Referenced by classTypeExists(), classTypeExistsChild(), hasRootAttr(), and isEntry().

◆ m_rootAttrs

std::unordered_set<std::string> Mantid::Nexus::NexusDescriptorLazy::m_rootAttrs
mutableprivate

Root attributes cache.

This is mutable because it is modified in a const method.

Definition at line 125 of file NexusDescriptorLazy.h.

Referenced by hasRootAttr().


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