WARPXM v1.10.0
Loading...
Searching...
No Matches
WxIoBase Class Referenceabstract

Provides an abstract interface for access to hierachical datasets. More...

#include <wxiobase.h>

Inheritance diagram for WxIoBase:
WxHdf5Io

Detailed Description

Provides an abstract interface for access to hierachical datasets.

Classes

struct  AtttributeNotFoundException
 Exception class for reporting when an attribute does not exist. More...
 

Public Member Functions

virtual ~WxIoBase ()
 Virtual destructor.
 
void setBaseName (const std::string &bn)
 Set the base name.
 
std::string getBaseName ()
 Get the base name.
 
void setDumpNo (int d)
 Set the dump number.
 
int getDumpNo ()
 Get the dump number.
 
virtual WxIoNodeType createFile (const std::string &fileName)=0
 Create a file.
 
virtual WxIoNodeType createDumpFile (const std::string &dataName)
 Create a file with base name prepended and dump and suffix appended.
 
virtual WxIoNodeType openFile (const std::string &fileName, const std::string &perms)=0
 Open a file.
 
virtual WxIoNodeType openDumpFile (const std::string &dataName, const std::string &perms)
 Open a file with the base name prepended and the dump and suffix appended.
 
virtual void closeFile (WxIoNodeType fileNode)=0
 Close a file node.
 
virtual std::string getDumpFileName (const std::string &dataName)
 Get the dump name for a given data name.
 
virtual WxIoNodeType createGroup (WxIoNodeType node, const std::string &dataName) const =0
 Create an empty group.
 
virtual WxIoNodeType openGroup (WxIoNodeType node, const std::string &dataName) const =0
 Open a group.
 
virtual std::list< std::string > getGroupNames (WxIoNodeType node) const =0
 Get list of group names under the supplied node.
 
virtual WxIoNodeType createDataSet (WxIoNodeType node, const std::string &name, const WxRange &range, const std::type_info &typeinfo) const =0
 Collective dataset allocation.
 
virtual WxIoNodeType createDataSet (WxIoNodeType node, const std::string &dataName) const =0
 Create an empty node.
 
virtual WxIoNodeType openDataSet (WxIoNodeType node, const std::string &dataName) const =0
 Open a node.
 
template<typename T >
WxIoNodeType writeDataSet (WxIoNodeType node, const std::string &dataName, const std::vector< std::pair< int, int > > &fileSpaceCorners, const std::vector< std::pair< int, int > > &memorySpaceCorners, const std::vector< std::pair< int, int > > &writeSelectionCorners, const T *data) const
 Write a new data set under a node.
 
template<typename T >
void writeToDataSet (WxIoNodeType node, const WxRange &memoryRange, const WxRange &memorySubRange, const WxRange &fileRange, const WxRange &fileSubRange, const T *data) const
 Write to an open dataset (independent)
 
template<typename T >
WxIoNodeType readDataSet (WxIoNodeType node, const std::string &dataName, const std::vector< std::pair< int, int > > &memorySpaceCorners, const std::vector< std::pair< int, int > > &readSelectionCorners, T *data) const
 Read a new data set under a node.
 
template<typename T >
void readFromDataSet (WxIoNodeType node, const WxRange &memoryRange, const WxRange &memorySubRange, const WxRange &fileRange, const WxRange &fileSubRange, T *data) const
 Read from an open dataset (independent)
 
WxIoNodeType getDataShape (WxIoNodeType node, const std::string &dataSetName, WxRange &dataShape) const
 Obtain simple data shape for a data set under a node.
 
virtual void closeNode (WxIoNodeType node) const =0
 Close a data set.
 
template<typename T >
void writeAttribute (WxIoNodeType node, const std::string &attribName, const T *attrib)
 Write an attribute.
 
template<typename T >
void writeVecAttribute (WxIoNodeType node, const std::string &attribName, const std::vector< T > &attrib)
 Write an attribute (vector).
 
template<typename T >
void writeVecAttribute (WxIoNodeType node, const std::string &attribName, const T *attribStorage, int count)
 Write a vector of attributes.
 
virtual void writeStrAttribute (WxIoNodeType node, const std::string &attribName, const std::string &attrib) const =0
 Write a string attribute.
 
virtual void writeStrVecAttribute (WxIoNodeType node, const std::string &attribName, const std::vector< std::string > &stringsvector) const =0
 Write a vector of strings as attribute.
 
virtual void readStrAttribute (WxIoNodeType node, const std::string &attribName, std::string &attrib) const =0
 Read a string attribute.
 
virtual std::vector< std::string > readStrVecAttribute (WxIoNodeType node, const std::string &attribName) const =0
 Read a vector of strings attribute.
 
template<typename T >
void readAttribute (WxIoNodeType node, const std::string &attribName, T *attrib)
 Read an attribute.
 
template<typename T >
int readVecAttribute (WxIoNodeType node, const std::string &attribName, T *attribStorage, int count)
 Read a vector attribute.
 

Protected Member Functions

 WxIoBase ()
 Default constructor - no dump, basename or suffix.
 
 WxIoBase (const std::string &sfx)
 Constructor is protected, as this class cannot be made standalone.
 
 WxIoBase (const std::string &bn, int d, const std::string &sfx)
 Constructor is protected, as this class cannot be made standalone.
 
virtual void addOpenFile (WxIoNodeType node)
 Add a file to the list of open files.
 
virtual void removeOpenFile (WxIoNodeType node)
 Remove a file from the list of open files.
 
virtual void closeOpenFiles ()
 Close any files currently open.
 
void setIo (const WxIoTmpl *b)
 Sets the new io object implementation.
 

Protected Attributes

std::string suffix
 

Constructor & Destructor Documentation

◆ ~WxIoBase()

virtual WxIoBase::~WxIoBase ( )
virtual

Virtual destructor.

◆ WxIoBase() [1/3]

WxIoBase::WxIoBase ( )
protected

Default constructor - no dump, basename or suffix.

◆ WxIoBase() [2/3]

WxIoBase::WxIoBase ( const std::string &  sfx)
protected

Constructor is protected, as this class cannot be made standalone.

Construct with suffix only.

Parameters
sfxthe suffix for file names

◆ WxIoBase() [3/3]

WxIoBase::WxIoBase ( const std::string &  bn,
int  d,
const std::string &  sfx 
)
protected

Constructor is protected, as this class cannot be made standalone.

Parameters
bnthe base for file names
dthe dump number for file names
sfxthe suffix for file names

Member Function Documentation

◆ addOpenFile()

virtual void WxIoBase::addOpenFile ( WxIoNodeType  node)
protectedvirtual

Add a file to the list of open files.

Parameters
nodethe file node

◆ closeFile()

virtual void WxIoBase::closeFile ( WxIoNodeType  fileNode)
pure virtual

Close a file node.

Implemented in WxHdf5Io.

◆ closeNode()

virtual void WxIoBase::closeNode ( WxIoNodeType  node) const
pure virtual

Close a data set.

Parameters
nodethe node to be closed

Implemented in WxHdf5Io.

◆ closeOpenFiles()

virtual void WxIoBase::closeOpenFiles ( )
protectedvirtual

Close any files currently open.

◆ createDataSet() [1/2]

virtual WxIoNodeType WxIoBase::createDataSet ( WxIoNodeType  node,
const std::string &  dataName 
) const
pure virtual

Create an empty node.

Parameters
nodethe node to write under
dataNamethe name of the data
Returns
the node to the written data. This is not closed.

Implemented in WxHdf5Io.

◆ createDataSet() [2/2]

virtual WxIoNodeType WxIoBase::createDataSet ( WxIoNodeType  node,
const std::string &  name,
const WxRange range,
const std::type_info &  typeinfo 
) const
pure virtual

Collective dataset allocation.

Parameters
nodethe node to write under
namethe name of the data
rangethe name of the data
Returns
the node to the dataset. This is not closed.

Implemented in WxHdf5Io.

◆ createDumpFile()

virtual WxIoNodeType WxIoBase::createDumpFile ( const std::string &  dataName)
virtual

Create a file with base name prepended and dump and suffix appended.

Parameters
dataNamethe name for the file. Assumed to be rw.
Returns
node for the file

◆ createFile()

virtual WxIoNodeType WxIoBase::createFile ( const std::string &  fileName)
pure virtual

Create a file.

Parameters
fileNamethe name for the file. (an appropriate extension is added to the supplied filename.) Assumed to be rw.
Returns
node for the file

Implemented in WxHdf5Io.

◆ createGroup()

virtual WxIoNodeType WxIoBase::createGroup ( WxIoNodeType  node,
const std::string &  dataName 
) const
pure virtual

Create an empty group.

Parameters
nodethe node to write under
dataNamethe name of the data
Returns
the node to the written data. This is not closed.

Implemented in WxHdf5Io.

◆ getBaseName()

std::string WxIoBase::getBaseName ( )
inline

Get the base name.

Returns
the base name. Used to compose the file name.

◆ getDataShape()

WxIoNodeType WxIoBase::getDataShape ( WxIoNodeType  node,
const std::string &  dataSetName,
WxRange dataShape 
) const
inline

Obtain simple data shape for a data set under a node.

Parameters
nodethe node under which to find the dataset
dataNamethe name of the data
dataShapethe data set shape is returned by reference
Returns
the node to the dataset found

◆ getDumpFileName()

virtual std::string WxIoBase::getDumpFileName ( const std::string &  dataName)
virtual

Get the dump name for a given data name.

◆ getDumpNo()

int WxIoBase::getDumpNo ( )
inline

Get the dump number.

Returns
the dump number

◆ getGroupNames()

virtual std::list< std::string > WxIoBase::getGroupNames ( WxIoNodeType  node) const
pure virtual

Get list of group names under the supplied node.

Parameters
nodethe node to look in
Returns
list of group names found under the supplied node

Implemented in WxHdf5Io.

◆ openDataSet()

virtual WxIoNodeType WxIoBase::openDataSet ( WxIoNodeType  node,
const std::string &  dataName 
) const
pure virtual

Open a node.

Parameters
nodethe node to look in
dataNamethe name of the node to open
Returns
the node to the read data

Implemented in WxHdf5Io.

◆ openDumpFile()

virtual WxIoNodeType WxIoBase::openDumpFile ( const std::string &  dataName,
const std::string &  perms 
)
virtual

Open a file with the base name prepended and the dump and suffix appended.

Parameters
dataNameused to compose the name of the file
permsthe read and write permissions. "r" or "rw"
Returns
node for the file

◆ openFile()

virtual WxIoNodeType WxIoBase::openFile ( const std::string &  fileName,
const std::string &  perms 
)
pure virtual

Open a file.

Parameters
fileNamethe name for the file
permsthe read and write permissions. "r" or "rw"
Returns
node for the file

Implemented in WxHdf5Io.

◆ openGroup()

virtual WxIoNodeType WxIoBase::openGroup ( WxIoNodeType  node,
const std::string &  dataName 
) const
pure virtual

Open a group.

Parameters
nodethe node to look in
dataNamethe name of the data to open
Returns
the node to the read data

Implemented in WxHdf5Io.

◆ readAttribute()

template<typename T >
void WxIoBase::readAttribute ( WxIoNodeType  node,
const std::string &  attribName,
T *  attrib 
)
inline

Read an attribute.

Parameters
nodethe node to write under
attribNamethe name of the attribute
attribthe attribute to be read

◆ readDataSet()

template<typename T >
WxIoNodeType WxIoBase::readDataSet ( WxIoNodeType  node,
const std::string &  dataName,
const std::vector< std::pair< int, int > > &  memorySpaceCorners,
const std::vector< std::pair< int, int > > &  readSelectionCorners,
T *  data 
) const
inline

Read a new data set under a node.

Parameters
nodethe node to read under
dataNamethe name of the data
memorySpaceCornersvector of (start, stop) pairs for each dimension that specify local extent held in contiguous allocation
readSelectionCornersvector of (start, stop) pairs for each dimension that specify subarea of local extent to read
datathe destination for data to be read. This is returned in ROW MAJOR ordering.
Returns
the node to the written data. The node is not closed.

◆ readFromDataSet()

template<typename T >
void WxIoBase::readFromDataSet ( WxIoNodeType  node,
const WxRange memoryRange,
const WxRange memorySubRange,
const WxRange fileRange,
const WxRange fileSubRange,
T *  data 
) const
inline

Read from an open dataset (independent)

Parameters
nodethe node to read under
memoryRangeRange that specifies total extent on host
memorySubRangeRange that specifies local extent on host
fileRangeRange that specifies total extent on file
fileSubRangeRange that specifies local extent on file
datathe destination for data to be read. This is returned in ROW MAJOR ordering.

◆ readStrAttribute()

virtual void WxIoBase::readStrAttribute ( WxIoNodeType  node,
const std::string &  attribName,
std::string &  attrib 
) const
pure virtual

Read a string attribute.

Parameters
nodethe node to read under
attribNamethe name of the attribute
attribthe string value of the attribute

Implemented in WxHdf5Io.

◆ readStrVecAttribute()

virtual std::vector< std::string > WxIoBase::readStrVecAttribute ( WxIoNodeType  node,
const std::string &  attribName 
) const
pure virtual

Read a vector of strings attribute.

Parameters
nodethe node to read under
attribNamethe name of the attribute
Returns
the vector of string values in the attribute.
Exceptions
AtttributeNotFoundExceptionif attribName is not found at node.
WxExcepton all other errors

Implemented in WxHdf5Io.

◆ readVecAttribute()

template<typename T >
int WxIoBase::readVecAttribute ( WxIoNodeType  node,
const std::string &  attribName,
T *  attribStorage,
int  count 
)
inline

Read a vector attribute.

Parameters
nodethe node to which this attribute belongs
attribNamethe name of the attribute
attribStoragethe vector attribute to be read
countmaximum number of items to read; the amount of memory provided by attribStorage
Returns
number of items actually read

◆ removeOpenFile()

virtual void WxIoBase::removeOpenFile ( WxIoNodeType  node)
protectedvirtual

Remove a file from the list of open files.

Parameters
nodethe file node

◆ setBaseName()

void WxIoBase::setBaseName ( const std::string &  bn)
inline

Set the base name.

Parameters
bnthe base name

◆ setDumpNo()

void WxIoBase::setDumpNo ( int  d)
inline

Set the dump number.

Parameters
dthe dump number. Not used if negative.

◆ setIo()

void WxIoBase::setIo ( const WxIoTmpl b)
inlineprotected

Sets the new io object implementation.

The derived class should call this to setup WxIoBase properly.

◆ writeAttribute()

template<typename T >
void WxIoBase::writeAttribute ( WxIoNodeType  node,
const std::string &  attribName,
const T *  attrib 
)
inline

Write an attribute.

Parameters
nodethe node to write under
attribNamethe name of the attribute
attribthe attribute to be written

◆ writeDataSet()

template<typename T >
WxIoNodeType WxIoBase::writeDataSet ( WxIoNodeType  node,
const std::string &  dataName,
const std::vector< std::pair< int, int > > &  fileSpaceCorners,
const std::vector< std::pair< int, int > > &  memorySpaceCorners,
const std::vector< std::pair< int, int > > &  writeSelectionCorners,
const T *  data 
) const
inline

Write a new data set under a node.

Parameters
nodethe node to write under
dataNamethe name of the data
fileSpaceCornersvector of (start, stop) pairs for each dimension that specify the global data space extent
memorySpaceCornersvector of (start, stop) pairs for each dimension that specify local extent held in contiguous allocation
writeSelectionCornersvector of (start, stop) pairs for each dimension that specify subarea of local extent to write
datathe data to be written. This is expected in ROW MAJOR ordering.
Returns
the node to the written data. The node is not closed.

◆ writeStrAttribute()

virtual void WxIoBase::writeStrAttribute ( WxIoNodeType  node,
const std::string &  attribName,
const std::string &  attrib 
) const
pure virtual

Write a string attribute.

Parameters
nodethe node to write under
attribNamethe name of the attribute
attribthe string value of the attribute

Implemented in WxHdf5Io.

◆ writeStrVecAttribute()

virtual void WxIoBase::writeStrVecAttribute ( WxIoNodeType  node,
const std::string &  attribName,
const std::vector< std::string > &  stringsvector 
) const
pure virtual

Write a vector of strings as attribute.

Parameters
nodethe node to write under
attribNamethe name of the attribute
thevector of strings for the attribute

Implemented in WxHdf5Io.

◆ writeToDataSet()

template<typename T >
void WxIoBase::writeToDataSet ( WxIoNodeType  node,
const WxRange memoryRange,
const WxRange memorySubRange,
const WxRange fileRange,
const WxRange fileSubRange,
const T *  data 
) const
inline

Write to an open dataset (independent)

Parameters
nodethe node to write under
memoryRangeRange that specifies total extent on host
memorySubRangeRange that specifies local extent on host
fileRangeRange that specifies total extent on file
fileSubRangeRange that specifies local extent on file
datathe destination for data to be written. This is returned in ROW MAJOR ordering.

◆ writeVecAttribute() [1/2]

template<typename T >
void WxIoBase::writeVecAttribute ( WxIoNodeType  node,
const std::string &  attribName,
const std::vector< T > &  attrib 
)
inline

Write an attribute (vector).

Parameters
nodethe node to write under
attribNamethe name of the attribute
attribthe attribute vector to be written

◆ writeVecAttribute() [2/2]

template<typename T >
void WxIoBase::writeVecAttribute ( WxIoNodeType  node,
const std::string &  attribName,
const T *  attribStorage,
int  count 
)
inline

Write a vector of attributes.

Parameters
nodethe node to write under
attribNamethe name of the attribute
attribStoragethe vector attribute to be written
countnumber of items to write

Member Data Documentation

◆ suffix

std::string WxIoBase::suffix
protected

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