diff options
-rw-r--r-- | c++/src/H5AbstractDs.cpp | 2 | ||||
-rw-r--r-- | c++/src/H5ArrayType.h | 3 | ||||
-rw-r--r-- | c++/src/H5AtomType.cpp | 18 | ||||
-rw-r--r-- | c++/src/H5AtomType.h | 3 | ||||
-rw-r--r-- | c++/src/H5Attribute.h | 3 | ||||
-rw-r--r-- | c++/src/H5CompType.h | 3 | ||||
-rw-r--r-- | c++/src/H5DataSet.h | 3 | ||||
-rw-r--r-- | c++/src/H5DataSpace.h | 3 | ||||
-rw-r--r-- | c++/src/H5DataType.cpp | 85 | ||||
-rw-r--r-- | c++/src/H5DataType.h | 4 | ||||
-rw-r--r-- | c++/src/H5DcreatProp.h | 3 | ||||
-rw-r--r-- | c++/src/H5DxferProp.h | 3 | ||||
-rw-r--r-- | c++/src/H5EnumType.h | 3 | ||||
-rw-r--r-- | c++/src/H5FaccProp.h | 3 | ||||
-rw-r--r-- | c++/src/H5FcreatProp.h | 3 | ||||
-rw-r--r-- | c++/src/H5File.cpp | 34 | ||||
-rw-r--r-- | c++/src/H5File.h | 4 | ||||
-rw-r--r-- | c++/src/H5FloatType.h | 3 | ||||
-rw-r--r-- | c++/src/H5Group.cpp | 27 | ||||
-rw-r--r-- | c++/src/H5Group.h | 4 | ||||
-rw-r--r-- | c++/src/H5IdComponent.cpp | 46 | ||||
-rw-r--r-- | c++/src/H5IdComponent.h | 33 | ||||
-rw-r--r-- | c++/src/H5IntType.h | 3 | ||||
-rw-r--r-- | c++/src/H5Object.cpp | 23 | ||||
-rw-r--r-- | c++/src/H5PredType.h | 3 | ||||
-rw-r--r-- | c++/src/H5PropList.cpp | 40 | ||||
-rw-r--r-- | c++/src/H5PropList.h | 3 | ||||
-rw-r--r-- | c++/src/H5StrType.h | 3 | ||||
-rw-r--r-- | c++/src/H5VarLenType.h | 3 |
29 files changed, 275 insertions, 96 deletions
diff --git a/c++/src/H5AbstractDs.cpp b/c++/src/H5AbstractDs.cpp index 1b3f7e9..c132dec 100644 --- a/c++/src/H5AbstractDs.cpp +++ b/c++/src/H5AbstractDs.cpp @@ -70,7 +70,7 @@ H5T_class_t AbstractDs::getTypeClass() const return( type_class ); else { - throw DataTypeIException("AbstractDs::getTypeClass", + throw DataTypeIException(inMemFunc("getTypeClass"), "H5Tget_class returns H5T_NO_CLASS"); } } diff --git a/c++/src/H5ArrayType.h b/c++/src/H5ArrayType.h index 3072a6a..46d9919 100644 --- a/c++/src/H5ArrayType.h +++ b/c++/src/H5ArrayType.h @@ -34,6 +34,9 @@ class H5_DLLCPP ArrayType : public DataType { // Returns the sizes of dimensions of this array datatype. int getArrayDims(hsize_t* dims); + // Returns this class name + virtual string fromClass () const { return ("ArrayType"); } + // Copy constructor: makes copy of the original object. ArrayType( const ArrayType& original ); diff --git a/c++/src/H5AtomType.cpp b/c++/src/H5AtomType.cpp index 321718e..ebfd287 100644 --- a/c++/src/H5AtomType.cpp +++ b/c++/src/H5AtomType.cpp @@ -66,7 +66,7 @@ void AtomType::setSize( size_t size ) const herr_t ret_value = H5Tset_size( id, size ); if( ret_value < 0 ) { - throw DataTypeIException("AtomType::setSize", "H5Tset_size failed"); + throw DataTypeIException(inMemFunc("setSize"), "H5Tset_size failed"); } } @@ -88,7 +88,7 @@ H5T_order_t AtomType::getOrder() const // return a byte order constant if successful if( type_order == H5T_ORDER_ERROR ) { - throw DataTypeIException("AtomType::getOrder", + throw DataTypeIException(inMemFunc("getOrder"), "H5Tget_order returns H5T_ORDER_ERROR"); } return( type_order ); @@ -142,7 +142,7 @@ void AtomType::setOrder( H5T_order_t order ) const herr_t ret_value = H5Tset_order( id, order ); if( ret_value < 0 ) { - throw DataTypeIException("AtomType::setOrder", "H5Tset_order failed"); + throw DataTypeIException(inMemFunc("setOrder"), "H5Tset_order failed"); } } @@ -164,7 +164,7 @@ size_t AtomType::getPrecision() const // returns number of significant bits if successful if( num_signi_bits == 0 ) { - throw DataTypeIException("AtomType::getPrecision", + throw DataTypeIException(inMemFunc("getPrecision"), "H5Tget_precision returns invalid number of significant bits"); } return( num_signi_bits ); @@ -186,7 +186,7 @@ void AtomType::setPrecision( size_t precision ) const herr_t ret_value = H5Tset_precision( id, precision ); if( ret_value < 0 ) { - throw DataTypeIException("AtomType::setPrecision", "H5Tset_precision failed"); + throw DataTypeIException(inMemFunc("setPrecision"), "H5Tset_precision failed"); } } @@ -211,7 +211,7 @@ int AtomType::getOffset() const // returns a non-negative offset value if successful if( offset == -1 ) { - throw DataTypeIException("AtomType::getOffset", + throw DataTypeIException(inMemFunc("getOffset"), "H5Tget_offset returns a negative offset value"); } return( offset ); @@ -233,7 +233,7 @@ void AtomType::setOffset( size_t offset ) const herr_t ret_value = H5Tset_offset( id, offset ); if( ret_value < 0 ) { - throw DataTypeIException("AtomType::setOffset", "H5Tset_offset failed"); + throw DataTypeIException(inMemFunc("setOffset"), "H5Tset_offset failed"); } } @@ -257,7 +257,7 @@ void AtomType::getPad( H5T_pad_t& lsb, H5T_pad_t& msb ) const herr_t ret_value = H5Tget_pad( id, &lsb, &msb ); if( ret_value < 0 ) { - throw DataTypeIException("AtomType::getPad", "H5Tget_pad failed"); + throw DataTypeIException(inMemFunc("getPad"), "H5Tget_pad failed"); } } @@ -280,7 +280,7 @@ void AtomType::setPad( H5T_pad_t lsb, H5T_pad_t msb ) const herr_t ret_value = H5Tset_pad( id, lsb, msb ); if( ret_value < 0 ) { - throw DataTypeIException("AtomType::setPad", "H5Tset_pad failed"); + throw DataTypeIException(inMemFunc("setPad"), "H5Tset_pad failed"); } } diff --git a/c++/src/H5AtomType.h b/c++/src/H5AtomType.h index b721644..d8a89c5 100644 --- a/c++/src/H5AtomType.h +++ b/c++/src/H5AtomType.h @@ -55,6 +55,9 @@ class H5_DLLCPP AtomType : public DataType { // Sets the total size for an atomic datatype. void setSize( size_t size ) const; + // Returns this class name + virtual string fromClass () const { return("AtomType"); } + // Copy constructor - makes copy of the original object AtomType( const AtomType& original ); diff --git a/c++/src/H5Attribute.h b/c++/src/H5Attribute.h index 0d50006..89dba65 100644 --- a/c++/src/H5Attribute.h +++ b/c++/src/H5Attribute.h @@ -41,6 +41,9 @@ class H5_DLLCPP Attribute : public AbstractDs { void write(const DataType& mem_type, const void *buf ) const; void write(const DataType& mem_type, const string& strg ) const; + // Returns this class name + virtual string fromClass () const { return("Attribute"); } + // Creates a copy of an existing attribute using the attribute id Attribute( const hid_t attr_id ); diff --git a/c++/src/H5CompType.h b/c++/src/H5CompType.h index 637592b..54cc7e0 100644 --- a/c++/src/H5CompType.h +++ b/c++/src/H5CompType.h @@ -90,6 +90,9 @@ class H5_DLLCPP CompType : public DataType { // Recursively removes padding from within this compound datatype. void pack() const; + // Returns this class name + virtual string fromClass () const { return("CompType"); } + // Default constructor CompType(); diff --git a/c++/src/H5DataSet.h b/c++/src/H5DataSet.h index 7c75ce6..7fc156b 100644 --- a/c++/src/H5DataSet.h +++ b/c++/src/H5DataSet.h @@ -79,6 +79,9 @@ class H5_DLLCPP DataSet : public AbstractDs { // Creates a reference to a named Hdf5 object in this object. void* Reference(const char* name) const; + // Returns this class name + virtual string fromClass () const { return("DataSet"); } + // Creates a copy of an existing DataSet using its id. DataSet(const hid_t existing_id); diff --git a/c++/src/H5DataSpace.h b/c++/src/H5DataSpace.h index d5a71c5..cb04baa 100644 --- a/c++/src/H5DataSpace.h +++ b/c++/src/H5DataSpace.h @@ -99,6 +99,9 @@ class H5_DLLCPP DataSpace : public IdComponent { // Sets or resets the size of this dataspace. void setExtentSimple( int rank, const hsize_t *current_size, const hsize_t *maximum_size = NULL ) const; + // Returns this class name + virtual string fromClass () const { return("DataSpace"); } + // Creates a DataSpace object using an existing dataspace id. DataSpace(const hid_t space_id); diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp index 63e3376..8f60428 100644 --- a/c++/src/H5DataType.cpp +++ b/c++/src/H5DataType.cpp @@ -107,7 +107,7 @@ void DataType::copy( const DataType& like_type ) decRefCount(); } catch (Exception close_error) { - throw DataTypeIException("DataType::copy", close_error.getDetailMsg()); + throw DataTypeIException(inMemFunc("copy"), close_error.getDetailMsg()); } } @@ -115,7 +115,7 @@ void DataType::copy( const DataType& like_type ) id = H5Tcopy( like_type.getId() ); if( id < 0 ) - throw DataTypeIException("DataType::copy", "H5Tcopy failed"); + throw DataTypeIException(inMemFunc("copy"), "H5Tcopy failed"); } //-------------------------------------------------------------------------- @@ -155,7 +155,7 @@ bool DataType::operator==(const DataType& compared_type ) const return false; else { - throw DataTypeIException("DataType::operator==", + throw DataTypeIException(inMemFunc("operator=="), "H5Tequal returns negative value"); } } @@ -177,7 +177,7 @@ void DataType::commit(CommonFG& loc, const char* name) const herr_t ret_value = H5Tcommit( loc_id, name, id ); if( ret_value < 0 ) { - throw DataTypeIException("DataType::commit", "H5Tcommit failed"); + throw DataTypeIException(inMemFunc("commit"), "H5Tcommit failed"); } } @@ -211,7 +211,7 @@ bool DataType::committed() const return false; else { - throw DataTypeIException("DataType::committed", "H5Tcommitted return negative value"); + throw DataTypeIException(inMemFunc("committed"), "H5Tcommitted return negative value"); } } @@ -231,7 +231,7 @@ H5T_conv_t DataType::find( const DataType& dest, H5T_cdata_t **pcdata ) const H5T_conv_t func = H5Tfind( id, dest.getId(), pcdata ); if( func == NULL ) { - throw DataTypeIException("DataType::find", "H5Tfind returns a NULL function"); + throw DataTypeIException(inMemFunc("find"), "H5Tfind returns a NULL function"); } return( func ); } @@ -260,7 +260,7 @@ void DataType::convert( const DataType& dest, size_t nelmts, void *buf, void *ba ret_value = H5Tconvert( id, dest_id, nelmts, buf, background, plist_id ); if( ret_value < 0 ) { - throw DataTypeIException("DataType::convert", "H5Tconvert failed"); + throw DataTypeIException(inMemFunc("convert"), "H5Tconvert failed"); } } @@ -271,7 +271,7 @@ void DataType::setOverflow( H5T_overflow_t func ) const herr_t ret_value = H5Tset_overflow( func ); if( ret_value < 0 ) { - throw DataTypeIException("DataType::setOverflow", "H5Tset_overflow failed"); + throw DataTypeIException(inMemFunc("setOverflow"), "H5Tset_overflow failed"); } } @@ -302,7 +302,7 @@ void DataType::lock() const herr_t ret_value = H5Tlock( id ); if( ret_value < 0 ) { - throw DataTypeIException("DataType::lock", "H5Tlock failed"); + throw DataTypeIException(inMemFunc("lock"), "H5Tlock failed"); } } @@ -320,7 +320,7 @@ H5T_class_t DataType::getClass() const // Return datatype class identifier if successful if( type_class == H5T_NO_CLASS ) { - throw DataTypeIException("DataType::getClass", + throw DataTypeIException(inMemFunc("getClass"), "H5Tget_class returns H5T_NO_CLASS"); } return( type_class ); @@ -339,7 +339,7 @@ size_t DataType::getSize() const size_t type_size = H5Tget_size( id ); if( type_size <= 0 ) // valid data types are never zero size { - throw DataTypeIException("DataType::getSize", + throw DataTypeIException(inMemFunc("getSize"), "H5Tget_size returns invalid datatype size"); } return( type_size ); @@ -367,7 +367,7 @@ DataType DataType::getSuper() const } else { - throw DataTypeIException("DataType::getSuper", "H5Tget_super failed"); + throw DataTypeIException(inMemFunc("getSuper"), "H5Tget_super failed"); } } @@ -395,7 +395,7 @@ void DataType::registerFunc( H5T_pers_t pers, const char* name, const DataType& herr_t ret_value = H5Tregister( pers, name, id, dest_id, func ); if( ret_value < 0 ) { - throw DataTypeIException("DataType::registerFunc", "H5Tregister failed"); + throw DataTypeIException(inMemFunc("registerFunc"), "H5Tregister failed"); } } @@ -432,7 +432,7 @@ void DataType::unregister( H5T_pers_t pers, const char* name, const DataType& de herr_t ret_value = H5Tunregister( pers, name, id, dest_id, func ); if( ret_value < 0 ) { - throw DataTypeIException("DataType::unregister", "H5Tunregister failed"); + throw DataTypeIException(inMemFunc("unregister"), "H5Tunregister failed"); } } @@ -462,7 +462,7 @@ void DataType::setTag( const char* tag ) const herr_t ret_value = H5Tset_tag( id, tag ); if( ret_value < 0 ) { - throw DataTypeIException("DataType::setTag", "H5Tset_tag failed"); + throw DataTypeIException(inMemFunc("setTag"), "H5Tset_tag failed"); } } @@ -499,7 +499,7 @@ string DataType::getTag() const } else { - throw DataTypeIException("DataType::getTag", + throw DataTypeIException(inMemFunc("getTag"), "H5Tget_tag returns NULL for tag"); } } @@ -522,7 +522,7 @@ bool DataType::detectClass(H5T_class_t cls) const return false; else { - throw DataTypeIException("DataType::detectClass", + throw DataTypeIException(inMemFunc("detectClass"), "H5Tdetect_class returns negative value"); } } @@ -544,7 +544,7 @@ bool DataType::isVariableStr() const return false; else { - throw DataTypeIException("DataType::isVariableStr", + throw DataTypeIException(inMemFunc("isVariableStr"), "H5Tis_variable_str returns negative value"); } } @@ -561,7 +561,12 @@ bool DataType::isVariableStr() const //-------------------------------------------------------------------------- void* DataType::Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_type) const { - return(p_reference(name, dataspace.getId(), ref_type)); + try { + return(p_reference(name, dataspace.getId(), ref_type)); + } + catch (IdComponentException E) { + throw DataTypeIException(inMemFunc("Reference"), E.getDetailMsg()); + } } //-------------------------------------------------------------------------- @@ -580,7 +585,25 @@ void* DataType::Reference(const char* name, DataSpace& dataspace, H5R_type_t ref //-------------------------------------------------------------------------- void* DataType::Reference(const char* name) const { - return(p_reference(name, -1, H5R_OBJECT)); + try { + return(p_reference(name, -1, H5R_OBJECT)); + } + catch (IdComponentException E) { + throw DataTypeIException(inMemFunc("Reference"), E.getDetailMsg()); + } +} + +//-------------------------------------------------------------------------- +// Function: DataType::Reference +///\brief This is an overloaded function, provided for your convenience. +/// It differs from the above function in that it takes an +/// \c std::string for the object's name. +///\param name - IN: Name of the object to be referenced - \c std::string +// Programmer Binh-Minh Ribler - May, 2004 +//-------------------------------------------------------------------------- +void* DataType::Reference(const string& name) const +{ + return(Reference(name.c_str())); } //-------------------------------------------------------------------------- @@ -598,7 +621,12 @@ void* DataType::Reference(const char* name) const //-------------------------------------------------------------------------- H5G_obj_t DataType::getObjType(void *ref, H5R_type_t ref_type) const { - return(p_get_obj_type(ref, ref_type)); + try { + return(p_get_obj_type(ref, ref_type)); + } + catch (IdComponentException E) { + throw DataTypeIException(inMemFunc("getObjType"), E.getDetailMsg()); + } } //-------------------------------------------------------------------------- @@ -612,8 +640,13 @@ H5G_obj_t DataType::getObjType(void *ref, H5R_type_t ref_type) const //-------------------------------------------------------------------------- DataSpace DataType::getRegion(void *ref, H5R_type_t ref_type) const { - DataSpace dataspace(p_get_region(ref, ref_type)); - return(dataspace); + try { + DataSpace dataspace(p_get_region(ref, ref_type)); + return(dataspace); + } + catch (IdComponentException E) { + throw DataTypeIException(inMemFunc("getRegion"), E.getDetailMsg()); + } } //-------------------------------------------------------------------------- @@ -631,13 +664,13 @@ void DataType::close() herr_t ret_value = H5Tclose(id); if( ret_value < 0 ) { - throw DataTypeIException("DataType::close", "H5Tclose failed"); + throw DataTypeIException(inMemFunc("close"), "H5Tclose failed"); } // reset the id because the datatype that it represents is now closed id = 0; } else // cannot close a predefined type - throw DataTypeIException("DataType::close", "Cannot close a predefined type"); + throw DataTypeIException(inMemFunc("close"), "Cannot close a predefined type"); } //-------------------------------------------------------------------------- @@ -656,7 +689,7 @@ DataType::~DataType() decRefCount(); } catch (Exception close_error) { - cerr << "DataType::~DataType - " << close_error.getDetailMsg() << endl; + cerr << inMemFunc("~DataType - ") << close_error.getDetailMsg() << endl; } } } diff --git a/c++/src/H5DataType.h b/c++/src/H5DataType.h index b82fdc1..f4bf0a4 100644 --- a/c++/src/H5DataType.h +++ b/c++/src/H5DataType.h @@ -98,6 +98,7 @@ class H5_DLLCPP DataType : public H5Object { // Creates a reference to a named Hdf5 object in this object. void* Reference(const char* name) const; + void* Reference(const string& name) const; // Creates a reference to a named Hdf5 object or to a dataset region // in this object. @@ -109,6 +110,9 @@ class H5_DLLCPP DataType : public H5Object { // Retrieves a dataspace with the region pointed to selected. DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const; + // Returns this class name + virtual string fromClass () const { return("DataType"); } + // Creates a copy of an existing DataType using its id DataType( const hid_t type_id, bool predtype = false ); diff --git a/c++/src/H5DcreatProp.h b/c++/src/H5DcreatProp.h index 7028123..b7b7aaf 100644 --- a/c++/src/H5DcreatProp.h +++ b/c++/src/H5DcreatProp.h @@ -100,6 +100,9 @@ class H5_DLLCPP DSetCreatPropList : public PropList { // Sets method of the shuffle filter. void setShuffle(); + // Returns this class name + virtual string fromClass () const { return("DSetCreatPropList"); } + // Default constructor: creates a stub dataset creation property list. DSetCreatPropList(); diff --git a/c++/src/H5DxferProp.h b/c++/src/H5DxferProp.h index 00cff3c..dfab7bb 100644 --- a/c++/src/H5DxferProp.h +++ b/c++/src/H5DxferProp.h @@ -97,6 +97,9 @@ class H5_DLLCPP DSetMemXferPropList : public PropList { // Determines whether error-detection is enabled for dataset reads. H5Z_EDC_t getEDCCheck(); + // Returns this class name + virtual string fromClass () const { return("DSetMemXferPropList"); } + // Default constructor: creates a dataset memory and transfer prop list. DSetMemXferPropList(); diff --git a/c++/src/H5EnumType.h b/c++/src/H5EnumType.h index c7f3d26..9b38fa4 100644 --- a/c++/src/H5EnumType.h +++ b/c++/src/H5EnumType.h @@ -56,6 +56,9 @@ class H5_DLLCPP EnumType : public DataType { void valueOf( const char* name, void *value ) const; void valueOf( const string& name, void *value ) const; + // Returns this class name + virtual string fromClass () const { return("EnumType"); } + // Default constructor EnumType(); diff --git a/c++/src/H5FaccProp.h b/c++/src/H5FaccProp.h index 1e22e5a..38da7e3 100644 --- a/c++/src/H5FaccProp.h +++ b/c++/src/H5FaccProp.h @@ -119,6 +119,9 @@ class H5_DLLCPP FileAccPropList : public PropList { // Returns garbage collecting references setting. unsigned getGcReferences() const; + // Returns this class name + virtual string fromClass () const { return("FileAccPropList"); } + // Creates a file access property list. FileAccPropList(); diff --git a/c++/src/H5FcreatProp.h b/c++/src/H5FcreatProp.h index f3bbf4e..e167a19 100644 --- a/c++/src/H5FcreatProp.h +++ b/c++/src/H5FcreatProp.h @@ -65,6 +65,9 @@ class H5_DLLCPP FileCreatPropList : public PropList { // indexing chunked datasets. void setIstorek( unsigned ik ) const; + // Returns this class name + virtual string fromClass () const { return("FileCreatPropList"); } + // Creates a file create property list. FileCreatPropList(); diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp index 868adf9..a904871 100644 --- a/c++/src/H5File.cpp +++ b/c++/src/H5File.cpp @@ -427,7 +427,12 @@ void H5File::getVFDHandle(void **file_handle) const //-------------------------------------------------------------------------- string H5File::getFileName() const { - return(p_get_file_name()); + try { + return(p_get_file_name()); + } + catch (IdComponentException E) { + throw FileIException("H5File::getFileName", E.getDetailMsg()); + } } //-------------------------------------------------------------------------- @@ -444,7 +449,12 @@ string H5File::getFileName() const //-------------------------------------------------------------------------- void* H5File::Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_type) const { - return(p_reference(name, dataspace.getId(), ref_type)); + try { + return(p_reference(name, dataspace.getId(), ref_type)); + } + catch (IdComponentException E) { + throw FileIException("H5File::Reference", E.getDetailMsg()); + } } //-------------------------------------------------------------------------- @@ -466,7 +476,25 @@ void* H5File::Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_t //-------------------------------------------------------------------------- void* H5File::Reference(const char* name) const { - return(p_reference(name, -1, H5R_OBJECT)); + try { + return(p_reference(name, -1, H5R_OBJECT)); + } + catch (IdComponentException E) { + throw FileIException("H5File::Reference", E.getDetailMsg()); + } +} + +//-------------------------------------------------------------------------- +// Function: H5File::Reference +///\brief This is an overloaded function, provided for your convenience. +/// It differs from the above function in that it takes an +/// \c std::string for the object's name. +///\param name - IN: Name of the object to be referenced - \c std::string +// Programmer Binh-Minh Ribler - May, 2004 +//-------------------------------------------------------------------------- +void* H5File::Reference(const string& name) const +{ + return(Reference(name.c_str())); } //-------------------------------------------------------------------------- diff --git a/c++/src/H5File.h b/c++/src/H5File.h index 54c50fd..d1d29bd 100644 --- a/c++/src/H5File.h +++ b/c++/src/H5File.h @@ -81,6 +81,10 @@ class H5_DLLCPP H5File : public IdComponent, public CommonFG { // Creates a reference to a named Hdf5 object in this object. void* Reference(const char* name) const; + void* Reference(const string& name) const; + + // Returns this class name + virtual string fromClass () const { return ("H5File"); } // Throw file exception. virtual void throwException(const string func_name, const string msg) const; diff --git a/c++/src/H5FloatType.h b/c++/src/H5FloatType.h index 1b5df67..8cd4a69 100644 --- a/c++/src/H5FloatType.h +++ b/c++/src/H5FloatType.h @@ -52,6 +52,9 @@ class H5_DLLCPP FloatType : public AtomType { // Sets the mantissa normalization of a floating-point datatype. void setNorm( H5T_norm_t norm ) const; + // Returns this class name + virtual string fromClass () const { return ("FloatType"); } + // Default constructor FloatType(); diff --git a/c++/src/H5Group.cpp b/c++/src/H5Group.cpp index cb0bfc4..8a6f30e 100644 --- a/c++/src/H5Group.cpp +++ b/c++/src/H5Group.cpp @@ -86,7 +86,12 @@ Group::Group( const hid_t group_id ) : H5Object( group_id ) {} //-------------------------------------------------------------------------- void* Group::Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_type) const { - return(p_reference(name, dataspace.getId(), ref_type)); + try { + return(p_reference(name, dataspace.getId(), ref_type)); + } + catch (IdComponentException E) { + throw GroupIException("Group::Reference", E.getDetailMsg()); + } } //-------------------------------------------------------------------------- @@ -105,7 +110,25 @@ void* Group::Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_ty //-------------------------------------------------------------------------- void* Group::Reference(const char* name) const { - return(p_reference(name, -1, H5R_OBJECT)); + try { + return(p_reference(name, -1, H5R_OBJECT)); + } + catch (IdComponentException E) { + throw GroupIException("Group::Reference", E.getDetailMsg()); + } +} + +//-------------------------------------------------------------------------- +// Function: Group::Reference +///\brief This is an overloaded function, provided for your convenience. +/// It differs from the above function in that it takes an +/// \c std::string for the object's name. +///\param name - IN: Name of the object to be referenced +// Programmer Binh-Minh Ribler - May, 2004 +//-------------------------------------------------------------------------- +void* Group::Reference(const string& name) const +{ + return(Reference(name.c_str())); } //-------------------------------------------------------------------------- diff --git a/c++/src/H5Group.h b/c++/src/H5Group.h index a95f53d..74bd665 100644 --- a/c++/src/H5Group.h +++ b/c++/src/H5Group.h @@ -37,6 +37,10 @@ class H5_DLLCPP Group : public H5Object, public CommonFG { // Creates a reference to a named Hdf5 object in this object. void* Reference(const char* name) const; + void* Reference(const string& name) const; + + // Returns this class name + virtual string fromClass () const { return ("Group"); } // Throw group exception. virtual void throwException(const string func_name, const string msg) const; diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp index acb3a31..f0400fb 100644 --- a/c++/src/H5IdComponent.cpp +++ b/c++/src/H5IdComponent.cpp @@ -53,7 +53,7 @@ void IdComponent::incRefCount(hid_t obj_id) const { if (p_valid_id(obj_id)) if (H5Iinc_ref(obj_id) < 0) - throw IdComponentException("IdComponent::incRefCount", "incrementing object ref count failed"); + throw IdComponentException(inMemFunc("incRefCount"), "incrementing object ref count failed"); } //-------------------------------------------------------------------------- @@ -79,10 +79,10 @@ void IdComponent::decRefCount(hid_t obj_id) const if (p_valid_id(obj_id)) if (H5Idec_ref(obj_id) < 0) if (H5Iget_ref(obj_id) <= 0) - throw IdComponentException("IdComponent::decRefCount", + throw IdComponentException(inMemFunc("decRefCount"), "object ref count is 0 or negative"); else - throw IdComponentException("IdComponent::decRefCount", + throw IdComponentException(inMemFunc("decRefCount"), "decrementing object ref count failed"); } @@ -109,7 +109,7 @@ int IdComponent::getCounter(hid_t obj_id) const { counter = H5Iget_ref(obj_id); if (counter < 0) - throw IdComponentException("IdComponent::incRefCount", "incrementing object ref count failed"); + throw IdComponentException(inMemFunc("incRefCount"), "incrementing object ref count failed"); } return (counter); } @@ -218,7 +218,8 @@ IdComponent::~IdComponent() { } // -// Implementation of protected functions for HDF5 Reference Interface. +// Implementation of protected functions for HDF5 Reference Interface +// and miscelaneous helpers. // #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -247,8 +248,7 @@ string IdComponent::p_get_file_name() const // If H5Aget_name returns a negative value, raise an exception, if( name_size < 0 ) { - throw IdComponentException("IdComponent::p_get_file_name", - "H5Fget_name failed"); + throw IdComponentException("", "H5Fget_name failed"); } // Call H5Fget_name again to get the actual file name @@ -258,8 +258,7 @@ string IdComponent::p_get_file_name() const // Check for failure again if( name_size < 0 ) { - throw IdComponentException("IdComponent::p_get_file_name", - "H5Fget_name failed"); + throw IdComponentException("", "H5Fget_name failed"); } // Convert the C file name and return @@ -285,8 +284,7 @@ void* IdComponent::p_reference(const char* name, hid_t space_id, H5R_type_t ref_ herr_t ret_value = H5Rcreate(ref, id, name, ref_type, space_id); if (ret_value < 0) { - throw IdComponentException("IdComponent::p_reference", - "H5Rcreate failed"); + throw IdComponentException("", "H5Rcreate failed"); } return(ref); } @@ -310,8 +308,7 @@ H5G_obj_t IdComponent::p_get_obj_type(void *ref, H5R_type_t ref_type) const H5G_obj_t obj_type = H5Rget_obj_type(id, ref_type, ref); if (obj_type == H5G_UNKNOWN) { - throw IdComponentException("IdComponent::p_get_obj_type", - "H5R_get_obj_type failed"); + throw IdComponentException("", "H5R_get_obj_type failed"); } return(obj_type); } @@ -332,8 +329,7 @@ hid_t IdComponent::p_get_region(void *ref, H5R_type_t ref_type) const hid_t space_id = H5Rget_region(id, ref_type, ref); if (space_id < 0) { - throw IdComponentException("IdComponent::p_get_region", - "H5Rget_region failed"); + throw IdComponentException("", "H5Rget_region failed"); } return(space_id); } @@ -358,6 +354,26 @@ bool IdComponent::p_valid_id(hid_t obj_id) const return true; } +//-------------------------------------------------------------------------- +// Function: IdComponent::inMemFunc +///\brief Makes and returns string "<class-name>::<func_name>" +///\param func_name - Name of the function where failure occurs +// Description +/// Concatenates the class name of this object with the +/// passed-in function name to create a string that indicates +/// where the failure occurs. The class-name is provided by +/// fromClass(). This string will be used by a base class when +/// an exception is thrown. +// Programmer Binh-Minh Ribler - Oct 10, 2005 +//-------------------------------------------------------------------------- +string IdComponent::inMemFunc(const char* func_name) const +{ + string full_name = func_name; + full_name.insert(0, "::"); + full_name.insert(0, fromClass()); + return (full_name); +} + #endif // DOXYGEN_SHOULD_SKIP_THIS #ifndef H5_NO_NAMESPACE diff --git a/c++/src/H5IdComponent.h b/c++/src/H5IdComponent.h index 7ce0c87..7a54c80 100644 --- a/c++/src/H5IdComponent.h +++ b/c++/src/H5IdComponent.h @@ -1,8 +1,8 @@ // C++ informative line for the emacs editor: -*- C++ -*- /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by the Board of Trustees of the University of Illinois. * - * All rights reserved. * - * * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * @@ -21,6 +21,9 @@ #ifndef H5_NO_NAMESPACE namespace H5 { +#ifndef H5_NO_STD + using std::string; +#endif // H5_NO_STD #endif class H5_DLLCPP IdComponent { @@ -56,8 +59,16 @@ class H5_DLLCPP IdComponent { // Pure virtual function for there are various H5*close for the // subclasses. virtual void close() = 0; + #endif // DOXYGEN_SHOULD_SKIP_THIS + // Makes and returns the string "<class-name>::<func_name>"; + // <class-name> is returned by fromClass(). + string inMemFunc(const char* func_name) const; + + // Returns this class name. + virtual string fromClass() const {return ("IdComponent");} + // Destructor virtual ~IdComponent(); @@ -75,17 +86,17 @@ class H5_DLLCPP IdComponent { string p_get_file_name() const; #endif // H5_NO_STD - // Gets the id of the H5 file in which the given object is located. - hid_t p_get_file_id(); + // Gets the id of the H5 file in which the given object is located. + hid_t p_get_file_id(); - // Creates a reference to an HDF5 object or a dataset region. - void* p_reference(const char* name, hid_t space_id, H5R_type_t ref_type) const; + // Creates a reference to an HDF5 object or a dataset region. + void* p_reference(const char* name, hid_t space_id, H5R_type_t ref_type) const; - // Retrieves the type of object that an object reference points to. - H5G_obj_t p_get_obj_type(void *ref, H5R_type_t ref_type) const; + // Retrieves the type of object that an object reference points to. + H5G_obj_t p_get_obj_type(void *ref, H5R_type_t ref_type) const; - // Retrieves a dataspace with the region pointed to selected. - hid_t p_get_region(void *ref, H5R_type_t ref_type) const; + // Retrieves a dataspace with the region pointed to selected. + hid_t p_get_region(void *ref, H5R_type_t ref_type) const; // Verifies that the given id is valid. bool p_valid_id(hid_t obj_id) const; diff --git a/c++/src/H5IntType.h b/c++/src/H5IntType.h index c8d64df..b04fecd 100644 --- a/c++/src/H5IntType.h +++ b/c++/src/H5IntType.h @@ -33,6 +33,9 @@ class H5_DLLCPP IntType : public AtomType { // Sets the sign proprety for an integer type. void setSign( H5T_sign_t sign ) const; + // Returns this class name + virtual string fromClass () const { return ("IntType"); } + // Default constructor IntType(); diff --git a/c++/src/H5Object.cpp b/c++/src/H5Object.cpp index 1697737..1c45730 100644 --- a/c++/src/H5Object.cpp +++ b/c++/src/H5Object.cpp @@ -111,7 +111,7 @@ Attribute H5Object::createAttribute( const char* name, const DataType& data_type } else { - throw AttributeIException("H5Object::createAttribute", "H5Acreate failed"); + throw AttributeIException(inMemFunc("createAttribute"), "H5Acreate failed"); } } @@ -145,7 +145,7 @@ Attribute H5Object::openAttribute( const char* name ) const } else { - throw AttributeIException("H5Object::openAttribute", "H5Aopen_name failed"); + throw AttributeIException(inMemFunc("openAttribute"), "H5Aopen_name failed"); } } @@ -179,7 +179,7 @@ Attribute H5Object::openAttribute( const unsigned int idx ) const } else { - throw AttributeIException("H5Object::openAttribute", "H5Aopen_idx failed"); + throw AttributeIException(inMemFunc("openAttribute"), "H5Aopen_idx failed"); } } @@ -217,7 +217,7 @@ int H5Object::iterateAttrs( attr_operator_t user_op, unsigned * idx, void *op_da return( ret_value ); else // raise exception when H5Aiterate returns a negative value { - throw AttributeIException("H5Object::iterateAttrs", "H5Aiterate failed"); + throw AttributeIException(inMemFunc("iterateAttrs"), "H5Aiterate failed"); } } @@ -233,7 +233,7 @@ int H5Object::getNumAttrs() const int num_attrs = H5Aget_num_attrs( id ); if( num_attrs < 0 ) { - throw AttributeIException("H5Object::getNumAttrs", + throw AttributeIException(inMemFunc("getNumAttrs"), "H5Aget_num_attrs failed - returned negative number of attributes"); } else @@ -252,7 +252,7 @@ void H5Object::removeAttr( const char* name ) const herr_t ret_value = H5Adelete( id, name ); if( ret_value < 0 ) { - throw AttributeIException("H5Object::removeAttr", "H5Adelete failed"); + throw AttributeIException(inMemFunc("removeAttr"), "H5Adelete failed"); } } @@ -281,7 +281,7 @@ void H5Object::renameAttr(const char* oldname, const char* newname) const herr_t ret_value = H5Arename(id, oldname, newname); if (ret_value < 0) { - throw AttributeIException("H5Object::renameAttr", "H5Arename failed"); + throw AttributeIException(inMemFunc("renameAttr"), "H5Arename failed"); } } @@ -314,7 +314,7 @@ void H5Object::flush(H5F_scope_t scope ) const herr_t ret_value = H5Fflush( id, scope ); if( ret_value < 0 ) { - throw FileIException("H5Object::flush", "H5Fflush failed"); + throw FileIException(inMemFunc("flush"), "H5Fflush failed"); } } @@ -327,7 +327,12 @@ void H5Object::flush(H5F_scope_t scope ) const //-------------------------------------------------------------------------- string H5Object::getFileName() const { - return(p_get_file_name()); + try { + return(p_get_file_name()); + } + catch (IdComponentException E) { + throw FileIException(inMemFunc("getFileName"), E.getDetailMsg()); + } } //-------------------------------------------------------------------------- diff --git a/c++/src/H5PredType.h b/c++/src/H5PredType.h index 9bf14cc..301a76b 100644 --- a/c++/src/H5PredType.h +++ b/c++/src/H5PredType.h @@ -27,6 +27,9 @@ namespace H5 { class H5_DLLCPP PredType : public AtomType { public: + // Returns this class name + virtual string fromClass () const { return ("PredType"); } + // Makes a copy of the predefined type and stores the new // id in the left hand side object. PredType& operator=( const PredType& rhs ); diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp index c27a4fd..2b0458e 100644 --- a/c++/src/H5PropList.cpp +++ b/c++/src/H5PropList.cpp @@ -98,14 +98,14 @@ void PropList::copy( const PropList& like_plist ) decRefCount(); } catch (Exception close_error) { - throw PropListIException("PropList::copy", close_error.getDetailMsg()); + throw PropListIException(inMemFunc("copy"), close_error.getDetailMsg()); } // call C routine to copy the property list id = H5Pcopy( like_plist.getId() ); if( id < 0 ) - throw PropListIException("PropList::copy", "H5Pcopy failed"); + throw PropListIException(inMemFunc("copy"), "H5Pcopy failed"); } //-------------------------------------------------------------------------- @@ -139,7 +139,7 @@ void PropList::copyProp(PropList& dest, const char *name) const herr_t ret_value = H5Pcopy_prop(dst_id, id, name); if( ret_value < 0 ) { - throw PropListIException("PropList::copyProp", "H5Pcopy_prop failed"); + throw PropListIException(inMemFunc("copyProp"), "H5Pcopy_prop failed"); } } @@ -174,7 +174,7 @@ void PropList::copyProp( PropList& dest, PropList& src, const char *name ) const herr_t ret_value = H5Pcopy_prop(dst_id, src_id, name); if( ret_value < 0 ) { - throw PropListIException("PropList::copyProp", "H5Pcopy_prop failed"); + throw PropListIException(inMemFunc("copyProp"), "H5Pcopy_prop failed"); } } @@ -208,13 +208,13 @@ void PropList::close() herr_t ret_value = H5Pclose( id ); if( ret_value < 0 ) { - throw PropListIException("PropList::close", "H5Pclose failed"); + throw PropListIException(inMemFunc("close"), "H5Pclose failed"); } // reset the id because the property list that it represents is now closed id = 0; } else - throw PropListIException("PropList::close", "Cannot close a constant"); + throw PropListIException(inMemFunc("close"), "Cannot close a constant"); } //-------------------------------------------------------------------------- @@ -229,7 +229,7 @@ hid_t PropList::getClass() const hid_t plist_class = H5Pget_class( id ); if( plist_class == H5P_NO_CLASS ) { - throw PropListIException("PropList::getClass", + throw PropListIException(inMemFunc("getClass"), "H5Pget_class failed - returned H5P_NO_CLASS"); } return( plist_class ); @@ -259,7 +259,7 @@ bool PropList::propExist(const char* name ) const return false; else // Raise exception when H5Pexist returns a negative value { - throw PropListIException("PropList::propExist", "H5Pexist failed"); + throw PropListIException(inMemFunc("propExist"), "H5Pexist failed"); } } //-------------------------------------------------------------------------- @@ -290,7 +290,7 @@ void PropList::closeClass() const herr_t ret_value = H5Pclose_class(id); if( ret_value < 0 ) { - throw PropListIException("PropList::closeClass", "H5Pclose_class failed"); + throw PropListIException(inMemFunc("closeClass"), "H5Pclose_class failed"); } } @@ -311,7 +311,7 @@ void PropList::getProperty(const char* name, void* value) const herr_t ret_value = H5Pget(id, name, value); if (ret_value < 0) { - throw PropListIException("PropList::getProperty", "H5Pget failed"); + throw PropListIException(inMemFunc("getProperty"), "H5Pget failed"); } } //-------------------------------------------------------------------------- @@ -333,7 +333,7 @@ string PropList::getProperty(const char* name) const // Throw exception if H5Pget returns failure if (ret_value < 0) { - throw PropListIException("PropList::getProperty", "H5Pget failed"); + throw PropListIException(inMemFunc("getProperty"), "H5Pget failed"); } // Return propety value as a string after deleting temp C-string @@ -387,7 +387,7 @@ size_t PropList::getPropSize(const char *name) const herr_t ret_value = H5Pget_size(id, name, &prop_size); if (ret_value < 0) { - throw PropListIException("PropList::getPropSize", "H5Pget_size failed"); + throw PropListIException(inMemFunc("getPropSize"), "H5Pget_size failed"); } return(prop_size); } @@ -439,7 +439,7 @@ size_t PropList::getNumProps() const herr_t ret_value = H5Pget_nprops (id, &nprops); if (ret_value < 0) { - throw PropListIException("PropList::getNumProps", "H5Pget_nprops failed"); + throw PropListIException(inMemFunc("getNumProps"), "H5Pget_nprops failed"); } return (nprops); } @@ -457,7 +457,7 @@ void PropList::setProperty(const char* name, void* value) const herr_t ret_value = H5Pset(id, name, value); if (ret_value < 0) { - throw PropListIException("PropList::setProperty", "H5Pset failed"); + throw PropListIException(inMemFunc("setProperty"), "H5Pset failed"); } } //-------------------------------------------------------------------------- @@ -474,7 +474,7 @@ void PropList::setProperty(const char* name, const char* charptr) const herr_t ret_value = H5Pset(id, name, (void*) charptr); if (ret_value < 0) { - throw PropListIException("PropList::setProperty", "H5Pset failed"); + throw PropListIException(inMemFunc("setProperty"), "H5Pset failed"); } } //-------------------------------------------------------------------------- @@ -537,7 +537,7 @@ bool PropList::isAClass(const PropList& prop_class) const return false; else // Raise exception when H5Pisa_class returns a negative value { - throw PropListIException("PropList::isAClass", "H5Pisa_class failed"); + throw PropListIException(inMemFunc("isAClass"), "H5Pisa_class failed"); } } @@ -554,7 +554,7 @@ void PropList::removeProp(const char *name) const herr_t ret_value = H5Premove(id, name); if (ret_value < 0) { - throw PropListIException("PropList::removeProp", "H5Premove failed"); + throw PropListIException(inMemFunc("removeProp"), "H5Premove failed"); } } @@ -589,7 +589,7 @@ bool PropList::operator==(const PropList& rhs) const return false; else // Raise exception when H5Pequal returns a negative value { - throw PropListIException("PropList::operator==", "H5Pequal failed"); + throw PropListIException(inMemFunc("operator=="), "H5Pequal failed"); } } @@ -603,9 +603,9 @@ bool PropList::operator==(const PropList& rhs) const PropList PropList::getClassParent() const { hid_t class_id = H5Pget_class_parent(id); - if (class_id <= 0) + if (class_id < 0) { - throw PropListIException("PropList::getClassParent", "H5Pget_class_parent failed"); + throw PropListIException(inMemFunc("getClassParent"), "H5Pget_class_parent failed"); } PropList pclass(class_id); return(pclass); diff --git a/c++/src/H5PropList.h b/c++/src/H5PropList.h index 8f10889..f820518 100644 --- a/c++/src/H5PropList.h +++ b/c++/src/H5PropList.h @@ -93,6 +93,9 @@ class H5_DLLCPP PropList : public IdComponent { void removeProp(const char *name) const; void removeProp(const string& name) const; + // Returns this class name + virtual string fromClass () const { return ("PropList"); } + // Default constructor: creates a stub PropList object. PropList(); diff --git a/c++/src/H5StrType.h b/c++/src/H5StrType.h index c210472..b79ad0b 100644 --- a/c++/src/H5StrType.h +++ b/c++/src/H5StrType.h @@ -46,6 +46,9 @@ class H5_DLLCPP StrType : public AtomType { // Defines the storage mechanism for character strings. void setStrpad(H5T_str_t strpad) const; + // Returns this class name + virtual string fromClass () const { return ("StrType"); } + // default constructor StrType(); diff --git a/c++/src/H5VarLenType.h b/c++/src/H5VarLenType.h index 766e12b..7db324f 100644 --- a/c++/src/H5VarLenType.h +++ b/c++/src/H5VarLenType.h @@ -24,6 +24,9 @@ namespace H5 { #endif class H5_DLLCPP VarLenType : public DataType { public: + // Returns this class name + virtual string fromClass () const { return ("VarLenType"); } + // Constructor that creates a variable-length datatype based // on the specified base type. VarLenType(const DataType* base_type); |