20 #include "SheafSystem/sheaf_file.h" 22 #include "SheafSystem/assert_contract.h" 23 #include "SheafSystem/file_data_type_map.h" 24 #include "SheafSystem/error_message.h" 32 const int HDF_FAIL = -1;
77 _hdf_id = xother._hdf_id;
79 _type_map = xother._type_map;
185 bool result =
dynamic_cast<const sheaf_file*
>(other) != 0;
206 require(!xname.empty());
220 _hdf_id = H5Fopen(_name.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
240 post_fatal_error_message(
"unable to open file in READ_ONLY mode");
252 _hdf_id = H5Fcreate(_name.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
271 post_fatal_error_message(
"unable to open file in READ_WRITE mode");
276 post_fatal_error_message(
"no clobber not yet implemented");
285 post_fatal_error_message(
"unrecognized access mode");
292 ensure(
name() == xname);
293 ensure(
mode() == xmode);
314 result = (_mode != NONE);
318 ensure(result == (
mode() != NONE));
369 herr_t lstatus = H5Fclose(_hdf_id);
373 post_fatal_error_message(
"failed to close file");
444 result = _type_map != 0;
virtual bool invariant() const
Class invariant.
virtual bool invariant() const
Class invariant, intended to be redefined in each descendant. See below for template for invariant in...
An encapsulation of an HDF file containing sheaf data.
A collection of data converters that map data types between internal and external representations ass...
virtual sheaf_file * clone() const
Virtual constructor; makes a new instance of the same type as this.
access_mode
File access modes.
data_type_map & type_map()
Data type map for primitive types in this file (mutable version)
Abstract base class with useful features for all objects.
bool is_open() const
True if this file is open.
access_mode mode() const
The current access mode.
std::string name() const
The name of this file.
void disable_invariant_check() const
Disable invariant check. Intended for preventing recursive calls to invariant and for suppressing inv...
void close()
Closes the file.
sheaf_file()
Default constructor.
bool type_map_defined() const
True if type map previously defined.
virtual ~sheaf_file()
Destructor.
bool invariant_check() const
True if invariant checking is enabled.
virtual bool is_ancestor_of(const any *other) const
Conformance test; true if other conforms to this.
void open(const std::string &xname, access_mode xmode=READ_WRITE, bool xclobber=true)
Opens a file with name xname, with access mode xmode. If xclobber and the file already exists...
A collection of data converters that map data types between internal and external representations...
bool is_same_type(const any *other) const
True if other is the same type as this.
void enable_invariant_check() const
Enable invariant checking.