105inline bool Object::operator==(
const Object& other)
const {
109 if (leftOInfo.getFileNumber() != rightOInfo.getFileNumber() ||
110 leftOInfo.getFileNumber() == 0 ||
111 rightOInfo.getFileNumber() == 0)
114#if (H5Oget_info_vers < 3)
118 H5O_token_t leftToken = leftOInfo.getHardLinkToken();
119 H5O_token_t rightToken = rightOInfo.getHardLinkToken();
121 hid_t fileId = H5Iget_file_id(_hid);
122 bool closeFileId =
true;
123 if (!H5Iis_valid(fileId)){
125 HDF5ErrMapper::ToException<ObjectException>(
126 std::string(
"File ID is invalid. Probably the object doesn't belong to any file"));
129 if (H5Otoken_cmp(fileId, &leftToken, &rightToken, &tokenCMP) < 0){
130 HDF5ErrMapper::ToException<ObjectException>(
131 "Unable compare tokens");
143inline Object::~Object() {
144 if (isValid() && H5Idec_ref(_hid) < 0) {
145 std::cerr <<
"h5gt::~Object: reference counter decrease failure"
150inline void Object::flush(
bool globalScope) {
153 scope = H5F_scope_t::H5F_SCOPE_GLOBAL;
155 scope = H5F_scope_t::H5F_SCOPE_LOCAL;
156 if (H5Fflush(_hid, scope) < 0) {
157 HDF5ErrMapper::ToException<ObjectException>(
158 std::string(
"Unable to flush object " + getPath()));
162inline bool Object::isValid() const noexcept {
163 return (_hid != H5I_INVALID_HID) && (H5Iis_valid(_hid) !=
false);
166#if (H5_VERS_MAJOR >= 1 && H5_VERS_MINOR >= 10)
167inline bool Object::refresh() const noexcept {
168 return (H5Orefresh(_hid) < 0) ? false :
true;
172inline hid_t Object::getId(
const bool& increaseRefCount)
const noexcept {
173 if (increaseRefCount)
179inline std::string Object::getFileName()
const {
180 return details::get_name([&](
char *buffer, hsize_t length) {
181 return H5Fget_name(_hid, buffer, length);
185inline std::string Object::getPath()
const {
186 return details::get_name([&](
char *buffer, hsize_t length) {
187 return H5Iget_name(_hid, buffer, length);
191inline int Object::getIdRefCount() const noexcept {
192 return H5Iget_ref(_hid);
195inline ObjectType Object::getObjectType()
const {
198 if ((h5type = H5Iget_type(_hid)) == H5I_BADID) {
199 HDF5ErrMapper::ToException<ObjectException>(
"Invalid hid or object type");
201 return _convert_object_type(h5type);
206#if (H5Oget_info_vers < 3)
207 if (H5Oget_info(_hid, &info.raw_info) < 0) {
209 if (H5Oget_info3(_hid, &info.raw_info, H5O_INFO_ALL) < 0) {
211 HDF5ErrMapper::ToException<ObjectException>(
"Unable to obtain info for object");
216inline LinkInfo Object::_getLinkInfo(
const std::string& objPath)
const {
218#if (H5Lget_info_vers < 2)
219 if (H5Lget_info(_hid, objPath.c_str(), &info.link_info, H5P_DEFAULT) < 0) {
221 if (H5Lget_info2(_hid, objPath.c_str(), &info.link_info, H5P_DEFAULT) < 0) {
223 HDF5ErrMapper::ToException<ObjectException>(
"Unable to obtain info for link");
228inline std::string Object::_unpackSoftLink(
229 const std::string& objName)
const
233 if (linkInfo.getLinkType() != LinkType::Soft){
234 HDF5ErrMapper::ToException<ObjectException>(
235 std::string(
"The link is not Soft"));
236 return std::string();
241 HDF5ErrMapper::ToException<ObjectException>(
242 std::string(
"Link size is too small (n < 1)"));
243 return std::string();
245 std::vector<char> v(n);
246 if (H5Lget_val(getId(
false), objName.c_str(),
247 v.data(), n, H5P_DEFAULT) < 0){
248 HDF5ErrMapper::ToException<ObjectException>(
249 std::string(
"Unable to get path to which the link points to"));
251 return std::string(v.data(), n-1);
254inline std::string Object::_unpackExternalLink(
255 const std::string& objName,
256 std::string& fileName_out)
const
260 if (linkInfo.getLinkType() != LinkType::External){
261 HDF5ErrMapper::ToException<ObjectException>(
262 std::string(
"The link is not External"));
263 return std::string();
268 HDF5ErrMapper::ToException<ObjectException>(
269 std::string(
"Link size is too small (n < 1)"));
270 return std::string();
272 std::vector<char> v(n);
273 if (H5Lget_val(getId(
false), objName.c_str(),
274 v.data(), n, H5P_DEFAULT) < 0){
275 HDF5ErrMapper::ToException<ObjectException>(
276 std::string(
"Unable to get path to which the link points to"));
282 if (H5Lunpack_elink_val(v.data(), n, &flags, &f_out, &o_out) < 0){
283 HDF5ErrMapper::ToException<ObjectException>(
284 std::string(
"Unable to get path to which the link points to"));
287 fileName_out = std::string(f_out);
288 return std::string(o_out);
291inline void Object::_unlink(
const std::string& objName)
const
293 const herr_t val = H5Ldelete(getId(
false), objName.c_str(), H5P_DEFAULT);
295 HDF5ErrMapper::ToException<ObjectException>(
296 std::string(
"Invalid name for unlink() "));
300#if (H5Lget_info_vers < 2)
301inline haddr_t ObjectInfo::getAddress() const noexcept {
302 return raw_info.addr;
305inline H5O_token_t ObjectInfo::getHardLinkToken() const noexcept{
306 return raw_info.token;
310inline unsigned long ObjectInfo::getFileNumber() const noexcept {
311 return raw_info.fileno;
314inline size_t ObjectInfo::getHardLinkRefCount() const noexcept {
317inline time_t ObjectInfo::getAccessTime() const noexcept {
318 return raw_info.atime;
320inline time_t ObjectInfo::getModificationTime() const noexcept {
321 return raw_info.mtime;
323inline time_t ObjectInfo::getChangeTime() const noexcept {
324 return raw_info.ctime;
326inline time_t ObjectInfo::getCreationTime() const noexcept {
327 return raw_info.btime;
329inline hsize_t ObjectInfo::getNumAttr() const noexcept {
330 return raw_info.num_attrs;
334inline LinkType LinkInfo::getLinkType() const noexcept{
335 return _convert_link_type(link_info.type);
337inline hbool_t LinkInfo::creationOrderValid() const noexcept{
338 return link_info.corder_valid;
340inline int64_t LinkInfo::getCreationOrder() const noexcept{
341 return link_info.corder;
343inline H5T_cset_t LinkInfo::getLinkNameCharacterSet() const noexcept{
344 return link_info.cset;
346#if (H5Lget_info_vers < 2)
347inline haddr_t LinkInfo::getAddress() const noexcept{
348 return link_info.u.address;
351inline H5O_token_t LinkInfo::getHardLinkToken() const noexcept{
352 return link_info.u.token;
355inline size_t LinkInfo::getSoftLinkSize() const noexcept{
356 return link_info.u.val_size;
ObjectInfo getObjectInfo() const
Retrieve several infos about the current object (address, dates, etc)
Definition H5Object_misc.hpp:204