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

#include <NexusDescriptor.h>

Public Member Functions

void addEntry (const std::string &entryName, const std::string &groupClass)
 Add an entry to the mapping for the file.
 
void addRootAttr (const std::string &name)
 
std::map< std::string, std::string > allAddressesAtLevel (const std::string &level) const
 
std::vector< std::string > allAddressesOfType (const std::string &type) const
 
bool classTypeExists (const std::string &classType) const
 Query if a given type exists somewhere in the file.
 
std::string classTypeForName (std::string const &name) const
 
const std::string & extension () const
 Access the file extension.
 
const std::string & filename () const noexcept
 Returns a copy of the current file name.
 
const std::pair< std::string, std::string > & firstEntryNameType () const
 Returns the name & type of the first entry in the file.
 
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.
 
bool hasRootAttr (const std::string &name) const
 Query if the given attribute exists on the root node.
 
bool isEntry (const std::string &entryName) const noexcept
 Checks if a full-address entry exists in a Nexus dataset.
 
bool isEntry (const std::string &entryName, const std::string &groupClass) const noexcept
 Checks if a full-address entry exists for a particular groupClass in a Nexus dataset.
 
 NexusDescriptor ()=delete
 
 NexusDescriptor (NexusDescriptor const &nd)=default
 
 NexusDescriptor (std::string const &filename)
 Unique constructor.
 
 NexusDescriptor (std::string const &filename, NXaccess access)
 
NexusDescriptoroperator= (NexusDescriptor const &nd)=default
 
 ~NexusDescriptor ()=default
 Using RAII components, no need to deallocate explicitly.
 

Private Member Functions

std::map< std::string, std::set< std::string > > initAllEntries ()
 Sets m_allEntries, called in HDF5 constructor.
 

Private Attributes

std::map< std::string, std::set< std::string > > m_allEntries
 All entries metadata.
 
std::string m_extension
 Extension.
 
std::string m_filename
 Nexus HDF5 file name.
 
std::pair< std::string, std::string > m_firstEntryNameType
 First entry name/type.
 
std::unordered_set< std::string > m_rootAttrs
 Root attributes.
 

Detailed Description

Definition at line 23 of file NexusDescriptor.h.

Constructor & Destructor Documentation

◆ NexusDescriptor() [1/4]

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

Unique constructor.

Parameters
filenameinput HDF5 Nexus file name

Definition at line 73 of file NexusDescriptor.cpp.

◆ NexusDescriptor() [2/4]

Mantid::Nexus::NexusDescriptor::NexusDescriptor ( std::string const &  filename,
NXaccess  access 
)

Definition at line 77 of file NexusDescriptor.cpp.

References CREATE5, initAllEntries(), m_allEntries, and m_filename.

◆ NexusDescriptor() [3/4]

Mantid::Nexus::NexusDescriptor::NexusDescriptor ( )
delete

◆ NexusDescriptor() [4/4]

Mantid::Nexus::NexusDescriptor::NexusDescriptor ( NexusDescriptor const &  nd)
default

◆ ~NexusDescriptor()

Mantid::Nexus::NexusDescriptor::~NexusDescriptor ( )
default

Using RAII components, no need to deallocate explicitly.

Member Function Documentation

◆ addEntry()

void Mantid::Nexus::NexusDescriptor::addEntry ( const std::string &  entryName,
const std::string &  groupClass 
)

Add an entry to the mapping for the file.

Since there is no handle to the file after creation, it is up to the caller to only add entries that exist. This should not be used for files that are read-only.

Parameters
entryNamefull address to the node in the file
groupClassNXclass (for group) or SDS (for dataset)

Definition at line 99 of file NexusDescriptor.cpp.

References isEntry(), m_allEntries, and m_filename.

◆ addRootAttr()

void Mantid::Nexus::NexusDescriptor::addRootAttr ( const std::string &  name)

Definition at line 97 of file NexusDescriptor.cpp.

References m_rootAttrs, and name.

◆ allAddressesAtLevel()

std::map< std::string, std::string > Mantid::Nexus::NexusDescriptor::allAddressesAtLevel ( const std::string &  level) const
Parameters
levelA string specifying the parent address
Returns
address A map of strings giving names within parent (mapped to class type) e.g. group1 : NXentry, group2 : NXentry, data : NXdata

Definition at line 185 of file NexusDescriptor.cpp.

References m_allEntries.

◆ allAddressesOfType()

std::vector< std::string > Mantid::Nexus::NexusDescriptor::allAddressesOfType ( const std::string &  type) const
Parameters
typeA string specifying the required type
Returns
pataddressh A vector of strings giving address using UNIX-style address separators (/), e.g. /raw_data_1, /entry/bank1

Definition at line 176 of file NexusDescriptor.cpp.

References m_allEntries.

◆ classTypeExists()

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

Query if a given type exists somewhere in the file.

Definition at line 204 of file NexusDescriptor.cpp.

References m_allEntries.

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

◆ classTypeForName()

std::string Mantid::Nexus::NexusDescriptor::classTypeForName ( std::string const &  name) const
Parameters
nameA address within a Nexus file to an entry
Returns
The class type associated with that address

Definition at line 206 of file NexusDescriptor.cpp.

References m_allEntries, and m_filename.

◆ extension()

const std::string & Mantid::Nexus::NexusDescriptor::extension ( ) const
inline

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 56 of file NexusDescriptor.h.

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

◆ filename()

const std::string & Mantid::Nexus::NexusDescriptor::filename ( ) const
noexcept

◆ firstEntryNameType()

const std::pair< std::string, std::string > & Mantid::Nexus::NexusDescriptor::firstEntryNameType ( ) const
inline

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

Definition at line 59 of file NexusDescriptor.h.

◆ getAllEntries()

const std::map< std::string, std::set< std::string > > & Mantid::Nexus::NexusDescriptor::getAllEntries ( ) const
noexcept

◆ hasRootAttr()

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

Query if the given attribute exists on the root node.

Definition at line 91 of file NexusDescriptor.cpp.

References m_rootAttrs, and name.

◆ initAllEntries()

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

Sets m_allEntries, called in HDF5 constructor.

m_filename must be set

Definition at line 123 of file NexusDescriptor.cpp.

References Mantid::Nexus::H5Util::defaultFileAcc(), m_filename, m_firstEntryNameType, and m_rootAttrs.

Referenced by NexusDescriptor().

◆ isEntry() [1/2]

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

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 171 of file NexusDescriptor.cpp.

◆ isEntry() [2/2]

bool Mantid::Nexus::NexusDescriptor::isEntry ( const std::string &  entryName,
const std::string &  groupClass 
) const
noexcept

◆ operator=()

NexusDescriptor & Mantid::Nexus::NexusDescriptor::operator= ( NexusDescriptor const &  nd)
default

Member Data Documentation

◆ m_allEntries

std::map<std::string, std::set<std::string> > Mantid::Nexus::NexusDescriptor::m_allEntries
private

All entries metadata.

  key: group_class (e.g. NXentry, NXlog)
  value: set with absolute entry names for the group_class key
         (e.g. /entry/log)

Definition at line 150 of file NexusDescriptor.h.

Referenced by addEntry(), allAddressesAtLevel(), allAddressesOfType(), classTypeExists(), classTypeForName(), getAllEntries(), and NexusDescriptor().

◆ m_extension

std::string Mantid::Nexus::NexusDescriptor::m_extension
private

Extension.

Definition at line 136 of file NexusDescriptor.h.

◆ m_filename

std::string Mantid::Nexus::NexusDescriptor::m_filename
private

Nexus HDF5 file name.

Definition at line 134 of file NexusDescriptor.h.

Referenced by addEntry(), classTypeForName(), filename(), initAllEntries(), and NexusDescriptor().

◆ m_firstEntryNameType

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

First entry name/type.

Definition at line 138 of file NexusDescriptor.h.

Referenced by initAllEntries().

◆ m_rootAttrs

std::unordered_set<std::string> Mantid::Nexus::NexusDescriptor::m_rootAttrs
private

Root attributes.

Definition at line 140 of file NexusDescriptor.h.

Referenced by addRootAttr(), hasRootAttr(), and initAllEntries().


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