h5gt 0.2.0
C++ wrapper for HDF5 library (based on HighFive project)
Loading...
Searching...
No Matches
H5Object.hpp
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//----------------------------------------------------------------//
21// H5Object.hpp H5Object_misc.hpp cant contain variables //
22// of type H5PropertyLists as H5Object.hpp is included //
23// by H5PropertyLists.hpp //
24// You will get recursion hell if break this rule //
25//----------------------------------------------------------------//
26
27namespace h5gt {
28
29class LinkAccessProps;
30
34enum class ObjectType {
35 File,
36 Group,
37 UserDataType,
38 DataSpace,
39 Dataset,
40 Attribute,
41 Other // Internal/custom object type
42};
43
47enum class LinkType {
48 Hard,
49 Soft,
50 External,
51 Other // Reserved or User-defined
52};
53
54
55class Object {
56public:
57 // decrease reference counter
58 ~Object();
59
69 void flush(bool globalScope = true);
70
75 bool isValid() const noexcept;
76
77#if (H5_VERS_MAJOR >= 1 && H5_VERS_MINOR >= 10)
83 bool refresh() const noexcept;
84#endif
85
91 hid_t getId(const bool& increaseRefCount = false) const noexcept;
92
93 std::string getFileName() const;
94
99 std::string getPath() const;
100
101 int getIdRefCount() const noexcept;
102
107
113 ObjectType getObjectType() const;
114
115protected:
116 // empty constructor
117 Object();
118
119 // copy constructor, increase reference counter
120 Object(const Object& other);
121
122 // move constructor, reuse hid
123 Object(Object&& other) noexcept;
124
125 // Init with an low-level object id
126 explicit Object(const hid_t&);
127 explicit Object(const hid_t&, const ObjectType&, const bool&);
128
135 LinkInfo _getLinkInfo(const std::string& objPath) const;
136
137 std::string _unpackSoftLink(
138 const std::string& objName) const;
139 std::string _unpackExternalLink(
140 const std::string& objName,
141 std::string& fileName_out) const;
142 void _unlink(const std::string& obj_name) const;
143
144 Object& operator=(const Object& other);
146 bool operator==(const Object& other) const;
147
148 hid_t _hid;
149
150private:
151
152 template <typename Derivate> friend class NodeTraits;
153 template <typename Derivate> friend class AnnotateTraits;
154 friend class Reference;
155 friend class DataSpace;
156 friend class File;
157 friend class Group;
158 friend class DataSet;
159 friend class Attribute;
160 friend class DataType;
161 friend class Selection;
162};
163
164
169public:
171#if (H5Oget_info_vers < 3)
172 haddr_t getAddress() const noexcept;
173#else
175 H5O_token_t getHardLinkToken() const noexcept;
176#endif
177
178 unsigned long getFileNumber() const noexcept;
179
181 size_t getHardLinkRefCount() const noexcept;
182
183 time_t getAccessTime() const noexcept;
184 time_t getModificationTime() const noexcept;
185 time_t getChangeTime() const noexcept;
186 time_t getCreationTime() const noexcept;
187 hsize_t getNumAttr() const noexcept;
188
189protected:
190
191#if (H5Oget_info_vers < 3)
192 H5O_info_t raw_info;
193#else
194 H5O_info2_t raw_info;
195#endif
196
197 friend class Object;
198};
199
200class LinkInfo {
201public:
202 LinkType getLinkType() const noexcept;
203 hbool_t creationOrderValid() const noexcept;
204 int64_t getCreationOrder() const noexcept;
205 H5T_cset_t getLinkNameCharacterSet() const noexcept;
206#if (H5Lget_info_vers < 2)
207 haddr_t getAddress() const noexcept;
208#else
210 H5O_token_t getHardLinkToken() const noexcept;
211#endif
213 size_t getSoftLinkSize() const noexcept;
214
215protected:
216#if (H5Lget_info_vers < 2)
217 H5L_info_t link_info;
218#else
219 H5L_info2_t link_info;
220#endif
221
222 friend class Object;
223};
224
225} // namespace h5gt
226
227#include "bits/H5Object_misc.hpp"
228
229#endif // H5OBJECT_HPP
Definition H5Annotate_traits.hpp:19
Class representing an attribute of a dataset or group.
Definition H5Attribute.hpp:22
Class representing a dataset.
Definition H5DataSet.hpp:28
Class representing the space (dimensions) of a dataset.
Definition H5DataSpace.hpp:37
HDF5 Data Type.
Definition H5DataType.hpp:48
File class.
Definition H5File.hpp:25
Represents an hdf5 group.
Definition H5Group.hpp:23
NodeTraits: Base class for Group and File.
Definition H5Node_traits.hpp:23
Definition H5Object.hpp:55
LinkInfo _getLinkInfo(const std::string &objPath) const
getLinkInfo retrieve link info from an object with 'objPath'. This object must reside in the same con...
Definition H5Object_misc.hpp:216
ObjectType getObjectType() const
Gets the fundamental type of the object (dataset, group, etc)
Definition H5Object_misc.hpp:195
ObjectInfo getObjectInfo() const
Retrieve several infos about the current object (address, dates, etc)
Definition H5Object_misc.hpp:204
void flush(bool globalScope=true)
flush
Definition H5Object_misc.hpp:150
std::string getPath() const
return the path to the current group, dataset, datatype or attribute's holder
Definition H5Object_misc.hpp:185
hid_t getId(const bool &increaseRefCount=false) const noexcept
getId
Definition H5Object_misc.hpp:172
bool operator==(const Object &other) const
When coparing objects h5gt::File must be open.
Definition H5Object_misc.hpp:105
bool isValid() const noexcept
isValid
Definition H5Object_misc.hpp:162
A class for accessing hdf5 objects info.
Definition H5Object.hpp:168
haddr_t getAddress() const noexcept
Retrieve the address of the object (within its file)
Definition H5Object_misc.hpp:301
size_t getHardLinkRefCount() const noexcept
Retrieve the number of references to this object.
Definition H5Object_misc.hpp:314
An HDF5 (object) reference type.
Definition H5Reference.hpp:31
Selection: represent a view on a slice/part of a dataset.
Definition H5Selection.hpp:23