HDF5Handle Class Reference

#include <CH_HDF5.H>

List of all members.


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.

Public Types

enum  mode { CREATE, CREATE_SERIAL, OPEN_RDONLY, OPEN_RDWR }

Public Member Functions

 HDF5Handle ()
 { constructor}
 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}
bool isOpen () const
void close ()
void setGroupToLevel (int a_level)
 { Group functions}
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


Member Enumeration Documentation

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::HDF5Handle (  ) 

{ constructor}

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

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 ( const HDF5Handle  )  [private]


Member Function Documentation

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\

bool HDF5Handle::isOpen (  )  const

A NULL or failed constructed HDF5Handle will return false.

void HDF5Handle::close (  ) 

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

void HDF5Handle::setGroupToLevel ( int  a_level  ) 

{ Group functions}

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

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().

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.

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.

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().

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

References m_mode.

Referenced by write().

const hid_t& HDF5Handle::fileID (  )  const

const hid_t& HDF5Handle::groupID (  )  const

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

static void HDF5Handle::initialize (  )  [static, private]


Member Data Documentation

hid_t HDF5Handle::box_id [static]

hid_t HDF5Handle::intvect_id [static]

hid_t HDF5Handle::realvect_id [static]

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

hid_t HDF5Handle::m_fileID [private]

Referenced by openMode().

bool HDF5Handle::m_isOpen [private]

std::string HDF5Handle::m_filename [private]

std::string HDF5Handle::m_group [private]

int HDF5Handle::m_level [private]

bool HDF5Handle::initialized [static, private]


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

Generated on Fri Nov 24 03:27:10 2017 for Chombo + EB + MF by  doxygen 1.5.5