Chombo + EB + MF  3.2
Public Types | Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
HDF5Handle Class Reference

Handle to a particular group in an HDF file. More...

#include <CH_HDF5.H>

Public Types

enum  mode { CREATE, CREATE_SERIAL, OPEN_RDONLY, OPEN_RDWR }
 

Public Member Functions

 HDF5Handle ()
 { constructor} More...
 
 HDF5Handle (const std::string &a_filename, mode a_mode, const char *a_globalGroupName="Chombo_global")
 
 ~HDF5Handle ()
 
int open (const std::string &a_filename, mode a_mode, const char *a_globalGroupName="Chombo_global")
 { File functions} More...
 
bool isOpen () const
 
void close ()
 
void setGroupToLevel (int a_level)
 { Group functions} More...
 
int setGroup (const std::string &groupAbsPath)
 
int pushGroup (const std::string &grp)
 
int popGroup ()
 
const std::string & getGroup () const
 
HDF5Handle::mode openMode () const
 
const hid_t & fileID () const
 
const hid_t & groupID () const
 

Static Public Attributes

static hid_t box_id
 
static hid_t intvect_id
 
static hid_t realvect_id
 
static map< std::string, std::string > groups
 

Private Member Functions

 HDF5Handle (const HDF5Handle &)
 
HDF5Handleoperator= (const HDF5Handle &)
 

Static Private Member Functions

static void initialize ()
 

Private Attributes

hid_t m_fileID
 
hid_t m_currentGroupID
 
mode m_mode
 
bool m_isOpen
 
std::string m_filename
 
std::string m_group
 
int m_level
 

Static Private Attributes

static bool initialized
 

Detailed Description

Handle to a particular group in an HDF file.

HDF5Handle is a handle to a particular group in an HDF file. Upon construction, group is defined to be the root. All data is written and read assuming the native representations for data on the architecture it is running on. When a file is opened, these settings are checked and an error is flagged when things don't match up. It is the USER'S responsibility to close() this object when it is no longer needed.

Member Enumeration Documentation

◆ mode

Enumeration of opening modes for HDF5 files. \

CREATE: file is created if it didn't exist, or an existing file of the same name is clobbered.\

CREATE_SERIAL: in serial execution this is equivalent to CREATE. In parallel this opens a file just on this particular calling processor. Working with LevelData and this kind of file is difficult to get right and most users will not use this mode. \

OPEN_RDONLY: existing file is opened in read-only mode. If the file doesn't already exist then open fails and isOpen() returns false.\

OPEN_RDWR: existing file is opened in read-write mode. If the file doesn't already exist then open fails and isOpen() returns false.\

Enumerator
CREATE 
CREATE_SERIAL 
OPEN_RDONLY 
OPEN_RDWR 

Constructor & Destructor Documentation

◆ HDF5Handle() [1/3]

HDF5Handle::HDF5Handle ( )

{ constructor}

Default constructor. User must call open() prior to using constructed object.

◆ HDF5Handle() [2/3]

HDF5Handle::HDF5Handle ( const std::string &  a_filename,
mode  a_mode,
const char *  a_globalGroupName = "Chombo_global" 
)

Opens file and sets the current group to the root "/" group. \

if mode == CREATE, then file is created if it didn't exist, or an existing file of the same name is clobbered.\

if mode == OPEN_*, then existing file is opened, if the file doesn't already exist then open fails and isOpen() returns false.\

Writes basic information such as SpaceDim and testReal to a global group. The global group is named Chombo_global in the call signature where no globalGroupName is passed.\

◆ ~HDF5Handle()

HDF5Handle::~HDF5Handle ( )

◆ HDF5Handle() [3/3]

HDF5Handle::HDF5Handle ( const HDF5Handle )
private

Member Function Documentation

◆ open()

int HDF5Handle::open ( const std::string &  a_filename,
mode  a_mode,
const char *  a_globalGroupName = "Chombo_global" 
)

{ File functions}

Opens file and sets the current group of this HDF5Handle to the root "/" group. File that this HDF5Handle previously pointed at is NOT closed, that is the users responsibility.\

if mode == CREATE, then file is created if it didn't exist, or an existing file of the same name is clobbered.\

if mode == OPEN_*, then existing file is opened, if the file doesn't already exist then open fails and isOpen() returns false.\

Writes basic information such as SpaceDim and testReal to a global group. The global group is named Chombo_global in the call signature where no globalGroupName is passed.\

returns:\ 0 on success\ negative number if file open failed (return code from HDF5)\ 1 file does not appear to contain datacheck info, probably not a Chombo file\ 2 on data bit size differences between code and file.\

aborts on SpaceDim not matching between code and file\

◆ isOpen()

bool HDF5Handle::isOpen ( ) const

A NULL or failed constructed HDF5Handle will return false.

◆ close()

void HDF5Handle::close ( )

Closes the file. Must be called to close file. Files are not automatically closed.

◆ setGroupToLevel()

void HDF5Handle::setGroupToLevel ( int  a_level)

{ Group functions}

Sets the current group to be "/level_x" where x=a_level.

◆ setGroup()

int HDF5Handle::setGroup ( const std::string &  groupAbsPath)

Set group to users choice, referenced from file root. groupAbsPath will look like a Unix file path: "/mySpecialData/group1/" "/" is the root group of the file. returns a negative value on failure

Referenced by blockRead(), blockReadLevel(), blockWrite(), blockWriteLevel(), read(), readLevel(), write(), writeLevel(), and WriteMultiData< T >::WriteMultiData().

◆ pushGroup()

int HDF5Handle::pushGroup ( const std::string &  grp)

Add the indicated string to the group path. For example, if getGroup() returns "/foo" then after pushGroup("bar"), getGroup() will return "/foo/bar". Return value is whatever the internal setGroup returns.

◆ popGroup()

int HDF5Handle::popGroup ( )

Pop off the last element of the group path. For example, "/foo/bar" becomes "/foo". It's an error to call this function if the group, going in, is "/". Return value is whatever the internal setGroup returns, when we call it to reset the group's path.

◆ getGroup()

const std::string& HDF5Handle::getGroup ( ) const

Returns name of current group. groupAbsPath will look like a Unix file path: "/mySpecialData/group1/" "/" is the root group of the file.

Referenced by blockRead(), blockReadLevel(), blockWrite(), blockWriteLevel(), read(), readLevel(), readParticlesFromHDF(), write(), writeLevel(), and WriteMultiData< T >::WriteMultiData().

◆ openMode()

HDF5Handle::mode HDF5Handle::openMode ( ) const
inline

Referenced by write().

◆ fileID()

const hid_t& HDF5Handle::fileID ( ) const

◆ groupID()

const hid_t& HDF5Handle::groupID ( ) const

◆ operator=()

HDF5Handle& HDF5Handle::operator= ( const HDF5Handle )
private

◆ initialize()

static void HDF5Handle::initialize ( )
staticprivate

Member Data Documentation

◆ box_id

hid_t HDF5Handle::box_id
static

◆ intvect_id

hid_t HDF5Handle::intvect_id
static

◆ realvect_id

hid_t HDF5Handle::realvect_id
static

◆ groups

map<std::string, std::string> HDF5Handle::groups
static

◆ m_fileID

hid_t HDF5Handle::m_fileID
private

◆ m_currentGroupID

hid_t HDF5Handle::m_currentGroupID
private

◆ m_mode

mode HDF5Handle::m_mode
private

◆ m_isOpen

bool HDF5Handle::m_isOpen
private

◆ m_filename

std::string HDF5Handle::m_filename
private

◆ m_group

std::string HDF5Handle::m_group
private

◆ m_level

int HDF5Handle::m_level
private

◆ initialized

bool HDF5Handle::initialized
staticprivate

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