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

The base class for a Nexus class (group). More...

#include <NexusClasses.h>

Inheritance diagram for Mantid::Nexus::NXClass:
Mantid::Nexus::NXObject Mantid::Nexus::NXData Mantid::Nexus::NXDetector Mantid::Nexus::NXEntry Mantid::Nexus::NXInstrument Mantid::Nexus::NXRoot

Public Member Functions

void close ()
 Close this class.
 
bool containsDataSet (const std::string &query) const
 Returns whether an individual dataset is present.
 
bool containsGroup (const std::string &query) const
 Returns whether an individual group (or group) is present.
 
std::vector< NXInfo > & datasets () const
 Returns a list of all datasets in this NXClass.
 
NXInfo getDataSetInfo (const std::string &name) const
 Returns NXInfo for a dataset.
 
double getDouble (const std::string &name) const
 Returns a double.
 
float getFloat (const std::string &name) const
 Returns a float.
 
int32_t getInt (const std::string &name) const
 Returns a int.
 
std::string getString (const std::string &name) const
 Returns a string.
 
std::vector< NXClassInfo > & groups () const
 Returns a list of all classes (or groups) in this NXClass.
 
bool isValid (const std::string &address) const
 Check if a address exists relative to the current class address.
 
std::string NX_class () const override
 The NX class identifier.
 
 NXClass (NXClass const &parent, std::string const &name)
 Constructor.
 
void open ()
 Opens this NXClass using File::openGroupAddress(). Can be slow (or is slow)
 
bool openLocal (const std::string &nxclass="")
 Opens this NXClass using File::openGroup().
 
NXChar openNXChar (const std::string &name) const
 Creates and opens a char dataset.
 
template<class NX >
NX openNXClass (const std::string &name) const
 Templated method for creating derived NX classes.
 
template<class T >
NXDataSetTyped< T > openNXDataSet (const std::string &name) const
 Templated method for creating datasets.
 
NXDouble openNXDouble (const std::string &name) const
 Creates and opens a double dataset.
 
NXFloat openNXFloat (const std::string &name) const
 Creates and opens a float dataset.
 
NXClass openNXGroup (const std::string &name) const
 Creates and opens an arbitrary (non-standard) class (group).
 
NXInt openNXInt (const std::string &name) const
 Creates and opens an integer dataset.
 
NXUInt64 openNXSize (const std::string &name) const
 Creates and opens a size_t dataset.
 
- Public Member Functions inherited from Mantid::Nexus::NXObject
NexusAddress const & address () const
 Returns the absolute address to the object.
 
std::string name () const
 Returns the name of the object.
 
 NXObject (File *fileID, NXClass const *parent, std::string const &name)
 NXObject constructor.
 
 NXObject (std::shared_ptr< File > const &fileID, NXClass const *parent, std::string const &name)
 NXObject constructor.
 
virtual ~NXObject ()=default
 

Protected Member Functions

void clear ()
 Deletes content of m_groups and m_datasets.
 
void readAllInfo ()
 Fills in m_groups and m_datasets.
 

Protected Attributes

std::shared_ptr< std::vector< NXInfo > > m_datasets
 Holds info about the datasets in this NXClass.
 
std::shared_ptr< std::vector< NXClassInfo > > m_groups
 Holds info about the child NXClasses.
 
- Protected Attributes inherited from Mantid::Nexus::NXObject
NexusAddress m_address
 Keeps the absolute address to the object.
 
bool m_open
 Set to true if the object has been open.
 

Private Member Functions

 NXClass ()
 Private constructor.
 

Friends

class NXRoot
 

Additional Inherited Members

- Public Attributes inherited from Mantid::Nexus::NXObject
std::shared_ptr< File > m_fileID
 Nexus file id.
 

Detailed Description

The base class for a Nexus class (group).

A Nexus class can contain datasets and other Nexus classes. The Nexus file format (www.nexusformat.org) specifies the content of the Nexus classes.

Derived classes have specialized methods for creating classes and datasets specific for the particular Nexus class. NXClass is a conctrete C++ class so arbitrary, non-standard Nexus classes (groups) can be created and loaded from Nexus files.

Definition at line 448 of file NexusClasses.h.

Constructor & Destructor Documentation

◆ NXClass() [1/2]

Mantid::Nexus::NXClass::NXClass ( NXClass const &  parent,
std::string const &  name 
)

Constructor.

Parameters
parent:: The parent Nexus class. In terms of HDF it is the group containing the NXClass.
name:: The name of the NXClass relative to its parent

Definition at line 137 of file NexusClasses.cpp.

References clear().

◆ NXClass() [2/2]

Mantid::Nexus::NXClass::NXClass ( )
inlineprivate

Private constructor.

Definition at line 591 of file NexusClasses.h.

Member Function Documentation

◆ clear()

void Mantid::Nexus::NXClass::clear ( )
protected

Deletes content of m_groups and m_datasets.

Definition at line 193 of file NexusClasses.cpp.

References m_datasets, and m_groups.

Referenced by NXClass(), and readAllInfo().

◆ close()

void Mantid::Nexus::NXClass::close ( )

◆ containsDataSet()

bool Mantid::Nexus::NXClass::containsDataSet ( const std::string &  query) const

◆ containsGroup()

bool Mantid::Nexus::NXClass::containsGroup ( const std::string &  query) const

◆ datasets()

std::vector< NXInfo > & Mantid::Nexus::NXClass::datasets ( ) const
inline

Returns a list of all datasets in this NXClass.

Definition at line 563 of file NexusClasses.h.

Referenced by Mantid::DataHandling::ANSTO::filterDatasets(), getDataSetInfo(), and Mantid::DataHandling::ANSTO::Anxs::isTimedDataSet().

◆ getDataSetInfo()

NXInfo Mantid::Nexus::NXClass::getDataSetInfo ( const std::string &  name) const

◆ getDouble()

double Mantid::Nexus::NXClass::getDouble ( const std::string &  name) const

Returns a double.

Parameters
name:: The name of the NXDouble dataset
Returns
The double

Definition at line 209 of file NexusClasses.cpp.

References Mantid::Nexus::NXDataSetTyped< T >::load(), Mantid::Nexus::NXObject::name(), and openNXDouble().

◆ getFloat()

float Mantid::Nexus::NXClass::getFloat ( const std::string &  name) const

◆ getInt()

int32_t Mantid::Nexus::NXClass::getInt ( const std::string &  name) const

◆ getString()

std::string Mantid::Nexus::NXClass::getString ( const std::string &  name) const

◆ groups()

std::vector< NXClassInfo > & Mantid::Nexus::NXClass::groups ( ) const
inline

◆ isValid()

bool Mantid::Nexus::NXClass::isValid ( const std::string &  address) const

Check if a address exists relative to the current class address.

Parameters
address:: A string representing the address to test
Returns
True if it is valid

Definition at line 153 of file NexusClasses.cpp.

References Mantid::Nexus::NXObject::address(), and Mantid::Nexus::NXObject::m_fileID.

Referenced by Mantid::DataHandling::LoadNexusProcessed::doAccelleratedMultiPeriodLoading(), Mantid::DataHandling::LoadNexusProcessed::loadEventEntry(), Mantid::DataHandling::LoadNexusProcessed::loadNonEventEntry(), and Mantid::DataHandling::LoadILLReflectometry::sampleAngle().

◆ NX_class()

std::string Mantid::Nexus::NXClass::NX_class ( ) const
inlineoverridevirtual

The NX class identifier.

Implements Mantid::Nexus::NXObject.

Reimplemented in Mantid::Nexus::NXData, Mantid::Nexus::NXDetector, Mantid::Nexus::NXInstrument, Mantid::Nexus::NXEntry, and Mantid::Nexus::NXRoot.

Definition at line 460 of file NexusClasses.h.

Referenced by close(), and openLocal().

◆ open()

void Mantid::Nexus::NXClass::open ( )

Opens this NXClass using File::openGroupAddress(). Can be slow (or is slow)

Definition at line 155 of file NexusClasses.cpp.

References Mantid::Nexus::NXObject::m_address, Mantid::Nexus::NXObject::m_fileID, Mantid::Nexus::NXObject::m_open, and readAllInfo().

◆ openLocal()

bool Mantid::Nexus::NXClass::openLocal ( const std::string &  nxclass = "")

Opens this NXClass using File::openGroup().

It is fast, but the parent of this class must be open at the time of calling.

It is fast, but the parent of this class must be open at the time of calling. openNXClass uses open() (the slow one). To open calss using openLocal() do: NXTheClass class(parent,name); class.openLocal(); // work with class class.close();

openNXClass uses open() (the slow one). To open class using openLocal() do: NXTheClass class(parent,name); class.openLocal(); // work with class class.close();

Parameters
nxclass:: The NX class name. If empty NX_class() will be used
Returns
true if OK

Definition at line 171 of file NexusClasses.cpp.

References Mantid::Nexus::NXObject::m_fileID, Mantid::Nexus::NXObject::m_open, Mantid::Nexus::NXObject::name(), NX_class(), and readAllInfo().

Referenced by Mantid::DataHandling::LoadNexusProcessed::doAccelleratedMultiPeriodLoading().

◆ openNXChar()

NXChar Mantid::Nexus::NXClass::openNXChar ( const std::string &  name) const
inline

◆ openNXClass()

template<class NX >
NX Mantid::Nexus::NXClass::openNXClass ( const std::string &  name) const
inline

Templated method for creating derived NX classes.

It also opens the created class.

Parameters
name:: The name of the class
Template Parameters
NXConcrete Nexus class
Returns
The new object

Definition at line 475 of file NexusClasses.h.

References name.

◆ openNXDataSet()

template<class T >
NXDataSetTyped< T > Mantid::Nexus::NXClass::openNXDataSet ( const std::string &  name) const
inline

◆ openNXDouble()

NXDouble Mantid::Nexus::NXClass::openNXDouble ( const std::string &  name) const
inline

◆ openNXFloat()

NXFloat Mantid::Nexus::NXClass::openNXFloat ( const std::string &  name) const
inline

Creates and opens a float dataset.

Parameters
name:: The name of the dataset
Returns
The float

Definition at line 513 of file NexusClasses.h.

References name.

Referenced by getFloat(), Mantid::DataHandling::LoadMuonNexusV2NexusHelper::getPeriodTotalCounts(), Mantid::DataHandling::LoadHelper::getTimeBinningFromNexusAddress(), Mantid::DataHandling::LoadILLSANS::getVariableTimeBinning(), Mantid::DataHandling::LoadILLPolarizedDiffraction::initStaticWorkspace(), Mantid::DataHandling::LoadILLSANS::initWorkSpaceD11B(), Mantid::DataHandling::LoadILLSANS::initWorkSpaceD22B(), Mantid::DataHandling::LoadILLSANS::initWorkSpaceD33(), Mantid::DataHandling::LoadILLIndirect2::loadDataDetails(), Mantid::DataHandling::LoadILLReflectometry::loadDataDetails(), Mantid::DataHandling::LoadILLDiffraction::loadDataScan(), Mantid::DataHandling::LoadMuonNexusV2NexusHelper::loadDeadTimesFromNexus(), Mantid::DataHandling::LoadNexusProcessed::loadEventEntry(), Mantid::DataHandling::LoadISISNexus2::loadPeriodData(), Mantid::DataHandling::LoadISISNexusHelper::loadRunDetails(), Mantid::DataHandling::LoadISISNexusHelper::loadSampleGeometry(), Mantid::DataHandling::LoadISISNexusHelper::loadTimeData(), Mantid::DataHandling::LoadILLTOF3::loadTimeDetails(), Mantid::DataHandling::LoadMLZ::loadTimeDetails(), Mantid::DataHandling::LoadILLPolarizedDiffraction::loadTwoThetaDetectors(), Mantid::DataHandling::LoadILLIndirect2::moveSingleDetectors(), Mantid::DataHandling::LoadILLPolarizedDiffraction::moveTwoTheta(), Mantid::DataHandling::LoadILLPolarizedDiffraction::prepareAxes(), and Mantid::DataHandling::LoadILLReflectometry::sampleAngle().

◆ openNXGroup()

NXClass Mantid::Nexus::NXClass::openNXGroup ( const std::string &  name) const
inline

Creates and opens an arbitrary (non-standard) class (group).

Parameters
name:: The name of the class.
Returns
The opened NXClass

Definition at line 487 of file NexusClasses.h.

References name.

Referenced by Mantid::DataHandling::LoadISISNexus2::exec(), Mantid::DataHandling::ANSTO::filterDatasets(), Mantid::DataHandling::LoadISISNexusHelper::findDetectorIDsAndSpectrumNumber(), Mantid::DataHandling::LoadISISNexusHelper::findNumberOfSpectra(), Mantid::DataHandling::LoadILLIndirect2::getDataAddress(), Mantid::DataHandling::LoadMuonNexusV2NexusHelper::getIntVector(), Mantid::DataHandling::LoadMuonNexusV2NexusHelper::getNumberOfPeriods(), Mantid::DataHandling::LoadMuonNexusV2NexusHelper::getPeriodLabels(), Mantid::DataHandling::LoadMuonNexusV2NexusHelper::getPeriodTotalCounts(), Mantid::DataHandling::LoadILLTOF3::initWorkspace(), Mantid::DataHandling::LoadISISNexus2::isMultipleTimeRegimeFile(), Mantid::DataHandling::ANSTO::Anxs::isTimedDataSet(), Mantid::DataHandling::LoadMuonNexusV2NexusHelper::loadDeadTimesFromNexus(), Mantid::DataHandling::LoadMuonNexusV2NexusHelper::loadDetectorGroupingFromNexus(), Mantid::DataHandling::LoadILLIndirect2::loadDiffractionData(), Mantid::DataHandling::LoadMuonNexusV2NexusHelper::loadFirstGoodDataFromNexus(), Mantid::DataHandling::LoadMuonNexusV2NexusHelper::loadGoodFramesDataFromNexus(), Mantid::DataHandling::LoadMuonNexusV2NexusHelper::loadLastGoodDataFromNexus(), Mantid::DataHandling::LoadNexusProcessed::loadNonEventEntry(), Mantid::DataHandling::LoadISISNexusHelper::loadRunDetails(), Mantid::DataHandling::LoadMLZ::loadRunDetails(), Mantid::DataHandling::LoadISISNexusHelper::loadSampleGeometry(), Mantid::DataHandling::LoadMuonNexusV2NexusHelper::loadSampleInformationFromNexus(), Mantid::DataHandling::LoadISISNexusHelper::loadTimeData(), Mantid::DataHandling::LoadILLTOF3::loadTimeDetails(), Mantid::DataHandling::LoadMuonNexusV2NexusHelper::loadTimeZeroFromNexusFile(), Mantid::DataHandling::LoadMuonNexusV2NexusHelper::loadTimeZeroListFromNexusFile(), and Mantid::DataHandling::LoadILLTOF3::prepareAxis().

◆ openNXInt()

NXInt Mantid::Nexus::NXClass::openNXInt ( const std::string &  name) const
inline

Creates and opens an integer dataset.

Parameters
name:: The name of the dataset
Returns
The int

Definition at line 507 of file NexusClasses.h.

References name.

Referenced by Mantid::DataHandling::LoadISISNexus2::exec(), Mantid::DataHandling::LoadNexusProcessed2::extractMappingInfoNew(), Mantid::DataHandling::LoadISISNexusHelper::findDetectorIDsAndSpectrumNumber(), Mantid::DataHandling::LoadISISNexusHelper::findNumberOfSpectra(), Mantid::DataHandling::LoadISISNexus2::findSpectraDetRangeInFile(), getInt(), Mantid::DataHandling::LoadMuonNexusV2NexusHelper::getIntVector(), Mantid::DataHandling::LoadILLReflectometry::initNames(), Mantid::DataHandling::LoadILLPolarizedDiffraction::initStaticWorkspace(), Mantid::DataHandling::LoadILLSANS::initWorkSpaceD33(), Mantid::DataHandling::LoadILLIndirect2::loadDataDetails(), Mantid::DataHandling::LoadILLReflectometry::loadDataDetails(), Mantid::DataHandling::LoadILLDiffraction::loadDataScan(), Mantid::DataHandling::LoadMuonNexusV2NexusHelper::loadDetectorGroupingFromNexus(), Mantid::DataHandling::LoadMuonNexusV2NexusHelper::loadFirstGoodDataFromNexus(), Mantid::DataHandling::LoadMuonNexusV2NexusHelper::loadGoodFramesDataFromNexus(), Mantid::DataHandling::LoadMuonNexusV2NexusHelper::loadLastGoodDataFromNexus(), Mantid::DataHandling::LoadNexusProcessed::loadLeanElasticPeaksEntry(), Mantid::DataHandling::LoadNexusProcessed::loadPeaksEntry(), Mantid::DataHandling::LoadISISNexusHelper::loadRunDetails(), Mantid::DataHandling::LoadISISNexusHelper::loadSampleGeometry(), Mantid::DataHandling::LoadMLZ::maskDetectors(), Mantid::DataHandling::LoadILLTOF3::prepareAxis(), and Mantid::DataHandling::LoadNexusProcessed::readBinMasking().

◆ openNXSize()

NXUInt64 Mantid::Nexus::NXClass::openNXSize ( const std::string &  name) const
inline

Creates and opens a size_t dataset.

Parameters
name:: The name of the dataset
Returns
The size_t

Definition at line 531 of file NexusClasses.h.

References name.

Referenced by Mantid::DataHandling::LoadNexusProcessed::readBinMasking().

◆ readAllInfo()

void Mantid::Nexus::NXClass::readAllInfo ( )
protected

Fills in m_groups and m_datasets.

Definition at line 139 of file NexusClasses.cpp.

References clear(), m_datasets, Mantid::Nexus::NXObject::m_fileID, and m_groups.

Referenced by Mantid::Nexus::NXRoot::NXRoot(), open(), and openLocal().

Friends And Related Symbol Documentation

◆ NXRoot

friend class NXRoot
friend

Definition at line 449 of file NexusClasses.h.

Member Data Documentation

◆ m_datasets

std::shared_ptr<std::vector<NXInfo> > Mantid::Nexus::NXClass::m_datasets
protected

Holds info about the datasets in this NXClass.

Definition at line 586 of file NexusClasses.h.

Referenced by clear(), and readAllInfo().

◆ m_groups

std::shared_ptr<std::vector<NXClassInfo> > Mantid::Nexus::NXClass::m_groups
protected

Holds info about the child NXClasses.

Definition at line 585 of file NexusClasses.h.

Referenced by clear(), containsGroup(), and readAllInfo().


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