Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-13 09:13:20

0001 /*
0002  *  Copyright (c), 2017, Adrien Devresse <adrien.devresse@epfl.ch>
0003  *
0004  *  Distributed under the Boost Software License, Version 1.0.
0005  *    (See accompanying file LICENSE_1_0.txt or copy at
0006  *          http://www.boost.org/LICENSE_1_0.txt)
0007  *
0008  */
0009 #pragma once
0010 
0011 #include <ctime>
0012 
0013 #include "bits/H5_definitions.hpp"
0014 #include "bits/H5Friends.hpp"
0015 
0016 #include "H5Exception.hpp"
0017 #include "bits/h5o_wrapper.hpp"
0018 #include "bits/h5i_wrapper.hpp"
0019 
0020 namespace HighFive {
0021 
0022 ///
0023 /// \brief Enum of the types of objects (H5O api)
0024 ///
0025 enum class ObjectType {
0026     File,
0027     Group,
0028     UserDataType,
0029     DataSpace,
0030     Dataset,
0031     Attribute,
0032     Other  // Internal/custom object type
0033 };
0034 
0035 
0036 class Object {
0037   public:
0038     // move constructor, reuse hid
0039     Object(Object&& other) noexcept;
0040 
0041     ///
0042     /// \brief isValid
0043     /// \return true if current Object is a valid HDF5Object
0044     ///
0045     bool isValid() const noexcept;
0046 
0047     ///
0048     /// \brief getId
0049     /// \return internal HDF5 id to the object
0050     ///  provided for C API compatibility
0051     ///
0052     hid_t getId() const noexcept;
0053 
0054     ///
0055     /// \brief Retrieve several infos about the current object (address, dates, etc)
0056     ///
0057     ObjectInfo getInfo() const;
0058 
0059     ///
0060     /// \brief Address of an HDF5 object in the file.
0061     ///
0062     /// Not all HDF5 files support addresses anymore. The more recent concept
0063     /// is a VOL token.
0064     ///
0065     /// \since 3.0.0
0066     ///
0067     haddr_t getAddress() const;
0068 
0069     ///
0070     /// \brief Gets the fundamental type of the object (dataset, group, etc)
0071     /// \exception ObjectException when the _hid is negative or the type
0072     ///     is custom and not registered yet
0073     ///
0074     ObjectType getType() const;
0075 
0076     // Check if refer to same object
0077     bool operator==(const Object& other) const noexcept {
0078         return _hid == other._hid;
0079     }
0080 
0081   protected:
0082     // empty constructor
0083     Object();
0084 
0085     // copy constructor, increase reference counter
0086     Object(const Object& other);
0087 
0088     // Init with an low-level object id
0089     explicit Object(hid_t) noexcept;
0090 
0091     // decrease reference counter
0092     ~Object();
0093 
0094     // Copy-Assignment operator
0095     Object& operator=(const Object& other);
0096     Object& operator=(Object&& other);
0097 
0098     hid_t _hid;
0099 
0100   private:
0101     friend class Reference;
0102     friend class CompoundType;
0103 
0104 #if HIGHFIVE_HAS_FRIEND_DECLARATIONS
0105     template <typename Derivate>
0106     friend class NodeTraits;
0107     template <typename Derivate>
0108     friend class AnnotateTraits;
0109     template <typename Derivate>
0110     friend class PathTraits;
0111 #endif
0112 };
0113 
0114 
0115 ///
0116 /// \brief A class for accessing hdf5 objects info
0117 ///
0118 class ObjectInfo {
0119   public:
0120     ObjectInfo(const Object& obj);
0121 
0122     /// \brief Retrieve the number of references to this object
0123     size_t getRefCount() const noexcept;
0124 
0125     /// \brief Retrieve the object's creation time
0126     time_t getCreationTime() const noexcept;
0127 
0128     /// \brief Retrieve the object's last modification time
0129     time_t getModificationTime() const noexcept;
0130 
0131   private:
0132     detail::h5o_info1_t raw_info;
0133 
0134     friend class Object;
0135 };
0136 
0137 }  // namespace HighFive
0138 
0139 #include "bits/H5Object_misc.hpp"