HighFive  2.2.2
HighFive - Header-only C++ HDF5 interface
H5Object.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c), 2017, Adrien Devresse <adrien.devresse@epfl.ch>
3  *
4  * Distributed under the Boost Software License, Version 1.0.
5  * (See accompanying file LICENSE_1_0.txt or copy at
6  * http://www.boost.org/LICENSE_1_0.txt)
7  *
8  */
9 #ifndef H5OBJECT_HPP
10 #define H5OBJECT_HPP
11 
12 #include <ctime>
13 
14 #include <H5Ipublic.h>
15 #include <H5Opublic.h>
16 
17 #include "H5Exception.hpp"
18 #include "bits/H5_definitions.hpp"
19 
20 namespace HighFive {
21 
25 enum class ObjectType {
26  File,
27  Group,
29  DataSpace,
30  Dataset,
31  Attribute,
32  Other // Internal/custom object type
33 };
34 
35 
36 class Object {
37  public:
38  // decrease reference counter
39  ~Object();
40 
45  bool isValid() const noexcept;
46 
52  hid_t getId() const noexcept;
53 
57  ObjectInfo getInfo() const;
58 
64  ObjectType getType() const;
65 
66  protected:
67  // empty constructor
68  Object();
69 
70  // copy constructor, increase reference counter
71  Object(const Object& other);
72 
73  // move constructor, reuse hid
74  Object(Object&& other) noexcept;
75 
76  // Init with an low-level object id
77  explicit Object(hid_t);
78 
79  Object& operator=(const Object& other);
80 
81  hid_t _hid;
82 
83  private:
84 
85  template <typename Derivate> friend class NodeTraits;
86  template <typename Derivate> friend class AnnotateTraits;
87  friend class Reference;
88 };
89 
90 
94 class ObjectInfo {
95  public:
97  H5_DEPRECATED("Deprecated since HighFive 2.2. Soon supporting VOL tokens")
98  haddr_t getAddress() const noexcept;
99 
101  size_t getRefCount() const noexcept;
102 
104  time_t getCreationTime() const noexcept;
105 
107  time_t getModificationTime() const noexcept;
108 
109  protected:
110 
111 #if (H5Oget_info_vers < 3)
112  H5O_info_t raw_info;
113 #else
114  // Use compat H5O_info1_t while getAddress() is supported (deprecated)
115  H5O_info1_t raw_info;
116 #endif
117 
118  friend class Object;
119 };
120 
121 } // namespace HighFive
122 
123 #include "bits/H5Object_misc.hpp"
124 
125 #endif // H5OBJECT_HPP
#define H5_DEPRECATED
Definition: H5_definitions.hpp:9
Definition: H5Annotate_traits.hpp:19
NodeTraits: Base class for Group and File.
Definition: H5Node_traits.hpp:23
Definition: H5Object.hpp:36
hid_t getId() const noexcept
getId
Definition: H5Object_misc.hpp:55
ObjectInfo getInfo() const
Retrieve several infos about the current object (address, dates, etc)
Definition: H5Object_misc.hpp:87
~Object()
Definition: H5Object_misc.hpp:44
ObjectType getType() const
Gets the fundamental type of the object (dataset, group, etc)
Definition: H5Object_misc.hpp:78
Object()
Definition: H5Object_misc.hpp:16
bool isValid() const noexcept
isValid
Definition: H5Object_misc.hpp:51
hid_t _hid
Definition: H5Object.hpp:81
Object & operator=(const Object &other)
Definition: H5Object_misc.hpp:31
A class for accessing hdf5 objects info.
Definition: H5Object.hpp:94
time_t getCreationTime() const noexcept
Retrieve the object's creation time.
Definition: H5Object_misc.hpp:105
haddr_t getAddress() const noexcept
Retrieve the address of the object (within its file)
Definition: H5Object_misc.hpp:99
size_t getRefCount() const noexcept
Retrieve the number of references to this object.
Definition: H5Object_misc.hpp:102
H5O_info_t raw_info
Definition: H5Object.hpp:112
time_t getModificationTime() const noexcept
Retrieve the object's last modification time.
Definition: H5Object_misc.hpp:108
An HDF5 (object) reference type.
Definition: H5Reference.hpp:31
Definition: H5_definitions.hpp:15
ObjectType
Enum of the types of objects (H5O api)
Definition: H5Object.hpp:25