HighFive  2.3.1
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  // Check if refer to same object
67  bool operator==(const Object& other) const noexcept {
68  return _hid == other._hid;
69  }
70 
71  protected:
72  // empty constructor
73  Object();
74 
75  // copy constructor, increase reference counter
76  Object(const Object& other);
77 
78  // move constructor, reuse hid
79  Object(Object&& other) noexcept;
80 
81  // Init with an low-level object id
82  explicit Object(hid_t);
83 
84  // Copy-Assignment operator
85  Object& operator=(const Object& other);
86 
87  hid_t _hid;
88 
89  private:
90 
91  template <typename Derivate> friend class NodeTraits;
92  template <typename Derivate> friend class AnnotateTraits;
93  friend class Reference;
94 };
95 
96 
100 class ObjectInfo {
101  public:
103  H5_DEPRECATED("Deprecated since HighFive 2.2. Soon supporting VOL tokens")
104  haddr_t getAddress() const noexcept;
105 
107  size_t getRefCount() const noexcept;
108 
110  time_t getCreationTime() const noexcept;
111 
113  time_t getModificationTime() const noexcept;
114 
115  protected:
116 
117 #if (H5Oget_info_vers < 3)
118  H5O_info_t raw_info;
119 #else
120  // Use compat H5O_info1_t while getAddress() is supported (deprecated)
121  H5O_info1_t raw_info;
122 #endif
123 
124  friend class Object;
125 };
126 
127 } // namespace HighFive
128 
129 #include "bits/H5Object_misc.hpp"
130 
131 #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:87
Object & operator=(const Object &other)
Definition: H5Object_misc.hpp:31
bool operator==(const Object &other) const noexcept
Definition: H5Object.hpp:67
A class for accessing hdf5 objects info.
Definition: H5Object.hpp:100
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:118
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