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

#include <NexusDescriptorLazy.h>

Public Types

enum class  CacheReturnStatus_t {
  NXFOUND , NXCACHED , NXNOT_DATASET , NXDATASET_NOT_FOUND ,
  NXWRONG_TYPE , NXERROR , NXUNSET
}
 
using CacheValue_t = std::variant< float, double, int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t, uint64_t, std::string, CacheReturnStatus_t >
 

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.
 
template<typename T >
std::pair< T, NexusDescriptorLazy::CacheReturnStatus_t > getDataValue (const std::string &datasetAddress) const
 Gets the value of an entry in the Nexus 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.
 
NexusDescriptorLazy & operator= (NexusDescriptorLazy &&nd)=delete
 
NexusDescriptorLazy & operator= (NexusDescriptorLazy const &nd)=delete
 
 ~NexusDescriptorLazy ()=default
 Using RAII components, no need to deallocate explicitly.
 

Private Member Functions

const CacheValue_t _getDataValue (const std::string &datasetAddress) const
 
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<&H5Fclose > m_fileID
 HDF5 File Handle.
 
std::string const m_filename
 Nexus HDF5 file name.
 
std::pair< std::string, std::string > m_firstEntryNameType
 
std::map< std::string, CacheValue_t > m_readEntries
 the map of all read entry values that have been checked
 
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 26 of file NexusDescriptorLazy.h.

Member Typedef Documentation

◆ CacheValue_t

using Mantid::Nexus::NexusDescriptorLazy::CacheValue_t = std::variant<float, double, int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t, uint64_t, std::string, CacheReturnStatus_t>

Definition at line 39 of file NexusDescriptorLazy.h.

Member Enumeration Documentation

◆ CacheReturnStatus_t

Enumerator
NXFOUND 
NXCACHED 
NXNOT_DATASET 
NXDATASET_NOT_FOUND 
NXWRONG_TYPE 
NXERROR 
NXUNSET 

Definition at line 29 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

◆ _getDataValue()

const NexusDescriptorLazy::CacheValue_t Mantid::Nexus::NexusDescriptorLazy::_getDataValue ( const std::string &  datasetAddress) const
private

Definition at line 269 of file NexusDescriptorLazy.cpp.

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

Referenced by getDataValue().

◆ 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 73 of file NexusDescriptorLazy.h.

Referenced by Mantid::DataHandling::LoadEMUHdf::confidence(), Mantid::DataHandling::NXcanSAS::LoadNXcanSAS::confidence(), Mantid::DataHandling::LoadPLN::confidence(), and Mantid::DataHandling::LoadPLNnxs::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 66 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 76 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 90 of file NexusDescriptorLazy.h.

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

◆ getDataValue()

template<typename T >
template MANTID_NEXUS_DLL std::pair< float, NexusDescriptorLazy::CacheReturnStatus_t > Mantid::Nexus::NexusDescriptorLazy::getDataValue< float > ( const std::string &  datasetAddress) const

Gets the value of an entry in the Nexus file.

Only single values are returned, either numeric or strings.

Parameters
datasetAddressfull address for an entry name
Returns
pair<value, status> where value is valid only if the return status is FOUND or CACHED

Definition at line 304 of file NexusDescriptorLazy.cpp.

References _getDataValue(), m_readEntries, NXCACHED, NXFOUND, NXWRONG_TYPE, and value.

◆ 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::LoadMuonNexusV2::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

Definition at line 177 of file NexusDescriptorLazy.cpp.

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

Referenced by initAllEntries(), and loadGroups().

◆ 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 165 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 171 of file NexusDescriptorLazy.h.

Referenced by isEntry().

◆ m_extension

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

Extension.

Definition at line 149 of file NexusDescriptorLazy.h.

◆ m_fileID

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

HDF5 File Handle.

Definition at line 151 of file NexusDescriptorLazy.h.

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

◆ m_filename

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

Nexus HDF5 file name.

Definition at line 147 of file NexusDescriptorLazy.h.

Referenced by initAllEntries().

◆ m_firstEntryNameType

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

Definition at line 156 of file NexusDescriptorLazy.h.

Referenced by initAllEntries().

◆ m_readEntries

std::map<std::string, CacheValue_t> Mantid::Nexus::NexusDescriptorLazy::m_readEntries
mutableprivate

the map of all read entry values that have been checked

Definition at line 174 of file NexusDescriptorLazy.h.

Referenced by getDataValue().

◆ 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 168 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 154 of file NexusDescriptorLazy.h.

Referenced by hasRootAttr().


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