summaryrefslogtreecommitdiffstats
path: root/c++/src/H5CommonFG.h
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2000-12-13 13:06:57 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2000-12-13 13:06:57 (GMT)
commit1aec17231d77f4e4e2bc924b2aefd4541d046cca (patch)
tree1ebe4bc4fc5e70bd5a4a611f2d6fcdce488f1d9b /c++/src/H5CommonFG.h
parent9cbeb3c53f0d34d8e2b7cca0fbaab8ec55179066 (diff)
downloadhdf5-1aec17231d77f4e4e2bc924b2aefd4541d046cca.zip
hdf5-1aec17231d77f4e4e2bc924b2aefd4541d046cca.tar.gz
hdf5-1aec17231d77f4e4e2bc924b2aefd4541d046cca.tar.bz2
[svn-r3122] Purpose:
Fix and improve Description: - Put functions that are common to H5File and Group into a prototype class, CommonFG. I didn't do that before because of the fear of the consequences of multiple inheritance, since H5File and Group already inherit from different super classes. I recently read a C++ book and learned to use MI more safely. This change reduced some more of code redundancy. - Added missing const to some function parameters Platforms tested: Solaris/CC 5.0 (arabica)
Diffstat (limited to 'c++/src/H5CommonFG.h')
-rw-r--r--c++/src/H5CommonFG.h129
1 files changed, 94 insertions, 35 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