diff options
-rw-r--r-- | c++/src/H5DataSet.cpp | 60 | ||||
-rw-r--r-- | c++/src/H5DataSet.h | 18 | ||||
-rw-r--r-- | c++/src/H5DataType.cpp | 50 | ||||
-rw-r--r-- | c++/src/H5DataType.h | 18 | ||||
-rw-r--r-- | c++/src/H5File.cpp | 50 | ||||
-rw-r--r-- | c++/src/H5File.h | 10 | ||||
-rw-r--r-- | c++/src/H5Group.cpp | 56 | ||||
-rw-r--r-- | c++/src/H5Group.h | 11 | ||||
-rw-r--r-- | c++/src/H5IdComponent.cpp | 122 | ||||
-rw-r--r-- | c++/src/H5IdComponent.h | 16 | ||||
-rw-r--r-- | c++/src/H5PredType.cpp | 4 | ||||
-rw-r--r-- | c++/src/H5PropList.cpp | 4 | ||||
-rw-r--r-- | c++/src/H5StrType.cpp | 4 |
13 files changed, 281 insertions, 142 deletions
diff --git a/c++/src/H5DataSet.cpp b/c++/src/H5DataSet.cpp index c938b20..ae60e49 100644 --- a/c++/src/H5DataSet.cpp +++ b/c++/src/H5DataSet.cpp @@ -65,6 +65,23 @@ DataSet::DataSet(const hid_t existing_id) : AbstractDs(existing_id) {} DataSet::DataSet( const DataSet& original ) : AbstractDs( original ) {} //-------------------------------------------------------------------------- +// Function: DataSet overload constructor - dereference +///\brief Given a reference to some object, returns that dataset +/// obj - IN: Dataset reference object is in or location of +/// object that the dataset is located within. +///\param ref - IN: Reference pointer +///\exception H5::DataSetIException +///\parDescription +/// \c obj can be DataSet, Group, H5File, or named DataType, that +/// is a datatype that has been named by DataType::commit. +// Programmer Binh-Minh Ribler - Oct, 2006 +//-------------------------------------------------------------------------- +DataSet::DataSet(IdComponent& obj, void* ref) : AbstractDs() +{ + IdComponent::dereference(obj, ref); +} + +//-------------------------------------------------------------------------- // Function: DataSet::getSpace ///\brief Gets a copy of the dataspace of this dataset. ///\return DataSpace instance @@ -413,12 +430,9 @@ void DataSet::fillMemBuf(void *buf, DataType& buf_type, DataSpace& space) //-------------------------------------------------------------------------- // Function: DataSet::Reference -///\brief Creates a reference to an HDF5 object or a dataset region. -///\param name - IN: Name of the object to be referenced -///\param dataspace - IN: Dataspace with selection -///\param ref_type - IN: Type of reference; default to \c H5R_DATASET_REGION -///\return A reference -///\exception H5::DataSetIException +///\brief Important!!! - This functions may not work correctly, it +/// will be removed in the near future. Please use +/// DataSet::reference instead! // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- void* DataSet::Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_type) const @@ -433,16 +447,9 @@ void* DataSet::Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_ //-------------------------------------------------------------------------- // Function: DataSet::Reference -///\brief This is an overloaded function, provided for your convenience. -/// It differs from the above function in that it only creates -/// a reference to an HDF5 object, not to a dataset region. -///\param name - IN: Name of the object to be referenced - \c char pointer -///\return A reference -///\exception H5::DataSetIException -///\par Description -// This function passes H5R_OBJECT and -1 to the protected -// function for it to pass to the C API H5Rcreate -// to create a reference to the named object. +///\brief Important!!! - This functions may not work correctly, it +/// will be removed in the near future. Please use similar +/// DataSet::reference instead! // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- void* DataSet::Reference(const char* name) const @@ -457,10 +464,9 @@ void* DataSet::Reference(const char* name) const //-------------------------------------------------------------------------- // Function: DataSet::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 +///\brief Important!!! - This functions may not work correctly, it +/// will be removed in the near future. Please use similar +/// DataSet::reference instead! // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- void* DataSet::Reference(const H5std_string& name) const @@ -471,13 +477,15 @@ void* DataSet::Reference(const H5std_string& name) const //-------------------------------------------------------------------------- // Function: DataSet::getObjType ///\brief Retrieves the type of object that an object reference points to. -///\param ref_type - IN: Type of reference to query -///\param ref - IN: Reference to query +///\param ref_type - IN: Type of reference to query, valid values are: +/// \li \c H5R_OBJECT \tReference is an object reference. +/// \li \c H5R_DATASET_REGION \tReference is a dataset region reference. +///\param ref - IN: Reference to query ///\return An object type, which can be one of the following: -/// \li \c H5G_LINK Object is a symbolic link. -/// \li \c H5G_GROUP Object is a group. -/// \li \c H5G_DATASET Object is a dataset. -/// \li \c H5G_TYPE Object is a named datatype +/// \li \c H5G_LINK (0) \tObject is a symbolic link. +/// \li \c H5G_GROUP (1) \tObject is a group. +/// \li \c H5G_DATASET (2) \tObject is a dataset. +/// \li \c H5G_TYPE Object (3) \tis a named datatype ///\exception H5::DataSetIException // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- diff --git a/c++/src/H5DataSet.h b/c++/src/H5DataSet.h index a851d3d..490b575 100644 --- a/c++/src/H5DataSet.h +++ b/c++/src/H5DataSet.h @@ -70,24 +70,27 @@ class H5_DLLCPP DataSet : public AbstractDs { int iterateElems( void* buf, const DataType& type, const DataSpace& space, H5D_operator_t op, void* op_data = NULL ); // Retrieves the type of object that an object reference points to. - H5G_obj_t getObjType(void *ref, H5R_type_t ref_type) const; + H5G_obj_t getObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const; // Retrieves a dataspace with the region pointed to selected. DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const; // Creates a reference to a named Hdf5 object or to a dataset region // in this object. - void* Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_type = H5R_DATASET_REGION) const; + void* Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_type = H5R_DATASET_REGION) const; // will be obsolete // Creates a reference to a named Hdf5 object in this object. - void* Reference(const char* name) const; - void* Reference(const H5std_string& name) const; + void* Reference(const char* name) const; // will be obsolete + void* Reference(const H5std_string& name) const; // will be obsolete + + // Opens a referenced dataset. + DataSet dereference(void* ref) const; // Returns this class name virtual H5std_string fromClass () const { return("DataSet"); } - // Creates a copy of an existing DataSet using its id. - DataSet(const hid_t existing_id); + // Creates a dataset by way of dereference. + DataSet(IdComponent& obj, void* ref); // Default constructor. DataSet(); @@ -95,6 +98,9 @@ class H5_DLLCPP DataSet : public AbstractDs { // Copy constructor. DataSet( const DataSet& original ); + // Creates a copy of an existing DataSet using its id. + DataSet(const hid_t existing_id); + // Destructor: properly terminates access to this dataset. virtual ~DataSet(); diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp index 609e2f9..52c9bf2 100644 --- a/c++/src/H5DataType.cpp +++ b/c++/src/H5DataType.cpp @@ -76,6 +76,21 @@ DataType::DataType( const H5T_class_t type_class, size_t size ) : H5Object() } //-------------------------------------------------------------------------- +// Function: DataType overload constructor - dereference +///\brief Given a reference to some object, returns that datatype +///\param obj - IN: Location reference object is in +///\param ref - IN: Reference pointer +///\parDescription +/// \c obj can be DataSet, Group, H5File, or named DataType, that +/// is a datatype that has been named by DataType::commit. +// Programmer Binh-Minh Ribler - Oct, 2006 +//-------------------------------------------------------------------------- +DataType::DataType(IdComponent& obj, void* ref) : H5Object() +{ + IdComponent::dereference(obj, ref); +} + +//-------------------------------------------------------------------------- // Function: DataType default constructor ///\brief Default constructor: Creates a stub datatype // Programmer Binh-Minh Ribler - 2000 @@ -108,7 +123,7 @@ void DataType::copy( const DataType& like_type ) close(); } catch (Exception close_error) { - throw DataTypeIException("DataType::copy", close_error.getDetailMsg()); + throw DataTypeIException(inMemFunc("copy"), close_error.getDetailMsg()); } // call C routine to copy the datatype @@ -131,10 +146,8 @@ void DataType::copy( const DataType& like_type ) DataType& DataType::operator=( const DataType& rhs ) { if (this != &rhs) - { copy(rhs); - return(*this); - } + return(*this); } //-------------------------------------------------------------------------- @@ -532,12 +545,9 @@ bool DataType::isVariableStr() const //-------------------------------------------------------------------------- // Function: DataType::Reference -///\brief Creates a reference to an HDF5 object or a dataset region. -///\param name - IN: Name of the object to be referenced -///\param dataspace - IN: Dataspace with selection -///\param ref_type - IN: Type of reference; default to \c H5R_DATASET_REGION -///\return A reference -///\exception H5::DataTypeIException +///\brief Important!!! - This functions may not work correctly, it +/// will be removed in the near future. Please use similar +/// DataType::reference instead! // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- void* DataType::Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_type) const @@ -552,16 +562,9 @@ void* DataType::Reference(const char* name, DataSpace& dataspace, H5R_type_t ref //-------------------------------------------------------------------------- // Function: DataType::Reference -///\brief This is an overloaded function, provided for your convenience. -/// It differs from the above function in that it only creates -/// a reference to an HDF5 object, not to a dataset region. -///\param name - IN: Name of the object to be referenced -///\return A reference -///\exception H5::DataTypeIException -///\par Description -// This function passes H5R_OBJECT and -1 to the protected -// function for it to pass to the C API H5Rcreate -// to create a reference to the named object. +///\brief Important!!! - This functions may not work correctly, it +/// will be removed in the near future. Please use similar +/// DataType::reference instead! // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- void* DataType::Reference(const char* name) const @@ -576,10 +579,9 @@ void* DataType::Reference(const char* name) const //-------------------------------------------------------------------------- // 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 +///\brief Important!!! - This functions may not work correctly, it +/// will be removed in the near future. Please use similar +/// DataType::reference instead! // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- void* DataType::Reference(const H5std_string& name) const diff --git a/c++/src/H5DataType.h b/c++/src/H5DataType.h index 5e92edc..bb9b317 100644 --- a/c++/src/H5DataType.h +++ b/c++/src/H5DataType.h @@ -28,6 +28,9 @@ class H5_DLLCPP DataType : public H5Object { // Copy constructor: makes a copy of the original object DataType( const DataType& original ); + // Creates a datatype by way of dereference. + DataType(IdComponent& obj, void* ref); + // Closes this datatype. virtual void close(); @@ -90,16 +93,16 @@ class H5_DLLCPP DataType : public H5Object { // Checks whether this datatype is a variable-length string. bool isVariableStr() const; - // Creates a reference to a named Hdf5 object in this object. - void* Reference(const char* name) const; - void* Reference(const H5std_string& name) const; - - // Creates a reference to a named Hdf5 object or to a dataset region + // Creates a reference to a named HDF5 object or to a dataset region // in this object. - void* Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_type = H5R_DATASET_REGION) const; + void* Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_type = H5R_DATASET_REGION) const; // will be obsolete + + // Creates a reference to a named HDF5 object in this object. + void* Reference(const char* name) const; // will be obsolete + void* Reference(const H5std_string& name) const; // will be obsolete // Retrieves the type of object that an object reference points to. - H5G_obj_t getObjType(void *ref, H5R_type_t ref_type) const; + H5G_obj_t getObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const; // Retrieves a dataspace with the region pointed to selected. DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const; @@ -115,7 +118,6 @@ class H5_DLLCPP DataType : public H5Object { // Destructor: properly terminates access to this datatype. virtual ~DataType(); - }; #ifndef H5_NO_NAMESPACE } diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp index 7132105..ca2aea8 100644 --- a/c++/src/H5File.cpp +++ b/c++/src/H5File.cpp @@ -250,8 +250,10 @@ void H5File::openFile(const H5std_string& name, unsigned int flags, const FileAc // Note: This wrapper doesn't seem right regarding the 'id' and should // be investigated. BMR - 2/20/2005 // Modification -// Replaced resetIdComponent with decRefCount to use C library -// ID reference counting mechanism - BMR, Jun 1, 2004 +// - Replaced resetIdComponent() with decRefCount() to use C +// library ID reference counting mechanism - BMR, Feb 20, 2005 +// - Replaced decRefCount with close() to let the C library +// handle the reference counting - BMR, Jun 1, 2006 //-------------------------------------------------------------------------- void H5File::reOpen() { @@ -501,14 +503,9 @@ H5std_string H5File::getFileName() const //-------------------------------------------------------------------------- // Function: H5File::Reference -///\brief Creates a reference to an Hdf5 object or a dataset region. -///\param name - IN: Name of the object to be referenced -///\param dataspace - IN: Dataspace with selection -///\param ref_type - IN: Type of reference; default to \c H5R_DATASET_REGION -///\return A reference -///\exception H5::FileIException -///\par Description -/// Note that name must be an absolute path to the object in the file. +///\brief Important!!! - This functions does not work correctly, it +/// will be removed in the near future. Please use +/// H5File::reference instead! // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- void* H5File::Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_type) const @@ -523,19 +520,9 @@ void* H5File::Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_t //-------------------------------------------------------------------------- // Function: H5File::Reference -///\brief This is an overloaded function, provided for your convenience. -/// It differs from the above function in that it only creates -/// a reference to an HDF5 object, not to a dataset region. -///\param name - IN: Name of the object to be referenced -///\return A reference -///\exception H5::FileIException -///\par Description -// This function passes H5R_OBJECT and -1 to the protected -// function for it to pass to the C API H5Rcreate -// to create a reference to the named object. -///\par -/// Note that, for H5File, name must be an absolute path to the -/// object in the file. +///\brief Important!!! - This functions does not work correctly, it +/// will be removed in the near future. Please use similar +/// H5File::reference instead! // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- void* H5File::Reference(const char* name) const @@ -550,10 +537,9 @@ void* H5File::Reference(const char* name) const //-------------------------------------------------------------------------- // 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 +///\brief Important!!! - This functions does not work correctly, it +/// will be removed in the near future. Please use similar +/// H5File::reference instead! // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- void* H5File::Reference(const H5std_string& name) const @@ -565,7 +551,9 @@ void* H5File::Reference(const H5std_string& name) const // Function: H5File::getObjType ///\brief Retrieves the type of object that an object reference points to. ///\param ref - IN: Reference to query -///\param ref_type - IN: Type of reference to query +///\param ref_type - IN: Type of reference, valid values are: +/// \li \c H5R_OBJECT \tReference is an object reference. +/// \li \c H5R_DATASET_REGION \tReference is a dataset region reference. ///\return Object type, which can be one of the following: /// \li \c H5G_LINK - Object is a symbolic link. /// \li \c H5G_GROUP - Object is a group. @@ -685,8 +673,10 @@ void H5File::throwException(const H5std_string& func_name, const H5std_string& m ///\brief Properly terminates access to this file. // Programmer Binh-Minh Ribler - 2000 // Modification -// Replaced resetIdComponent with decRefCount to use C library -// ID reference counting mechanism - BMR, Jun 1, 2004 +// - Replaced resetIdComponent() with decRefCount() to use C +// library ID reference counting mechanism - BMR, Feb 20, 2005 +// - Replaced decRefCount with close() to let the C library +// handle the reference counting - BMR, Jun 1, 2006 //-------------------------------------------------------------------------- H5File::~H5File() { diff --git a/c++/src/H5File.h b/c++/src/H5File.h index e489271..1c14f3a 100644 --- a/c++/src/H5File.h +++ b/c++/src/H5File.h @@ -67,7 +67,7 @@ class H5_DLLCPP H5File : public IdComponent, public CommonFG { void getObjIDs(unsigned types, int max_objs, hid_t *oid_list) const; // Retrieves the type of object that an object reference points to. - H5G_obj_t getObjType(void *ref, H5R_type_t ref_type) const; + H5G_obj_t getObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const; // Retrieves a dataspace with the region pointed to selected. DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const; @@ -84,13 +84,13 @@ class H5_DLLCPP H5File : public IdComponent, public CommonFG { void reOpen(); // added for better name void reopen(); - // Creates a reference to a named Hdf5 object or to a dataset region + // Creates a reference to a named HDF5 object or to a dataset region // in this object. - void* Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_type = H5R_DATASET_REGION) const; + void* Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_type = H5R_DATASET_REGION) const; // will be obsolete // Creates a reference to a named Hdf5 object in this object. - void* Reference(const char* name) const; - void* Reference(const H5std_string& name) const; + void* Reference(const char* name) const; // will be obsolete + void* Reference(const H5std_string& name) const; // will be obsolete // Returns this class name virtual H5std_string fromClass () const { return("H5File"); } diff --git a/c++/src/H5Group.cpp b/c++/src/H5Group.cpp index 3edcc20..92f82fc 100644 --- a/c++/src/H5Group.cpp +++ b/c++/src/H5Group.cpp @@ -79,13 +79,25 @@ hid_t Group::getLocId() const Group::Group( const hid_t group_id ) : H5Object( group_id ) {} //-------------------------------------------------------------------------- +// Function: Group overload constructor - dereference +///\brief Given a reference to some object, returns that group +/// obj - IN: Location reference object is in +///\param ref - IN: Reference pointer +///\parDescription +/// \c obj can be DataSet, Group, H5File, or named DataType, that +/// is a datatype that has been named by DataType::commit. +// Programmer Binh-Minh Ribler - Oct, 2006 +//-------------------------------------------------------------------------- +Group::Group(IdComponent& obj, void* ref) : H5Object() +{ + IdComponent::dereference(obj, ref); +} + +//-------------------------------------------------------------------------- // Function: Group::Reference -///\brief Creates a reference to an HDF5 object or a dataset region. -///\param name - IN: Name of the object to be referenced -///\param dataspace - IN: Dataspace with selection -///\param ref_type - IN: Type of reference; default to \c H5R_DATASET_REGION -///\return A reference -///\exception H5::GroupIException +///\brief Important!!! - This functions may not work correctly, it +/// will be removed in the near future. Please use similar +/// Group::reference instead! // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- void* Group::Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_type) const @@ -100,16 +112,9 @@ void* Group::Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_ty //-------------------------------------------------------------------------- // Function: Group::Reference -///\brief This is an overloaded function, provided for your convenience. -/// It differs from the above function in that it only creates -/// a reference to an HDF5 object, not to a dataset region. -///\param name - IN: Name of the object to be referenced -///\return A reference -///\exception H5::GroupIException -///\par Description -// This function passes H5R_OBJECT and -1 to the protected -// function for it to pass to the C API H5Rcreate -// to create a reference to the named object. +///\brief Important!!! - This functions may not work correctly, it +/// will be removed in the near future. Please use similar +/// Group::reference instead! // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- void* Group::Reference(const char* name) const @@ -124,10 +129,9 @@ void* Group::Reference(const char* name) const //-------------------------------------------------------------------------- // 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 +///\brief Important!!! - This functions may not work correctly, it +/// will be removed in the near future. Please use similar +/// Group::reference instead! // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- void* Group::Reference(const H5std_string& name) const @@ -138,8 +142,10 @@ void* Group::Reference(const H5std_string& name) const //-------------------------------------------------------------------------- // Function: Group::getObjType ///\brief Retrieves the type of object that an object reference points to. -///\param ref - IN: Reference to query -///\param ref_type - IN: Type of reference to query +///\param ref - IN: Reference to query +///\param ref_type - IN: Type of reference to query, valid values are: +/// \li \c H5R_OBJECT \tReference is an object reference. +/// \li \c H5R_DATASET_REGION \tReference is a dataset region reference. ///\return An object type, which can be one of the following: /// H5G_LINK Object is a symbolic link. /// H5G_GROUP Object is a group. @@ -225,8 +231,10 @@ void Group::throwException(const H5std_string& func_name, const H5std_string& ms ///\brief Properly terminates access to this group. // Programmer Binh-Minh Ribler - 2000 // Modification -// Replaced resetIdComponent with decRefCount to use C library -// ID reference counting mechanism - BMR, Jun 1, 2004 +// - Replaced resetIdComponent() with decRefCount() to use C +// library ID reference counting mechanism - BMR, Feb 20, 2005 +// - Replaced decRefCount with close() to let the C library +// handle the reference counting - BMR, Jun 1, 2006 //-------------------------------------------------------------------------- Group::~Group() { diff --git a/c++/src/H5Group.h b/c++/src/H5Group.h index 38c559d..cf5e84a 100644 --- a/c++/src/H5Group.h +++ b/c++/src/H5Group.h @@ -26,18 +26,18 @@ class H5_DLLCPP Group : public H5Object, public CommonFG { virtual void close(); // Retrieves the type of object that an object reference points to. - H5G_obj_t getObjType(void *ref, H5R_type_t ref_type) const; + H5G_obj_t getObjType(void *ref, H5R_type_t ref_type = H5R_OBJECT) const; // Retrieves a dataspace with the region pointed to selected. DataSpace getRegion(void *ref, H5R_type_t ref_type = H5R_DATASET_REGION) const; // Creates a reference to a named Hdf5 object or to a dataset region // in this object. - void* Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_type = H5R_DATASET_REGION) const; + void* Reference(const char* name, DataSpace& dataspace, H5R_type_t ref_type = H5R_DATASET_REGION) const; // will be obsolete // Creates a reference to a named Hdf5 object in this object. - void* Reference(const char* name) const; - void* Reference(const H5std_string& name) const; + void* Reference(const char* name) const; // will be obsolete + void* Reference(const H5std_string& name) const; // will be obsolete // Returns this class name virtual H5std_string fromClass () const { return("Group"); } @@ -48,6 +48,9 @@ class H5_DLLCPP Group : public H5Object, public CommonFG { // for CommonFG to get the file id. virtual hid_t getLocId() const; + // Creates a group by way of dereference. + Group(IdComponent& obj, void* ref); + // default constructor Group(); diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp index 03c7809..c487ee6 100644 --- a/c++/src/H5IdComponent.cpp +++ b/c++/src/H5IdComponent.cpp @@ -11,6 +11,7 @@ * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + #ifdef H5_VMS #include <iostream> #endif /*H5_VMS*/ @@ -21,6 +22,7 @@ #include "H5Exception.h" #include "H5Library.h" #include "H5IdComponent.h" +#include "H5DataSpace.h" #ifndef H5_NO_NAMESPACE namespace H5 { @@ -316,19 +318,121 @@ H5std_string IdComponent::p_get_file_name() const // name - IN: Name of the object to be referenced // dataspace - IN: Dataspace with selection // ref_type - IN: Type of reference; default to \c H5R_DATASET_REGION +// Exception H5::IdComponentException +// Programmer Binh-Minh Ribler - May, 2004 +//-------------------------------------------------------------------------- +void IdComponent::p_reference(void* ref, const char* name, hid_t space_id, H5R_type_t ref_type) const +{ + herr_t ret_value = H5Rcreate(ref, id, name, ref_type, space_id); + if (ret_value < 0) + { + throw IdComponentException("", "H5Rcreate failed"); + } +} + +//-------------------------------------------------------------------------- +// Function: IdComponent::reference +///\brief Creates a reference to an HDF5 object or a dataset region. +///\param ref - IN: Reference pointer +///\param name - IN: Name of the object to be referenced +///\param dataspace - IN: Dataspace with selection +///\param ref_type - IN: Type of reference to query, valid values are: +/// \li \c H5R_OBJECT \tReference is an object reference. +/// \li \c H5R_DATASET_REGION \tReference is a dataset region +/// reference. - this is the default +///\exception H5::IdComponentException +// Programmer Binh-Minh Ribler - May, 2004 +//-------------------------------------------------------------------------- +void IdComponent::reference(void* ref, const char* name, const DataSpace& dataspace, H5R_type_t ref_type) const +{ + try { + p_reference(ref, name, dataspace.getId(), ref_type); + } + catch (IdComponentException E) { + throw IdComponentException("IdComponent::reference", E.getDetailMsg()); + } +} + +//-------------------------------------------------------------------------- +// Function: IdComponent::reference +///\brief This is an overloaded function, provided for your convenience. +/// It differs from the above function in that it only creates +/// a reference to an HDF5 object, not to a dataset region. +///\param ref - IN: Reference pointer +///\param name - IN: Name of the object to be referenced - \c char pointer +///\exception H5::IdComponentException +///\par Description +// This function passes H5R_OBJECT and -1 to the protected +// function for it to pass to the C API H5Rcreate +// to create a reference to the named object. +// Programmer Binh-Minh Ribler - May, 2004 +//-------------------------------------------------------------------------- +void IdComponent::reference(void* ref, const char* name) const +{ + try { + p_reference(ref, name, -1, H5R_OBJECT); + } + catch (IdComponentException E) { + throw IdComponentException("IdComponent::reference", E.getDetailMsg()); + } +} + +//-------------------------------------------------------------------------- +// Function: IdComponent::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 ref - IN: Reference pointer +///\param name - IN: Name of the object to be referenced - \c std::string +// Programmer Binh-Minh Ribler - May, 2004 +//-------------------------------------------------------------------------- +void IdComponent::reference(void* ref, const H5std_string& name) const +{ + reference(ref, name.c_str()); +} + +//-------------------------------------------------------------------------- +// Function: IdComponent::p_reference (protected) +// Purpose Creates a reference to an HDF5 object or a dataset region. +// Parameters +// name - IN: Name of the object to be referenced +// dataspace - IN: Dataspace with selection +// ref_type - IN: Type of reference; default to \c H5R_DATASET_REGION // Return A reference // Exception H5::IdComponentException +// Notes This function is incorrect, and will be removed in the near +// future after notifying users of the new APIs ::reference's. +// BMR - Oct 8, 2006 // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- void* IdComponent::p_reference(const char* name, hid_t space_id, H5R_type_t ref_type) const { - void *ref=NULL; - herr_t ret_value = H5Rcreate(ref, id, name, ref_type, space_id); + hobj_ref_t ref; + herr_t ret_value = H5Rcreate(&ref, id, name, ref_type, space_id); if (ret_value < 0) { throw IdComponentException("", "H5Rcreate failed"); } - return(ref); + return (reinterpret_cast<void*>(ref)); +} + +//-------------------------------------------------------------------------- +// Function: IdComponent::dereference +// Purpose Opens the HDF5 object referenced. +// Parameters +// obj - IN: Dataset reference object is in or location of +// object that the dataset is located within. +// ref - IN: Reference pointer +// Exception H5::IdComponentException +// Programmer Binh-Minh Ribler - Oct, 2006 +//-------------------------------------------------------------------------- +void IdComponent::dereference(IdComponent& obj, void* ref) +{ + id = H5Rdereference(obj.getId(), H5R_OBJECT, ref); + if (id < 0) + { + throw IdComponentException("", "H5Rdereference failed"); + } } //-------------------------------------------------------------------------- @@ -347,10 +451,19 @@ void* IdComponent::p_reference(const char* name, hid_t space_id, H5R_type_t ref_ //-------------------------------------------------------------------------- H5G_obj_t IdComponent::p_get_obj_type(void *ref, H5R_type_t ref_type) const { +#ifdef H5_WANT_H5_V1_4_COMPAT + H5G_obj_t obj_type = H5Rget_object_type(id, ref); +#else H5G_obj_t obj_type = H5Rget_obj_type(id, ref_type, ref); +#endif + if (obj_type == H5G_UNKNOWN) { - throw IdComponentException("", "H5R_get_obj_type failed"); +#ifdef H5_WANT_H5_V1_4_COMPAT + throw IdComponentException("", "H5Rget_object_type failed"); +#else + throw IdComponentException("", "H5Rget_obj_type failed"); +#endif } return(obj_type); } @@ -395,6 +508,7 @@ bool IdComponent::p_valid_id(const hid_t obj_id) const else return true; } + #endif // DOXYGEN_SHOULD_SKIP_THIS #ifndef H5_NO_NAMESPACE diff --git a/c++/src/H5IdComponent.h b/c++/src/H5IdComponent.h index 18bcacb..d353f11 100644 --- a/c++/src/H5IdComponent.h +++ b/c++/src/H5IdComponent.h @@ -22,6 +22,7 @@ namespace H5 { #endif +class DataSpace; class H5_DLLCPP IdComponent { public: // Increment reference counter. @@ -36,12 +37,20 @@ class H5_DLLCPP IdComponent { int getCounter(const hid_t obj_id) const; int getCounter() const; - // Returns an HDF object type, given the object id. + // Returns an HDF5 object type, given the object id. static H5I_type_t getHDFObjType(const hid_t obj_id); - // Assignment operator + // Assignment operator. IdComponent& operator=( const IdComponent& rhs ); + void reference(void* ref, const char* name, const DataSpace& dataspace, + H5R_type_t ref_type = H5R_DATASET_REGION) const; + void reference(void* ref, const char* name) const; + void reference(void* ref, const H5std_string& name) const; + + // Open a referenced HDF5 object. + void dereference(IdComponent& obj, void* ref); + // Sets the identifier of this object to a new value. void setId(const hid_t new_id); @@ -85,7 +94,8 @@ class H5_DLLCPP IdComponent { 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; + void p_reference(void* ref, const char* name, hid_t space_id, H5R_type_t ref_type) const; + void* p_reference(const char* name, hid_t space_id, H5R_type_t ref_type) const; // will be removed // 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; diff --git a/c++/src/H5PredType.cpp b/c++/src/H5PredType.cpp index 50f3f16..bb0b688 100644 --- a/c++/src/H5PredType.cpp +++ b/c++/src/H5PredType.cpp @@ -258,10 +258,8 @@ const PredType PredType::NATIVE_UINT_FAST64( H5T_NATIVE_UINT_FAST64 ); PredType& PredType::operator=( const PredType& rhs ) { if (this != &rhs) - { copy(rhs); - return(*this); - } + return(*this); } #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp index d84c98f..b50b907 100644 --- a/c++/src/H5PropList.cpp +++ b/c++/src/H5PropList.cpp @@ -128,10 +128,8 @@ void PropList::copy( const PropList& like_plist ) PropList& PropList::operator=( const PropList& rhs ) { if (this != &rhs) - { copy(rhs); - return(*this); - } + return(*this); } //-------------------------------------------------------------------------- diff --git a/c++/src/H5StrType.cpp b/c++/src/H5StrType.cpp index 68ac1f3..849f345 100644 --- a/c++/src/H5StrType.cpp +++ b/c++/src/H5StrType.cpp @@ -163,9 +163,9 @@ H5T_cset_t StrType::getCset() const //-------------------------------------------------------------------------- // Function: StrType::setCset ///\brief Sets character set to be used. -///\param cset - IN: character set type -///\exception H5::DataTypeIException +///\param cset - IN: character set type, which can be: /// \li \c H5T_CSET_ASCII (0) - Character set is US ASCII. +///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- void StrType::setCset( H5T_cset_t cset ) const |