H5IdComponent.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // C++ informative line for the emacs editor: -*- C++ -*-
  2. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  3. * Copyright by The HDF Group. *
  4. * Copyright by the Board of Trustees of the University of Illinois. *
  5. * All rights reserved. *
  6. * *
  7. * This file is part of HDF5. The full HDF5 copyright notice, including *
  8. * terms governing use, modification, and redistribution, is contained in *
  9. * the COPYING file, which can be found at the root of the source code *
  10. * distribution tree, or in https://www.hdfgroup.org/licenses. *
  11. * If you do not have access to either file, you may request a copy from *
  12. * help@hdfgroup.org. *
  13. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  14. #ifndef H5IdComponent_H
  15. #define H5IdComponent_H
  16. namespace H5 {
  17. /*! \class IdComponent
  18. \brief Class IdComponent provides wrappers of the C functions that
  19. operate on an HDF5 identifier.
  20. In most cases, the C library handles these operations and an application
  21. rarely needs them.
  22. */
  23. class H5_DLLCPP IdComponent {
  24. public:
  25. // Increment reference counter.
  26. void incRefCount(const hid_t obj_id) const;
  27. void incRefCount() const;
  28. // Decrement reference counter.
  29. void decRefCount(const hid_t obj_id) const;
  30. void decRefCount() const;
  31. // Get the reference counter to this identifier.
  32. int getCounter(const hid_t obj_id) const;
  33. int getCounter() const;
  34. // Returns an HDF5 object type, given the object id.
  35. static H5I_type_t getHDFObjType(const hid_t obj_id);
  36. // Returns an HDF5 object type of this object.
  37. H5I_type_t getHDFObjType() const;
  38. // Returns the number of members in a type.
  39. static hsize_t getNumMembers(H5I_type_t type);
  40. // Checks if the given ID is valid.
  41. static bool isValid(hid_t an_id);
  42. // Determines if an type exists.
  43. static bool typeExists(H5I_type_t type);
  44. // Assignment operator.
  45. IdComponent &operator=(const IdComponent &rhs);
  46. // Sets the identifier of this object to a new value.
  47. void setId(const hid_t new_id);
  48. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  49. // Gets the identifier of this object.
  50. virtual hid_t getId() const = 0;
  51. // Pure virtual function for there are various H5*close for the
  52. // subclasses.
  53. virtual void close() = 0;
  54. // Makes and returns the string "<class-name>::<func_name>";
  55. // <class-name> is returned by fromClass().
  56. H5std_string inMemFunc(const char *func_name) const;
  57. ///\brief Returns this class name.
  58. virtual H5std_string
  59. fromClass() const
  60. {
  61. return ("IdComponent");
  62. }
  63. #endif // DOXYGEN_SHOULD_SKIP_THIS
  64. // Destructor
  65. virtual ~IdComponent();
  66. #ifndef DOXYGEN_SHOULD_SKIP_THIS
  67. protected:
  68. // Default constructor.
  69. IdComponent();
  70. // Gets the name of the file, in which an HDF5 object belongs.
  71. H5std_string p_get_file_name() const;
  72. // Verifies that the given id is valid.
  73. static bool p_valid_id(const hid_t obj_id);
  74. // Sets the identifier of this object to a new value. - this one
  75. // doesn't increment reference count
  76. virtual void p_setId(const hid_t new_id) = 0;
  77. // This flag is used to decide whether H5dont_atexit should be called
  78. static bool H5dontAtexit_called;
  79. private:
  80. // This flag indicates whether H5Library::initH5cpp has been called
  81. // to register various terminating functions with atexit()
  82. static bool H5cppinit;
  83. #endif // DOXYGEN_SHOULD_SKIP_THIS
  84. }; // end class IdComponent
  85. } // namespace H5
  86. #endif // H5IdComponent_H