H5IdComponent.h

00001 // C++ informative line for the emacs editor: -*- C++ -*-
00002 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00003  * Copyright by The HDF Group.                                               *
00004  * Copyright by the Board of Trustees of the University of Illinois.         *
00005  * All rights reserved.                                                      *
00006  *                                                                           *
00007  * This file is part of HDF5.  The full HDF5 copyright notice, including     *
00008  * terms governing use, modification, and redistribution, is contained in    *
00009  * the files COPYING and Copyright.html.  COPYING can be found at the root   *
00010  * of the source code distribution tree; Copyright.html can be found at the  *
00011  * root level of an installed copy of the electronic HDF5 document set and   *
00012  * is linked from the top-level documents page.  It can also be found at     *
00013  * http://hdfgroup.org/HDF5/doc/Copyright.html.  If you do not have          *
00014  * access to either file, you may request a copy from help@hdfgroup.org.     *
00015  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00016 
00017 #ifndef _IdComponent_H
00018 #define _IdComponent_H
00019 
00020 // IdComponent represents an HDF5 object that has an identifier.
00021 
00022 #ifndef H5_NO_NAMESPACE
00023 namespace H5 {
00024 #endif
00025 
00026 class DataSpace;
00027 class H5_DLLCPP IdComponent {
00028    public:
00029         // Increment reference counter.
00030         void incRefCount(const hid_t obj_id) const;
00031         void incRefCount() const;
00032 
00033         // Decrement reference counter.
00034         void decRefCount(const hid_t obj_id) const;
00035         void decRefCount() const;
00036 
00037         // Get the reference counter to this identifier.
00038         int getCounter(const hid_t obj_id) const;
00039         int getCounter() const;
00040 
00041         // Returns an HDF5 object type, given the object id.
00042         static H5I_type_t getHDFObjType(const hid_t obj_id);
00043 
00044         // Assignment operator.
00045         IdComponent& operator=( const IdComponent& rhs );
00046 
00047         // Gets the identifier of this object.
00048         virtual hid_t getId () const = 0;
00049 
00050         // Sets the identifier of this object to a new value.
00051         void setId(const hid_t new_id);
00052 
00053         // Creates an object to hold an HDF5 identifier.
00054         IdComponent( const hid_t h5_id );
00055 
00056         // Copy constructor: makes copy of the original IdComponent object.
00057         IdComponent( const IdComponent& original );
00058 
00059 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00060         // Pure virtual function for there are various H5*close for the
00061         // subclasses.
00062         virtual void close() = 0;
00063 
00064         // Makes and returns the string "<class-name>::<func_name>";
00065         // <class-name> is returned by fromClass().
00066         H5std_string inMemFunc(const char* func_name) const;
00067 
00069         virtual H5std_string fromClass() const { return("IdComponent");}
00070 
00071 #endif // DOXYGEN_SHOULD_SKIP_THIS
00072 
00073         // Destructor
00074         virtual ~IdComponent();
00075 
00076    protected:
00077 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00078 
00079         // Default constructor.
00080         IdComponent();
00081 
00082         // Gets the name of the file, in which an HDF5 object belongs.
00083         H5std_string p_get_file_name() const;
00084 
00085         // Verifies that the given id is valid.
00086         static bool p_valid_id(const hid_t obj_id);
00087 
00088         // Sets the identifier of this object to a new value. - this one
00089         // doesn't increment reference count
00090         virtual void p_setId(const hid_t new_id) = 0;
00091 
00092 #endif // DOXYGEN_SHOULD_SKIP_THIS
00093 
00094 }; // end class IdComponent
00095 
00096 #ifndef H5_NO_NAMESPACE
00097 }
00098 #endif
00099 #endif