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

Defines a wrapper around a file whose internal structure can be accessed using the NeXus API. More...

#include <LegacyNexusDescriptor.h>

Public Member Functions

Mantid::LegacyNexus::File & data ()
 Access the open NeXus File object.
 
const std::string & extension () const
 Access the file extension.
 
const std::string & filename () const
 Access the filename.
 
const std::pair< std::string, std::string > & firstEntryNameType () const
 Returns the name & type of the first entry in the file.
 
 LegacyNexusDescriptor ()=delete
 Disable default constructor.
 
 LegacyNexusDescriptor (const LegacyNexusDescriptor &)=delete
 Disable copy operator.
 
 LegacyNexusDescriptor (const std::string &filename)
 Constructor accepting a filename.
 
LegacyNexusDescriptoroperator= (const LegacyNexusDescriptor &)=delete
 Disable assignment operator.
 
bool pathExists (const std::string &path) const
 Query if a path exists.
 
 ~LegacyNexusDescriptor ()
 Destructor.
 

Private Member Functions

void initialize (const std::string &filename)
 Initialize object with filename.
 
void walkFile (Mantid::LegacyNexus::File &file, const std::string &rootPath, const std::string &className, std::map< std::string, std::string > &pmap, int level)
 Walk the tree and cache the structure.
 

Private Attributes

std::string m_extension
 Extension.
 
std::unique_ptr< Mantid::LegacyNexus::File > m_file
 Open NeXus handle.
 
std::string m_filename
 Full filename.
 
std::pair< std::string, std::string > m_firstEntryNameType
 First entry name/type.
 
std::map< std::string, std::string > m_pathsToTypes
 Map of full path strings to types. Can check if path exists quickly.
 
std::unordered_set< std::string > m_rootAttrs
 Root attributes.
 

Detailed Description

Defines a wrapper around a file whose internal structure can be accessed using the NeXus API.

On construction the simple details about the layout of the file are cached for faster querying later.

Definition at line 32 of file LegacyNexusDescriptor.h.

Constructor & Destructor Documentation

◆ LegacyNexusDescriptor() [1/3]

Mantid::Kernel::LegacyNexusDescriptor::LegacyNexusDescriptor ( const std::string &  filename)

Constructor accepting a filename.

Constructs the wrapper.

Parameters
filenameA string pointing to an existing file
Exceptions
std::invalid_argumentif the file is not identified to be hierarchical. This currently involves simply checking for the signature if a HDF file at the start of the file

Definition at line 29 of file LegacyNexusDescriptor.cpp.

References filename(), and initialize().

◆ ~LegacyNexusDescriptor()

Mantid::Kernel::LegacyNexusDescriptor::~LegacyNexusDescriptor ( )
default

Destructor.

◆ LegacyNexusDescriptor() [2/3]

Mantid::Kernel::LegacyNexusDescriptor::LegacyNexusDescriptor ( )
delete

Disable default constructor.

◆ LegacyNexusDescriptor() [3/3]

Mantid::Kernel::LegacyNexusDescriptor::LegacyNexusDescriptor ( const LegacyNexusDescriptor )
delete

Disable copy operator.

Member Function Documentation

◆ data()

Mantid::LegacyNexus::File & Mantid::Kernel::LegacyNexusDescriptor::data ( )
inline

Access the open NeXus File object.

Returns
A reference to the open LegacyNexus file object

Definition at line 64 of file LegacyNexusDescriptor.h.

◆ extension()

const std::string & Mantid::Kernel::LegacyNexusDescriptor::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 59 of file LegacyNexusDescriptor.h.

◆ filename()

const std::string & Mantid::Kernel::LegacyNexusDescriptor::filename ( ) const
inline

Access the filename.

Returns
A reference to a const string containing the filename

Definition at line 53 of file LegacyNexusDescriptor.h.

Referenced by initialize(), and LegacyNexusDescriptor().

◆ firstEntryNameType()

const std::pair< std::string, std::string > & Mantid::Kernel::LegacyNexusDescriptor::firstEntryNameType ( ) const

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

Definition at line 49 of file LegacyNexusDescriptor.cpp.

References m_firstEntryNameType.

◆ initialize()

void Mantid::Kernel::LegacyNexusDescriptor::initialize ( const std::string &  filename)
private

Initialize object with filename.

Creates the internal cached structure of the file as a tree of nodes.

Definition at line 69 of file LegacyNexusDescriptor.cpp.

References filename(), m_extension, m_file, m_filename, m_pathsToTypes, m_rootAttrs, and walkFile().

Referenced by LegacyNexusDescriptor().

◆ operator=()

LegacyNexusDescriptor & Mantid::Kernel::LegacyNexusDescriptor::operator= ( const LegacyNexusDescriptor )
delete

Disable assignment operator.

◆ pathExists()

bool Mantid::Kernel::LegacyNexusDescriptor::pathExists ( const std::string &  path) const

Query if a path exists.

Parameters
pathA string giving a path using UNIX-style path separators (/), e.g. /raw_data_1, /entry/bank1
Returns
True if the path exists in the file, false otherwise

Definition at line 58 of file LegacyNexusDescriptor.cpp.

References m_pathsToTypes.

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

◆ walkFile()

void Mantid::Kernel::LegacyNexusDescriptor::walkFile ( Mantid::LegacyNexus::File &  file,
const std::string &  rootPath,
const std::string &  className,
std::map< std::string, std::string > &  pmap,
int  level 
)
private

Walk the tree and cache the structure.

Cache the structure in the given maps.

Parameters
fileAn open NeXus File object
rootPathThe current path that is open in the file
classNameThe class of the current open path
pmap[Out] An output map filled with mappings of path->type
levelAn integer defining the current level in the file

Definition at line 89 of file LegacyNexusDescriptor.cpp.

References m_firstEntryNameType, and walkFile().

Referenced by initialize(), and walkFile().

Member Data Documentation

◆ m_extension

std::string Mantid::Kernel::LegacyNexusDescriptor::m_extension
private

Extension.

Definition at line 81 of file LegacyNexusDescriptor.h.

Referenced by initialize().

◆ m_file

std::unique_ptr<Mantid::LegacyNexus::File> Mantid::Kernel::LegacyNexusDescriptor::m_file
private

Open NeXus handle.

Definition at line 90 of file LegacyNexusDescriptor.h.

Referenced by initialize().

◆ m_filename

std::string Mantid::Kernel::LegacyNexusDescriptor::m_filename
private

Full filename.

Definition at line 79 of file LegacyNexusDescriptor.h.

Referenced by initialize().

◆ m_firstEntryNameType

std::pair<std::string, std::string> Mantid::Kernel::LegacyNexusDescriptor::m_firstEntryNameType
private

First entry name/type.

Definition at line 83 of file LegacyNexusDescriptor.h.

Referenced by firstEntryNameType(), and walkFile().

◆ m_pathsToTypes

std::map<std::string, std::string> Mantid::Kernel::LegacyNexusDescriptor::m_pathsToTypes
private

Map of full path strings to types. Can check if path exists quickly.

Definition at line 87 of file LegacyNexusDescriptor.h.

Referenced by initialize(), and pathExists().

◆ m_rootAttrs

std::unordered_set<std::string> Mantid::Kernel::LegacyNexusDescriptor::m_rootAttrs
private

Root attributes.

Definition at line 85 of file LegacyNexusDescriptor.h.

Referenced by initialize().


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