diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2000-12-23 13:17:32 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2000-12-23 13:17:32 (GMT) |
commit | d24bacb8a47f945e6919f067e8057ad30012bd5a (patch) | |
tree | 2844b08018435b9d33f68ef4b787d5434db66d5a /c++ | |
parent | 45c5dd949f7dd4549dc5996ff8395652ef3d9dda (diff) | |
download | hdf5-d24bacb8a47f945e6919f067e8057ad30012bd5a.zip hdf5-d24bacb8a47f945e6919f067e8057ad30012bd5a.tar.gz hdf5-d24bacb8a47f945e6919f067e8057ad30012bd5a.tar.bz2 |
[svn-r3199]
Purpose: bug fix
Description:
I found a couple of places where virtual destructors were missing
and could cause small memory leaks. Also, some destructors were
not virtual when they should be.
Solution:
- added virtual destructors, which also free dynamically allocated
memory
- added virtual to several destructors
- also, fixed several typos
Platforms tested:
Solaris 2.7 (arabica)
Diffstat (limited to 'c++')
-rw-r--r-- | c++/src/H5AbstractDs.cpp | 3 | ||||
-rw-r--r-- | c++/src/H5AbstractDs.h | 26 | ||||
-rw-r--r-- | c++/src/H5AtomType.h | 14 | ||||
-rw-r--r-- | c++/src/H5Attribute.h | 7 | ||||
-rw-r--r-- | c++/src/H5CommonFG.h | 34 | ||||
-rw-r--r-- | c++/src/H5CompType.cpp | 6 | ||||
-rw-r--r-- | c++/src/H5CompType.h | 37 | ||||
-rw-r--r-- | c++/src/H5DataSet.cpp | 2 | ||||
-rw-r--r-- | c++/src/H5DataSet.h | 16 | ||||
-rw-r--r-- | c++/src/H5DataSpace.cpp | 5 | ||||
-rw-r--r-- | c++/src/H5DataSpace.h | 21 | ||||
-rw-r--r-- | c++/src/H5DataType.cpp | 24 | ||||
-rw-r--r-- | c++/src/H5DataType.h | 6 | ||||
-rw-r--r-- | c++/src/H5DcreatProp.cpp | 7 | ||||
-rw-r--r-- | c++/src/H5DcreatProp.h | 3 | ||||
-rw-r--r-- | c++/src/H5DxferProp.cpp | 11 | ||||
-rw-r--r-- | c++/src/H5DxferProp.h | 4 | ||||
-rw-r--r-- | c++/src/H5Exception.cpp | 53 | ||||
-rw-r--r-- | c++/src/H5Exception.h | 43 | ||||
-rw-r--r-- | c++/src/H5FaccProp.cpp | 8 | ||||
-rw-r--r-- | c++/src/H5FaccProp.h | 3 | ||||
-rw-r--r-- | c++/src/H5FcreatProp.cpp | 8 | ||||
-rw-r--r-- | c++/src/H5FcreatProp.h | 3 | ||||
-rw-r--r-- | c++/src/H5IdComponent.cpp | 6 | ||||
-rw-r--r-- | c++/src/H5Idtemplates.h | 2 | ||||
-rw-r--r-- | c++/src/H5PredType.cpp | 2 | ||||
-rw-r--r-- | c++/src/H5PropList.cpp | 10 | ||||
-rw-r--r-- | c++/src/H5RefCounter.cpp | 2 | ||||
-rw-r--r-- | c++/src/H5RefCounter.h | 6 |
29 files changed, 146 insertions, 226 deletions
diff --git a/c++/src/H5AbstractDs.cpp b/c++/src/H5AbstractDs.cpp index 5424bdb..4fa55dc 100644 --- a/c++/src/H5AbstractDs.cpp +++ b/c++/src/H5AbstractDs.cpp @@ -127,6 +127,9 @@ void AbstractDs::getDataType( StrType& strtype ) const } end of old style of getDataType */ +// Default destructor +AbstractDs::~AbstractDs() {} + #ifndef H5_NO_NAMESPACE } // end namespace #endif diff --git a/c++/src/H5AbstractDs.h b/c++/src/H5AbstractDs.h index 49aafa9..924b63b 100644 --- a/c++/src/H5AbstractDs.h +++ b/c++/src/H5AbstractDs.h @@ -1,3 +1,8 @@ +// Class AbstractDs is an abstract base class, from which Attribute and +// DataSet inherit. It provides the services that are common to both +// Attribute and DataSet. It also inherits from H5Object and passes down +// the services that H5Object provides. + #ifndef _AbstractDs_H #define _AbstractDs_H @@ -6,9 +11,6 @@ namespace H5 { #endif class AbstractDs : public H5Object { public: - // Copy constructor - AbstractDs( const AbstractDs& original ); - // Gets the dataspace of this abstract dataset - pure virtual virtual DataSpace getSpace() const = 0; @@ -16,22 +18,24 @@ class AbstractDs : public H5Object { // dataset H5T_class_t getTypeClass() const; - // Gets a copy the datatype of this abstract dataset. Note that - // this datatype is a generic one and can only be accessed via - // generic member functions, i.e., member functions belong to - // DataType. To get specific datatype, i.e. EnumType, - // FloatType, etc..., use the specific functions instead . + // Gets a copy the datatype of that this abstract dataset uses. + // Note that this datatype is a generic one and can only be accessed + // via generic member functions, i.e., member functions belong + // to DataType. To get specific datatype, i.e. EnumType, FloatType, + // etc..., use the specific functions, that follow, instead . DataType getDataType() const; - // Gets a copy of the specific datatype of this abstract dataset - - // overloading for subtypes. + // Gets a copy of the specific datatype of this abstract dataset EnumType getEnumType() const; CompType getCompType() const; IntType getIntType() const; FloatType getFloatType() const; StrType getStrType() const; - virtual ~AbstractDs() {}; + // Copy constructor + AbstractDs( const AbstractDs& original ); + + virtual ~AbstractDs(); protected: // Default constructor diff --git a/c++/src/H5AtomType.h b/c++/src/H5AtomType.h index 14834c3..bd8467c 100644 --- a/c++/src/H5AtomType.h +++ b/c++/src/H5AtomType.h @@ -1,3 +1,8 @@ +// Class AtomType is a base class, from which IntType, FloatType, StrType, +// and PredType inherit. It provides the services that are common to these +// subclasses. It also inherits from DataType and passes down the +// services that are common to all the datatypes. + #ifndef _H5AtomType_H #define _H5AtomType_H @@ -6,9 +11,6 @@ namespace H5 { #endif class AtomType : public DataType { public: - // Copy constructor - makes copy of the original object - AtomType( const AtomType& original ); - // Sets the total size for an atomic datatype. void setSize( size_t size ) const; @@ -38,13 +40,17 @@ class AtomType : public DataType { // Sets the least and most-significant bits padding types // void setPad( H5T_pad_t lsb, H5T_pad_t msb ) const; + // Copy constructor - makes copy of the original object + AtomType( const AtomType& original ); + + // Default destructor virtual ~AtomType(); protected: // Default constructor AtomType(); - // Constructor that takes an existing id - for predefined type + // Constructor that takes an existing id AtomType( const hid_t existing_id ); }; #ifndef H5_NO_NAMESPACE diff --git a/c++/src/H5Attribute.h b/c++/src/H5Attribute.h index d04e351..142a829 100644 --- a/c++/src/H5Attribute.h +++ b/c++/src/H5Attribute.h @@ -6,11 +6,7 @@ namespace H5 { #endif class Attribute : public AbstractDs { - public: - // Copy constructor: makes a copy of an existing Attribute object. - Attribute( const Attribute& original ); - // Writes data to this attribute. void write(const DataType& mem_type, void *buf ) const; @@ -32,6 +28,9 @@ class Attribute : public AbstractDs { // Creates a copy of an existing attribute using the attribute id Attribute( const hid_t attr_id ); + // Copy constructor: makes a copy of an existing Attribute object. + Attribute( const Attribute& original ); + virtual ~Attribute(); private: diff --git a/c++/src/H5CommonFG.h b/c++/src/H5CommonFG.h index 2eb532d..0fdf3d5 100644 --- a/c++/src/H5CommonFG.h +++ b/c++/src/H5CommonFG.h @@ -1,8 +1,6 @@ -/* -This class is a prototype class. Most of its member functions are those -that are common to both H5File and Group. H5File and Group will inherit -these functions. -*/ +// CommonFG is a protocol class. Its existence is simply to provide the +// common services that are provided by H5File and Group. The file or +// group in the context of this class is referred to as 'location'. #ifndef _CommonFG_H #define _CommonFG_H @@ -48,27 +46,28 @@ class CommonFG { void move( const string& src, const string& dst ) const; void move( const char* src, const char* dst ) const; - // Returns information about an object + // Returns information about an HDF5 object, given by its name, + // at this location. void getObjinfo( const string& name, hbool_t follow_link, H5G_stat_t& statbuf ) const; void getObjinfo( const char* name, hbool_t follow_link, H5G_stat_t& statbuf ) const; - // Returns the name of the object that the symbolic link points to. + // Returns the name of the HDF5 object that the symbolic link points to. string getLinkval( const string& name, size_t size ) const; string getLinkval( const char* name, size_t size ) const; - // Sets the comment for an object specified by its name + // Sets the comment for an HDF5 object specified by its name void setComment( const string& name, const string& comment ) const; void setComment( const char* name, const char* comment ) const; - // Retrieves comment for specified object + // Retrieves comment for the HDF5 object specified by its name string getComment( const string& name, size_t bufsize ) const; string getComment( const char* name, size_t bufsize ) const; - // Mounts the file 'child' onto this group + // Mounts the file 'child' onto this location void mount( const string& name, H5File& child, PropList& plist ) const; void mount( const char* name, H5File& child, PropList& plist) const; - // Unmounts the file named 'name' from this parent group + // Unmounts the file named 'name' from this parent location void unmount( const string& name ) const; void unmount( const char* name ) const; @@ -77,27 +76,27 @@ class CommonFG { int iterateElems( const string& name, int *idx, H5G_iterate_t op, void *op_data ); int iterateElems( const char* name, int *idx, H5G_iterate_t op, void *op_data ); - // Opens a generic named datatype in this file + // Opens a generic named datatype in this location DataType openDataType( const string& name ) const; DataType openDataType( const char* name ) const; - // Opens a named enumeration datatype in this file + // Opens a named enumeration datatype in this location EnumType openEnumType( const string& name ) const; EnumType openEnumType( const char* name ) const; - // Opens a named compound datatype in this file + // Opens a named compound datatype in this location CompType openCompType( const string& name ) const; CompType openCompType( const char* name ) const; - // Opens a named integer datatype in this file + // Opens a named integer datatype in this location IntType openIntType( const string& name ) const; IntType openIntType( const char* name ) const; - // Opens a named floating-point datatype in this file + // Opens a named floating-point datatype in this location FloatType openFloatType( const string& name ) const; FloatType openFloatType( const char* name ) const; - // Opens a named string datatype in this file + // Opens a named string datatype in this location StrType openStrType( const string& name ) const; StrType openStrType( const char* name ) const; @@ -105,7 +104,6 @@ class CommonFG { virtual void throwException() const = 0; CommonFG(); - virtual ~CommonFG(); private: diff --git a/c++/src/H5CompType.cpp b/c++/src/H5CompType.cpp index 7bb66ea..c4143df 100644 --- a/c++/src/H5CompType.cpp +++ b/c++/src/H5CompType.cpp @@ -201,12 +201,6 @@ void CompType::insertMember( const string name, size_t offset, const DataType& n } } -// Adds an array member to this compound datatype. -void CompType::insertMember( const string member_name, size_t offset, int ndims, const size_t* dim, const int* perm, const DataType& new_member ) const -{ - throw DataTypeIException( "Error: insertMember is no longer supported."); -} - // Recursively removes padding from within a compound datatype. void CompType::pack() const { diff --git a/c++/src/H5CompType.h b/c++/src/H5CompType.h index 976cb17..4b1c28e 100644 --- a/c++/src/H5CompType.h +++ b/c++/src/H5CompType.h @@ -1,3 +1,6 @@ +// Class CompType inherits from DataType and provides accesses to a compound +// datatype. + #ifndef _H5CompType_H #define _H5CompType_H @@ -7,35 +10,27 @@ namespace H5 { class CompType : public DataType { public: - // Creates a new datatype + // Creates a new compound datatype, given the type's size CompType( size_t size ); // H5Tcreate - // Default constructor - CompType(); - - // Creates a compound datatype using an existing id - CompType( const hid_t existing_id ); - - // Copy constructor - makes a copy of original object - CompType( const CompType& original ); - // Gets the compound datatype of the specified dataset CompType( const DataSet& dataset ); // H5Dget_type - // Retrieves the number of members in this compound datatype. + // Returns the number of members in this compound datatype. int getNmembers() const; - // Retrieves the name of a member of this compound datatype. + // Returns the name of a member of this compound datatype. string getMemberName( int member_num ) const; - // Retrieves the offset of a member of this compound datatype. + // Returns the offset of a member of this compound datatype. size_t getMemberOffset( int memb_no ) const; // Returns the dimensionality of the specified member. int getMemberDims( int member_num, size_t* dims, int* perm ) const; - // Gets the type class of the specified member. It provides to - // the user a way of knowing what type to declare. + // Returns the type class of the specified member of this compound + // datatype. It provides to the user a way of knowing what type + // to create another datatype of the same class H5T_class_t getMemberClass( int member_num ) const; // Returns the generic datatype of the specified member in @@ -65,12 +60,18 @@ class CompType : public DataType { // Adds a new member to this compound datatype. void insertMember( const string name, size_t offset, const DataType& new_member ) const; - // Adds an array datatype member to this compound datatype. - void insertMember( const string name, size_t offset, int ndims, const size_t* dim, const int* perm, const DataType& new_member ) const; - // Recursively removes padding from within this compound datatype. void pack() const; + // Default constructor + CompType(); + + // Creates a compound datatype using an existing id + CompType( const hid_t existing_id ); + + // Copy constructor - makes a copy of original object + CompType( const CompType& original ); + virtual ~CompType(); private: diff --git a/c++/src/H5DataSet.cpp b/c++/src/H5DataSet.cpp index aed8d70..d9578b0 100644 --- a/c++/src/H5DataSet.cpp +++ b/c++/src/H5DataSet.cpp @@ -199,7 +199,7 @@ void DataSet::p_close() const // a member function so it can be template to work around that problem. DataSet::~DataSet() { - // The dataset id will be closed properly + // The dataset id will be closed properly resetIdComponent( this ); } diff --git a/c++/src/H5DataSet.h b/c++/src/H5DataSet.h index 8a59234..e094159 100644 --- a/c++/src/H5DataSet.h +++ b/c++/src/H5DataSet.h @@ -1,3 +1,6 @@ + +// Class DataSet inherits from AbstractDs and provides accesses to a dataset. + #ifndef _H5DataSet_H #define _H5DataSet_H @@ -6,14 +9,7 @@ namespace H5 { #endif class DataSet : public AbstractDs { - public: - // Default constructor - DataSet(); - - // Copy constructor - DataSet( const DataSet& original ); - // Gets the dataspace of this dataset. virtual DataSpace getSpace() const; @@ -52,6 +48,12 @@ class DataSet : public AbstractDs { // Used by the API to appropriately close a dataset virtual void p_close() const; + // Default constructor + DataSet(); + + // Copy constructor + DataSet( const DataSet& original ); + virtual ~DataSet(); private: diff --git a/c++/src/H5DataSpace.cpp b/c++/src/H5DataSpace.cpp index 746dc39..3e1d922 100644 --- a/c++/src/H5DataSpace.cpp +++ b/c++/src/H5DataSpace.cpp @@ -56,10 +56,7 @@ void DataSpace::copy( const DataSpace& like_space ) id = H5Scopy( like_space.getId() ); // points to the same ref counter - ref_count = like_space.ref_count; - - // increment ref counter to indicate additional references to this id - ref_count->increment(); + ref_count = new RefCounter; if( id <= 0 ) { diff --git a/c++/src/H5DataSpace.h b/c++/src/H5DataSpace.h index 7f0ca83..5da7299 100644 --- a/c++/src/H5DataSpace.h +++ b/c++/src/H5DataSpace.h @@ -10,30 +10,15 @@ class DataSpace : public IdComponent { // Default DataSpace objects static const DataSpace ALL; - // Default constructor - DataSpace(); - // Creates a dataspace object given the space type DataSpace( H5S_class_t type ); // H5Screate - // Assignement operator - //DataSpace& operator=( const DataSpace& rhs ); - // Creates a simple dataspace DataSpace( int rank, const hsize_t * dims, const hsize_t * maxdims = NULL); // H5Screate_simple - // Copy constructor: makes a copy of the original DataSpace object. - DataSpace( const DataSpace& original ); - // Makes copy of an existing dataspace. void copy( const DataSpace& like_space ); // H5Scopy - // Gets value of member id of this dataspace - //hid_t getId () const; - - // Sets value for member id of this dataspace. - //void setId( hid_t new_space_id ); - // Determines if this dataspace is a simple one. bool isSimple () const; @@ -103,6 +88,12 @@ class DataSpace : public IdComponent { // Used by the API to close the dataspace void p_close() const; + // Default constructor + DataSpace(); + + // Copy constructor: makes a copy of the original DataSpace object. + DataSpace( const DataSpace& original ); + virtual ~DataSpace(); }; #ifndef H5_NO_NAMESPACE diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp index b376f61..889d233 100644 --- a/c++/src/H5DataType.cpp +++ b/c++/src/H5DataType.cpp @@ -53,10 +53,16 @@ void DataType::copy( const DataType& like_type ) // call C routine to copy the datatype id = H5Tcopy( like_type.getId() ); + ref_count = new RefCounter; + +/* +id != like_type.id so this object has a different ref_count than +like_type ref_count = like_type.ref_count; // increment ref counter to indicate additional references to this id ref_count->increment(); +*/ if( id <= 0 ) { @@ -85,27 +91,11 @@ bool DataType::operator==(const DataType& compared_type ) const // the parameter list??? //int DataType::iterate( unsigned * idx, H5A_operator_t op, void *op_data ) //{ - // Call C routine H5Aiterate to iterate the object's attributes - //int ret_value = H5Aiterate( id, idx, op, op_data ); - //if( ret_value >= 0 ) - //return( ret_value ); - //else - //{ - //throw DataTypeIException(); - //} //} // Creates a new variable-length datatype - Note: make it inheritance??? //DataType DataType::vlenCreate( const DataType& base_type ) //{ - // Call C routine to create a new VL datatype - //hid_t type_id = H5Tvlen_create( id ); - //if( type_id > 0 ) - //id_obj->setId( type_id ); - //else - //{ - //throw DataTypeIException(); - //} //} // Commits a transient datatype to a file, creating a new named datatype @@ -237,7 +227,7 @@ DataType DataType::getSuper() const DataType base_type( base_type_id ); return( base_type ); } - else {} + else { throw DataTypeIException(); } diff --git a/c++/src/H5DataType.h b/c++/src/H5DataType.h index 0fa1965..8e6b82e 100644 --- a/c++/src/H5DataType.h +++ b/c++/src/H5DataType.h @@ -7,9 +7,6 @@ namespace H5 { class DataType : public H5Object { public: - // Default constructor - DataType(); - // Creates a datatype given its class and size DataType( const H5T_class_t type_class, size_t size ); @@ -82,6 +79,9 @@ class DataType : public H5Object { // Creates a copy of an existing DataType using its id DataType( const hid_t type_id, bool predtype = false ); + // Default constructor + DataType(); + virtual ~DataType(); protected: diff --git a/c++/src/H5DcreatProp.cpp b/c++/src/H5DcreatProp.cpp index adaa046..39b653e 100644 --- a/c++/src/H5DcreatProp.cpp +++ b/c++/src/H5DcreatProp.cpp @@ -18,13 +18,6 @@ const DSetCreatPropList DSetCreatPropList::DEFAULT( H5P_DEFAULT ); // Copy constructor: makes a copy of the original DSetCreatPropList object; DSetCreatPropList::DSetCreatPropList( const DSetCreatPropList& orig ) : PropList( orig ) {} -// Copies a dataset creation property list using assignment statement -DSetCreatPropList& DSetCreatPropList::operator=( const DSetCreatPropList& rhs ) -{ - copy (rhs); - return( *this ); -} - // Sets the size of the chunks used to store a chunked layout dataset. void DSetCreatPropList::setChunk( int ndims, const hsize_t* dim ) const { diff --git a/c++/src/H5DcreatProp.h b/c++/src/H5DcreatProp.h index 5fa67ee..b4e1e9a 100644 --- a/c++/src/H5DcreatProp.h +++ b/c++/src/H5DcreatProp.h @@ -16,9 +16,6 @@ class DSetCreatPropList : public PropList { // often used by the compiler when passing by value occurs. DSetCreatPropList( const DSetCreatPropList& orig ); - // Copies a dataset creation property list using assignment statement - DSetCreatPropList& operator=( const DSetCreatPropList& rhs ); - // Sets the type of storage used to store the raw data for the // dataset that uses this property list void setLayout(hid_t plist, H5D_layout_t layout ) const; diff --git a/c++/src/H5DxferProp.cpp b/c++/src/H5DxferProp.cpp index ff96b66..5792865 100644 --- a/c++/src/H5DxferProp.cpp +++ b/c++/src/H5DxferProp.cpp @@ -19,14 +19,6 @@ DSetMemXferPropList::DSetMemXferPropList() : PropList( H5P_DATASET_XFER ) {} // Copy constructor: makes a copy of the original DSetMemXferPropList object; DSetMemXferPropList::DSetMemXferPropList( const DSetMemXferPropList& orig ) : PropList( orig ) {} -// Copies a dataset transfer property list using assignment statement -// Notes: can this be inherited from PropList??? and copy or operator=??? -DSetMemXferPropList& DSetMemXferPropList::operator=( const DSetMemXferPropList& rhs ) -{ - copy (rhs); - return( *this ); -} - // Sets type conversion and background buffers void DSetMemXferPropList::setBuffer( size_t size, void* tconv, void* bkg ) const { @@ -150,7 +142,7 @@ void DSetMemXferPropList::getVlenMemManager( H5MM_allocate_t& alloc_func, void** } } -/* these two functions are in parallel mode only - not supported at this time. +/* this function is in parallel mode only - not supported at this time. // Sets the transfer mode void DSetMemXferPropList::setXfer( H5D_transfer_t data_xfer_mode = H5D_XFER_INDEPENDENT ) const { @@ -161,6 +153,7 @@ void DSetMemXferPropList::setXfer( H5D_transfer_t data_xfer_mode = H5D_XFER_INDE } } +// this function is in parallel mode only - not supported at this time. // Gets the transfer mode H5D_transfer_t DSetMemXferPropList::getXfer() const { diff --git a/c++/src/H5DxferProp.h b/c++/src/H5DxferProp.h index 2e7f51a..bb25862 100644 --- a/c++/src/H5DxferProp.h +++ b/c++/src/H5DxferProp.h @@ -15,10 +15,6 @@ class DSetMemXferPropList : public PropList { // Copy constructor: creates a copy of a DSetMemXferPropList object DSetMemXferPropList( const DSetMemXferPropList& orig ); - // Copies a dataset memory and transfer property list using - // assignment statement - DSetMemXferPropList& operator=( const DSetMemXferPropList& rhs ); - // Sets type conversion and background buffers void setBuffer( size_t size, void* tconv, void* bkg ) const; diff --git a/c++/src/H5Exception.cpp b/c++/src/H5Exception.cpp index ea4cb63..4eff181 100644 --- a/c++/src/H5Exception.cpp +++ b/c++/src/H5Exception.cpp @@ -128,67 +128,60 @@ void Exception::printError( FILE* stream ) const throw Exception( "printError: H5Eprint fails" ); } +Exception::~Exception() +{ + herr_t ret_value = H5Eprint( NULL ); // print to stderr + if( ret_value < 0 ) + throw Exception( "printError: H5Eprint fails" ); +} + FileIException::FileIException():Exception(){} -FileIException::FileIException( string message ): -Exception( message ){} +FileIException::FileIException( string message ): Exception( message ){} +FileIException::~FileIException() {} GroupIException::GroupIException():Exception(){} -GroupIException::GroupIException( string message ): -Exception( message ){} - -ObjectHeaderException::ObjectHeaderException():Exception(){} -ObjectHeaderException::ObjectHeaderException( string message ): Exception( message ) {} +GroupIException::GroupIException( string message ): Exception( message ){} +GroupIException::~GroupIException() {} DataSpaceIException::DataSpaceIException():Exception(){} DataSpaceIException::DataSpaceIException( string message ): Exception( message ) {} +DataSpaceIException::~DataSpaceIException() {} DataTypeIException::DataTypeIException():Exception(){} DataTypeIException::DataTypeIException( string message ): Exception( message ) {} +DataTypeIException::~DataTypeIException() {} PropListIException::PropListIException():Exception(){} PropListIException::PropListIException( string message ): Exception( message ) {} +PropListIException::~PropListIException() {} DataSetIException::DataSetIException():Exception(){} DataSetIException::DataSetIException( string message ): Exception( message ) {} +DataSetIException::~DataSetIException() {} AttributeIException::AttributeIException():Exception(){} AttributeIException::AttributeIException( string message ): Exception( message ) {} - -FunctionArgumentException::FunctionArgumentException():Exception(){} -FunctionArgumentException::FunctionArgumentException( string message ): Exception( message ) {} +AttributeIException::~AttributeIException() {} ReferenceException::ReferenceException():Exception(){} -ReferenceException::ReferenceException( string message ): -Exception( message ) {} - -DataStorageException::DataStorageException():Exception(){} -DataStorageException::DataStorageException( string message ): -Exception( message ) {} +ReferenceException::ReferenceException( string message ): Exception( message ) {} +ReferenceException::~ReferenceException() {} LibraryIException::LibraryIException():Exception(){} -LibraryIException::LibraryIException( string message ): -Exception( message ) {} +LibraryIException::LibraryIException( string message ): Exception( message ) {} +LibraryIException::~LibraryIException() {} IdComponentException::IdComponentException(): Exception() {} IdComponentException::IdComponentException( string message ): Exception( message ) {} +IdComponentException::~IdComponentException() {} // The following are from Java API but not done here: // AtomException, BtreeException, DataFiltersException, // ExternalFileListException, FunctionEntryExitException, // HeapException, InternalErrorException, LowLevelIOException, // MetaDataCacheException, ResourceUnavailableException, -// SymbolTableException - -File_GroupException::File_GroupException() -{ - // for now, do nothing -} - -File_GroupException::File_GroupException( string message ) -{ - // for now, do nothing -} - +// SymbolTableException, ObjectHeaderException, FunctionArgumentException, +// DataStorageException #ifndef H5_NO_NAMESPACE } // end namespace diff --git a/c++/src/H5Exception.h b/c++/src/H5Exception.h index 69ecf42..c8e4132 100644 --- a/c++/src/H5Exception.h +++ b/c++/src/H5Exception.h @@ -59,95 +59,83 @@ class Exception { // Prints the error stack in a default manner. //void printError() const; - void printError( FILE* stream = NULL ) const; + virtual void printError( FILE* stream = NULL ) const; + + // virtual Destructor + virtual ~Exception(); private: string detailMessage; }; -// This exception is privately used in Group and H5File only -class File_GroupException { - public: - File_GroupException(); - File_GroupException( string message ); -}; - class FileIException : public Exception { public: FileIException(); FileIException( string message ); + virtual ~FileIException(); }; class GroupIException : public Exception { public: GroupIException(); GroupIException( string message ); -}; - -class ObjectHeaderException : public Exception { - public: - ObjectHeaderException(); - ObjectHeaderException( string message ); + virtual ~GroupIException(); }; class DataSpaceIException : public Exception { public: DataSpaceIException(); DataSpaceIException( string message ); + virtual ~DataSpaceIException(); }; class DataTypeIException : public Exception { public: DataTypeIException(); DataTypeIException( string message ); + virtual ~DataTypeIException(); }; class PropListIException : public Exception { public: PropListIException(); PropListIException( string message ); + virtual ~PropListIException(); }; class DataSetIException : public Exception { public: DataSetIException(); DataSetIException( string message ); + virtual ~DataSetIException(); }; class AttributeIException : public Exception { public: AttributeIException(); AttributeIException( string message ); -}; - -class FunctionArgumentException : public Exception { - public: - FunctionArgumentException(); - FunctionArgumentException( string message ); + virtual ~AttributeIException(); }; class ReferenceException : public Exception { public: ReferenceException(); ReferenceException( string message ); -}; - -class DataStorageException : public Exception { - public: - DataStorageException(); - DataStorageException( string message ); + virtual ~ReferenceException(); }; class LibraryIException : public Exception { public: LibraryIException(); LibraryIException( string message ); + virtual ~LibraryIException(); }; class IdComponentException : public Exception { public: IdComponentException(); IdComponentException( string message ); + virtual ~IdComponentException(); }; // The following are from Java API but not done here: @@ -155,7 +143,8 @@ class IdComponentException : public Exception { // ExternalFilelistException, FunctionEntryExitException, // HeapException, InternalErrorException, LowLevelIOException, // MetaDataCacheException, ResourceUnavailableException, -// SymbolTableException +// SymbolTableException, ObjectHeaderException, FunctionArgumentException, +// DataStorageException #ifndef H5_NO_NAMESPACE } #endif diff --git a/c++/src/H5FaccProp.cpp b/c++/src/H5FaccProp.cpp index a59173d..7d76bcc 100644 --- a/c++/src/H5FaccProp.cpp +++ b/c++/src/H5FaccProp.cpp @@ -19,14 +19,6 @@ FileAccPropList::FileAccPropList() : PropList( H5P_FILE_ACCESS ) {} // Copy constructor: makes a copy of the original FileAccPropList object; FileAccPropList::FileAccPropList( const FileAccPropList& orig ) : PropList( orig ) {} -// Copies a file access property list using assignment statement -// Notes: can this be inherited from PropList??? and copy or operator=??? -FileAccPropList& FileAccPropList::operator=( const FileAccPropList& rhs ) -{ - copy (rhs); - return( *this ); -} - /* commented out for 1.3.x, only in 1.2.x void FileAccPropList::setStdio() const { diff --git a/c++/src/H5FaccProp.h b/c++/src/H5FaccProp.h index e632fab..1a4de40 100644 --- a/c++/src/H5FaccProp.h +++ b/c++/src/H5FaccProp.h @@ -16,9 +16,6 @@ class FileAccPropList : public PropList { // Copy constructor: creates a copy of a FileAccPropList object FileAccPropList( const FileAccPropList& orig ); - // Copies a file access property list using assignment statement. - FileAccPropList& operator=( const FileAccPropList& rhs ); - // Sets the low level file driver to use the functions // declared in the stdio.h // void setStdio() const; diff --git a/c++/src/H5FcreatProp.cpp b/c++/src/H5FcreatProp.cpp index 41ec360..9d5c1d6 100644 --- a/c++/src/H5FcreatProp.cpp +++ b/c++/src/H5FcreatProp.cpp @@ -19,14 +19,6 @@ FileCreatPropList::FileCreatPropList() : PropList( H5P_FILE_CREATE ) {} // Copy constructor: makes a copy of the original FileCreatPropList object; FileCreatPropList::FileCreatPropList( const FileCreatPropList& orig ) : PropList( orig ) {} -// Copies a file create property list using assignment statement -// Notes: can this be inherited from PropList??? and copy or operator=??? -FileCreatPropList& FileCreatPropList::operator=( const FileCreatPropList& rhs ) -{ - copy (rhs); - return( *this ); -} - void FileCreatPropList::getVersion( int& boot, int& freelist, int& stab, int& shhdr ) const { diff --git a/c++/src/H5FcreatProp.h b/c++/src/H5FcreatProp.h index f40553f..503caca 100644 --- a/c++/src/H5FcreatProp.h +++ b/c++/src/H5FcreatProp.h @@ -16,9 +16,6 @@ class FileCreatPropList : public PropList { // Copy constructor: creates a copy of a FileCreatPropList object FileCreatPropList( const FileCreatPropList& orig ); - // Copies a file creation property list using assignment statement - FileCreatPropList& operator=( const FileCreatPropList& rhs ); - // Retrieves version information for various parts of a file. void getVersion( int& boot, int& freelist, int& stab, int& shhdr ) const; diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp index 4850bb0..60ddadb 100644 --- a/c++/src/H5IdComponent.cpp +++ b/c++/src/H5IdComponent.cpp @@ -103,13 +103,15 @@ hid_t IdComponent::getId () const void IdComponent::reset () { delete ref_count; + ref_count = NULL; } // Default destructor IdComponent::~IdComponent() { -/* uncomment this block when decide to use dontAtExit or fix the atexit/ - global destructor problem - BMR 11/14/00 +/* uncomment this block and complete it when deciding to use dontAtExit + unless the atexit/global destructor problem is fixed, then + remove it- BMR 11/14/00 if( id == NOTATEXIT ) { diff --git a/c++/src/H5Idtemplates.h b/c++/src/H5Idtemplates.h index 442ca97..220be6d 100644 --- a/c++/src/H5Idtemplates.h +++ b/c++/src/H5Idtemplates.h @@ -18,8 +18,10 @@ void resetIdComponent( if( obj->noReference()) // ref count of this object is decremented here { if( obj->getId() > 0 ) + { obj->p_close(); // which p_close depends on whom this // IdComponent object belongs to + } obj->reset(); // delete ref_count from IdComponent } } diff --git a/c++/src/H5PredType.cpp b/c++/src/H5PredType.cpp index a209b97..0ba8602 100644 --- a/c++/src/H5PredType.cpp +++ b/c++/src/H5PredType.cpp @@ -185,7 +185,7 @@ bool PredType::committed() return (-1); } -// Destructor: calls ~AtomType immediately +// Default destructor PredType::~PredType() {} #ifndef H5_NO_NAMESPACE diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp index 5279be0..ad9c8ca 100644 --- a/c++/src/H5PropList.cpp +++ b/c++/src/H5PropList.cpp @@ -15,10 +15,7 @@ const PropList PropList::DEFAULT( H5P_DEFAULT ); // Default constructor - set id to 0 by default here but may be set // to a valid one, if any, by a subclass constructor. -PropList::PropList() : IdComponent( 0 ) -{ -// id_obj = new IdComponent( 0 ); // init default object's id to 0 -} +PropList::PropList() : IdComponent( 0 ) {} // Creates a new property of specified type PropList::PropList( H5P_class_t type ) : IdComponent( 0 ) @@ -55,10 +52,7 @@ void PropList::copy( const PropList& like_plist ) id = H5Pcopy( like_plist.getId() ); // points to the same ref counter - ref_count = like_plist.ref_count; - - // increment ref counter to indicate additional references to this id - ref_count->increment(); + ref_count = new RefCounter; if( id <= 0 ) { diff --git a/c++/src/H5RefCounter.cpp b/c++/src/H5RefCounter.cpp index 6167642..61fcff4 100644 --- a/c++/src/H5RefCounter.cpp +++ b/c++/src/H5RefCounter.cpp @@ -6,7 +6,7 @@ using namespace std; #endif // Creates a reference counter to be used by an HDF5 object -RefCounter::RefCounter() : counter(1) { } +RefCounter::RefCounter() : counter(1) {} // Returns the current value of the reference counter int RefCounter::getCounter () const { return counter; } diff --git a/c++/src/H5RefCounter.h b/c++/src/H5RefCounter.h index 17c00d4..f5d832c 100644 --- a/c++/src/H5RefCounter.h +++ b/c++/src/H5RefCounter.h @@ -1,7 +1,5 @@ -//#ifndef _H5RefCounter_H -//#define _H5RefCounter_H -#ifndef _MY_RefCounter -#define _MY_RefCounter +#ifndef _H5RefCounter_H +#define _H5RefCounter_H #ifndef H5_NO_NAMESPACE namespace H5 { |