summaryrefslogtreecommitdiffstats
path: root/c++/src/H5IdComponent.h
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2000-11-14 21:30:12 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2000-11-14 21:30:12 (GMT)
commit92041a68656c59813619ae1f26ed211b7f028e86 (patch)
treeaaa3256c9a9f0adde21570eac9254f7ce00450b1 /c++/src/H5IdComponent.h
parent36acd5381e3977164e0d6d666f8ce97cc53f9387 (diff)
downloadhdf5-92041a68656c59813619ae1f26ed211b7f028e86.zip
hdf5-92041a68656c59813619ae1f26ed211b7f028e86.tar.gz
hdf5-92041a68656c59813619ae1f26ed211b7f028e86.tar.bz2
[svn-r2897] Purpose:
C++ API for 1.3.x branch Description: The *.C and *.h files named different than those in 1.2.x. They are in the form: 'H5' + classname, or just classname if the classname is already prefixed with 'H5' to avoid ambiguity in documentation context. This version has several hidden bugs fixed and an improvement on the reference counting approach. The classes and their inheritance structure are listed below: --------------------------------------- H5Library Exception RefCounter IdComponent H5File DataSpace H5Object Group AbstractDs DataSet Attribute DataType PredType EnumType CompType AtomType StrType IntType FloatType PropList FileCreatPropList FileAccPropList DSetCreatPropList DSetMemXferPropList --------------------------------------- IdComponent uses RefCounter to keep track of opened objects so proper termination of HDF5 objects can be maintained. Each class has a .h file containing the class declaration and a .C file containing its definition. In addition to the classes files, the following files do not have class information: - H5Cpp.h: header file to be included in user's application - H5Idtemplates.h: contains a template function used by several classes - H5Classes.h: contains forward class declarations - H5CommonFG.*: contains common code used by classes H5File and Group - H5Include.h: contains the hdf5.h header file and the #undef RCSID to work around the problem: multiple defined RcsId - H5Alltypes.h: simply serves as a container to hold the header files of all datatypes to simplify the header file inclusion Platforms: Solaris (arabica) and Linux
Diffstat (limited to 'c++/src/H5IdComponent.h')
-rw-r--r--c++/src/H5IdComponent.h95
1 files changed, 95 insertions, 0 deletions
diff --git a/c++/src/H5IdComponent.h b/c++/src/H5IdComponent.h
new file mode 100644
index 0000000..0ac9996
--- /dev/null
+++ b/c++/src/H5IdComponent.h
@@ -0,0 +1,95 @@
+#ifndef _IdComponent_H
+#define _IdComponent_H
+
+// IdComponent provides a mechanism to handle
+// reference counting for an identifier of any HDF5 object.
+
+#ifndef H5_NO_NAMESPACE
+namespace H5 {
+#endif
+
+class IdComponent {
+ public:
+ // Parent classes must reset the current IdComponent copy
+ // before setting new id to control reference count
+ void setId( hid_t new_id );
+
+ // Pure virtual function so appropriate close function can
+ // be called by subclasses' for the corresponding object
+ virtual void p_close() const = 0;
+
+ // Creates an object to hold an HDF5 identifier
+ IdComponent( hid_t h5_id );
+
+ // Copy constructor: makes copy of the original IdComponent object.
+ IdComponent( const IdComponent& original );
+
+ // Gets the value of IdComponent's data member
+ hid_t getId () const;
+
+ // Increment reference counter
+ void incRefCount();
+
+ // Decrement reference counter
+ void decRefCount();
+
+ // Get the reference counter to this identifier
+ int getCounter();
+
+ // Decrements the reference counter then determines if there are no more
+ // reference to this object
+ bool noReference();
+
+ // Resets this IdComponent instance
+ //template <class Type>
+ //void reset( Type* parent );
+ void reset();
+ void resetId();
+
+ // Destructor
+ virtual ~IdComponent();
+
+ protected:
+ hid_t id; // HDF5 object id
+ RefCounter* ref_count; // used to keep track of the
+ // number of copies of an object
+
+ // Assignment operator
+ IdComponent& operator=( const IdComponent& rhs );
+
+ // Default constructor
+ IdComponent();
+
+}; // end class IdComponent
+
+// BMR - including template member function implementation here to
+// prevent compilation errors. When the compilers support template
+// member functions in *.C files, move them to IdComponent.C.
+
+// This function makes sure that this IdComponent instance actually
+// represents an HDF5 component and that this HDF5 component is no longer
+// referenced, then calls the parent function p_close to close the
+// appropriate HDF5 component. In addition, this identifier instance
+// will delete itself.
+// Type is the class of the instance to whom this IdComponent object
+// belongs.
+/* 11/10/00 - BMR: commented this member function because many compilers
+ still have no support for member template function. The function is
+ replaced by resetIdComponent in H5Idtemplates.h
+template <class Type>
+void IdComponent::reset( Type* parent )
+{
+ if( ref_count->noReference()) // ref_count is decremented here
+ {
+ if( id > 0 )
+ parent->p_close(); // which p_close depends on whom this
+ // IdComponent object belongs to
+ delete ref_count; // delete the reference counter
+ delete this; // this IdComponent object deletes itself
+ }
+}
+*/
+#ifndef H5_NO_NAMESPACE
+}
+#endif
+#endif