diff options
Diffstat (limited to 'c++')
-rw-r--r-- | c++/src/H5CommonFG.h | 129 | ||||
-rw-r--r-- | c++/src/H5Cpp.h | 1 | ||||
-rw-r--r-- | c++/src/H5File.h | 88 | ||||
-rw-r--r-- | c++/src/H5Group.h | 89 | ||||
-rw-r--r-- | c++/src/H5IdComponent.h | 2 | ||||
-rw-r--r-- | c++/src/H5Include.h | 1 |
6 files changed, 106 insertions, 204 deletions
diff --git a/c++/src/H5CommonFG.h b/c++/src/H5CommonFG.h index 68c6bec..2eb532d 100644 --- a/c++/src/H5CommonFG.h +++ b/c++/src/H5CommonFG.h @@ -1,12 +1,7 @@ /* -These functions provide code that are common to both H5File and Group. -Some of the member functions of these two classes call a common function -and provide it a file or group id to perform a task that can be done on -either an H5File or Group instance. 10/31/00 - -The name of the functions ends with a T because these functions were -template functions until it was realized that more than one of our -supported platforms have not supported template functions. +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. */ #ifndef _CommonFG_H @@ -16,45 +11,109 @@ supported platforms have not supported template functions. namespace H5 { #endif -// Creates a new group at this location which can be a file or another group. -Group createGroupT( const hid_t loc_id, const string name, size_t size_hint ); +class Group; +class H5File; +class CommonFG { + public: + // Creates a new group at this location which can be a file or another group. + Group createGroup( const string& name, size_t size_hint = 0 ) const; + Group createGroup( const char* name, size_t size_hint = 0 ) const; -// Opens an existing group in a location which can be a file or another group -Group openGroupT( const hid_t loc_id, const string name ); + // Opens an existing group in a location which can be a file or another group + Group openGroup( const string& name ) const; + Group openGroup( const char* name ) const; -// Creates a new dataset at this location. -DataSet createDataSetT( const hid_t loc_id, const string name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist ); + // Creates a new dataset at this location. + DataSet createDataSet( const string& name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT ) const; + DataSet createDataSet( const char* name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT ) const; -// Opens an existing dataset at this location. -DataSet openDataSetT( const hid_t loc_id, const string name ); + // Opens an existing dataset at this location. + DataSet openDataSet( const string& name ) const; + DataSet openDataSet( const char* name ) const; -// Creates a link of the specified type from new_name to current_name; -// both names are interpreted relative to the specified location id -void linkT( const hid_t loc_id, H5G_link_t link_type, const string curr_name, const string new_name ); + // Creates a link of the specified type from new_name to current_name; + // both names are interpreted relative to the specified location id + void link( H5G_link_t link_type, const string& curr_name, const string& new_name ) const; + void link( H5G_link_t link_type, const char* curr_name, const char* new_name ) const; -// Removes the specified name at this location. -void unlinkT( const hid_t loc_id, const string name ); + // Removes the specified name at this location. + void unlink( const string& name ) const; + void unlink( const char* name ) const; -// Renames an object at this location. -void moveT( const hid_t loc_id, const string src, const string dst ); + // Get id of the location, either group or file - pure virtual so + // the subclass can get the correct id + virtual hid_t getLocId() const = 0; -// Returns information about an object -void getObjinfoT( const hid_t loc_id, const string name, hbool_t follow_link, H5G_stat_t& statbuf ); + // Renames an object at this location. + void move( const string& src, const string& dst ) const; + void move( const char* src, const char* dst ) const; -// Returns the name of the object that the symbolic link points to. -string getLinkvalT( const hid_t loc_id, const string name, size_t size ); + // Returns information about an object + 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; -// Sets the comment for an object specified by its name -void setCommentT( const hid_t loc_id, const string name, const string comment ); + // Returns the name of the 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; -// Retrieves comment for specified object -string getCommentT( const hid_t loc_id, const string name, size_t bufsize ); + // Sets the comment for an object specified by its name + void setComment( const string& name, const string& comment ) const; + void setComment( const char* name, const char* comment ) const; -// Mounts the file 'child' onto this group -void mountT( const hid_t loc_id, const string name, hid_t child_id, PropList& plist ); + // Retrieves comment for specified object + 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 + 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 + void unmount( const string& name ) const; + void unmount( const char* name ) const; + + // Iterates over the elements of this group - not implemented in + // C++ style yet + 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 + DataType openDataType( const string& name ) const; + DataType openDataType( const char* name ) const; + + // Opens a named enumeration datatype in this file + EnumType openEnumType( const string& name ) const; + EnumType openEnumType( const char* name ) const; + + // Opens a named compound datatype in this file + CompType openCompType( const string& name ) const; + CompType openCompType( const char* name ) const; + + // Opens a named integer datatype in this file + IntType openIntType( const string& name ) const; + IntType openIntType( const char* name ) const; + + // Opens a named floating-point datatype in this file + FloatType openFloatType( const string& name ) const; + FloatType openFloatType( const char* name ) const; + + // Opens a named string datatype in this file + StrType openStrType( const string& name ) const; + StrType openStrType( const char* name ) const; + + // for H5File and Group to throw appropriate exception + virtual void throwException() const = 0; + + CommonFG(); + + virtual ~CommonFG(); + + private: + // Common code for member functions openXxxType + hid_t p_openDataType( const char* name ) const; + +}; // end of CommonFG declaration -// Unmounts the file named 'name' from this parent group -void unmountT( const hid_t loc_id, const string name ); #ifndef H5_NO_NAMESPACE } #endif diff --git a/c++/src/H5Cpp.h b/c++/src/H5Cpp.h index 6188b67..a8409b5 100644 --- a/c++/src/H5Cpp.h +++ b/c++/src/H5Cpp.h @@ -23,6 +23,7 @@ #include "H5StrType.h" #include "H5CompType.h" #include "H5DataSet.h" +#include "H5CommonFG.h" #include "H5Group.h" #include "H5File.h" #include "H5Library.h" diff --git a/c++/src/H5File.h b/c++/src/H5File.h index 782a90d..dfca992 100644 --- a/c++/src/H5File.h +++ b/c++/src/H5File.h @@ -5,7 +5,7 @@ namespace H5 { #endif -class H5File : public IdComponent { +class H5File : public IdComponent, public CommonFG { public: // copy constructor: makes a copy of the original H5File object. H5File(const H5File& original ); @@ -18,17 +18,11 @@ class H5File : public IdComponent { const FileCreatPropList& create_plist = FileCreatPropList::DEFAULT, const FileAccPropList& access_plist = FileAccPropList::DEFAULT ); - // Sets and gets H5File's data member - //void setId( hid_t new_file_id ); - //hid_t getId() const; + // Gets the file id + virtual hid_t getLocId() const; - // Creates a new group in this file - Group createGroup( const string& name, size_t size_hint = 0 ) const; - Group createGroup( const char* name, size_t size_hint = 0 ) const; - - // Opens an existing group in this file - Group openGroup( const string& name ) const; - Group openGroup( const char* name ) const; + // Throw file exception + virtual void throwException() const; // Determines if a file, specified by its name, is in HDF5 format static bool isHdf5(const string& name ); @@ -37,90 +31,18 @@ class H5File : public IdComponent { // Reopens this file void reopen(); - // Creates a new dataset in this file - DataSet createDataSet( const string& name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT ) const; - DataSet createDataSet( const char* name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT ) const; - - // Opens a existing dataset in this file - DataSet openDataSet( const string& name ) const; - DataSet openDataSet( const char* name ) const; - - // Opens a generic named datatype in this file - DataType openDataType( const string& name ) const; - DataType openDataType( const char* name ) const; - - // Opens a named enumeration datatype in this file - EnumType openEnumType( const string& name ) const; - EnumType openEnumType( const char* name ) const; - - // Opens a named compound datatype in this file - CompType openCompType( const string& name ) const; - CompType openCompType( const char* name ) const; - - // Opens a named integer datatype in this file - IntType openIntType( const string& name ) const; - IntType openIntType( const char* name ) const; - - // Opens a named floating-point datatype in this file - FloatType openFloatType( const string& name ) const; - FloatType openFloatType( const char* name ) const; - - // Opens a named string datatype in this file - StrType openStrType( const string& name ) const; - StrType openStrType( const char* name ) const; - // Gets the creation property list of this file FileCreatPropList getCreatePlist() const; // Gets the access property list of this file FileAccPropList getAccessPlist() const; - // Creates a link from new_name to current_name in this file - void link( H5G_link_t link_type, const string& curr_name, const string& new_name ) const; - void link( H5G_link_t link_type, const char* curr_name, const char* new_name ) const; - - // Removes a name linked to this file - void unlink( const string& name ) const; - void unlink( const char* name ) const; - - // Renames an object within this file - void move( const string& src, const string& dst ) const; - void move( const char* src, const char* dst ) const; - - // Retrieves information about an object given its name and link - 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 'name' - // 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 - void setComment( const string& name, const string& comment ) const; - void setComment( const char* name, const char* comment ) const; - - // Gets the comment of an object specified by its name - string getComment( const string& name, size_t bufsize ) const; - string getComment( const char* name, size_t bufsize ) const; - - // Mounts a file, specified by its name, to this file - void mount( const string& name, H5File& child, PropList& plist ) const; - void mount( const char* name, H5File& child, PropList& plist ) const; - - // Unmounts a file, specified by its name, from this file - void unmount( const string& name ) const; - void unmount( const char* name ) const; - // Used by the API to appropriately close a file void p_close() const; virtual ~H5File(); private: - // Common code for member functions openXxxType - templates, maybe??? - hid_t p_openDataType( const char* name ) const; - // This function is private and contains common code between the // constructors taking a string or a char* void getFile( const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist ); diff --git a/c++/src/H5Group.h b/c++/src/H5Group.h index 6246aa4..66578b5 100644 --- a/c++/src/H5Group.h +++ b/c++/src/H5Group.h @@ -5,7 +5,7 @@ namespace H5 { #endif -class Group : public H5Object { +class Group : public H5Object, public CommonFG { public: // default constructor Group(); @@ -13,86 +13,11 @@ class Group : public H5Object { // Copy constructor: makes a copy of the original object Group( const Group& original ); - // Creates a group in this group - Group createGroup( const string& name, size_t size_hint = 0 ); - Group createGroup( const char* name, size_t size_hint = 0 ); + // for CommonFG to get the file id + virtual hid_t getLocId() const; - // Opens an existing group in this group - Group openGroup( const string& name ); - Group openGroup( const char* name ); - - // Creates a dataset in this group - DataSet createDataSet( const string& name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT ); - DataSet createDataSet( const char* name, const DataType& data_type, const DataSpace& data_space, const DSetCreatPropList& create_plist = DSetCreatPropList::DEFAULT ); - - // Opens a dataset in this group - DataSet openDataSet( const string& name ); - DataSet openDataSet( const char* name ); - - // Opens a generic named datatype in this group. - DataType openDataType( const string& name ) const; - DataType openDataType( const char* name ) const; - - // Opens a named enumeration datatype in this group. - EnumType openEnumType( const string& name ) const; - EnumType openEnumType( const char* name ) const; - - // Opens a named compound datatype in this group. - CompType openCompType( const string& name ) const; - CompType openCompType( const char* name ) const; - - // Opens a named integer datatype in this group. - IntType openIntType( const string& name ) const; - IntType openIntType( const char* name ) const; - - // Opens a named floating-point datatype in this group. - FloatType openFloatType( const string& name ) const; - FloatType openFloatType( const char* name ) const; - - // Opens a named string datatype in this group. - StrType openStrType( const string& name ) const; - StrType openStrType( const char* name ) const; - - // Creates a link from new_name to current_name in this group. - void link( H5G_link_t link_type, const string& curr_name, const string& new_name ); - void link( H5G_link_t link_type, const char* curr_name, const char* new_name ); - - // Removes a name linked to this group. - void unlink( const string& name ); - void unlink( const char* name ); - - // Iterates over the elements of this group - not implemented in - // C++ style yet - 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 ); - - // Renames an object within this group. - void move( const string& src, const string& dst ); - void move( const char* src, const char* dst ); - - // Retrieves information about the named object. - void getObjinfo( const string& name, hbool_t follow_link, H5G_stat_t& statbuf ); - void getObjinfo( const char* name, hbool_t follow_link, H5G_stat_t& statbuf ); - - // Returns the name of the object that the symbolic link points to. - string getLinkval( const string& name, size_t size ); - string getLinkval( const char* name, size_t size ); - - // Sets comment for an object specified by its name. - void setComment( const string& name, const string& comment ); - void setComment( const char* name, const char* comment ); - - // Gets the comment of an object specified by its name. - string getComment( const string& name, size_t bufsize ); - string getComment( const char* name, size_t bufsize ); - - // Mounts the file 'child' onto this group. - void mount( const string& name, H5File& child, PropList& plist); - void mount( const char* name, H5File& child, PropList& plist); - - // Unmounts the file named 'name' from this parent group. - void unmount( const string& name ); - void unmount( const char* name ); + // Throw group exception + virtual void throwException() const; // Used by the API to appropriately close a group void p_close() const; @@ -104,10 +29,6 @@ class Group : public H5Object { // to return a Group; will not be published; maybe, use friend???) Group( const hid_t group_id ); - private: - // Common code for member functions openXxxType - templates, maybe??? - hid_t p_openDataType( const char* name ) const; - }; #ifndef H5_NO_NAMESPACE } diff --git a/c++/src/H5IdComponent.h b/c++/src/H5IdComponent.h index 2c8b88f..3ab341c 100644 --- a/c++/src/H5IdComponent.h +++ b/c++/src/H5IdComponent.h @@ -12,7 +12,7 @@ class IdComponent { public: // Parent classes must reset the current IdComponent copy // before setting new id to control reference count - void setId( const hid_t new_id ); + void setId( hid_t new_id ); // Pure virtual function so appropriate close function can // be called by subclasses' for the corresponding object diff --git a/c++/src/H5Include.h b/c++/src/H5Include.h index c3ff064..0a1a3d3 100644 --- a/c++/src/H5Include.h +++ b/c++/src/H5Include.h @@ -5,4 +5,3 @@ #endif #include <hdf5.h> - |