H5Object_misc.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_MISC_HPP
10 #define H5OBJECT_MISC_HPP
11 
12 #include "../H5Exception.hpp"
13 #include "../H5Object.hpp"
14 
15 #include <iostream>
16 
17 namespace HighFive {
18 
19 inline Object::Object() : _hid(H5I_INVALID_HID) {}
20 
21 inline Object::Object(const Object& other) : _hid(other._hid) {
22  if (other.isValid() && H5Iinc_ref(_hid) < 0) {
23  throw ObjectException("Reference counter increase failure");
24  }
25 }
26 
27 inline Object& Object::operator=(const Object& other) {
28  if (this != &other) {
29  if (_hid != H5I_INVALID_HID)
30  H5Idec_ref(_hid);
31 
32  _hid = other._hid;
33  if (other.isValid() && H5Iinc_ref(_hid) < 0) {
34  throw ObjectException("Reference counter increase failure");
35  }
36  }
37  return *this;
38 }
39 
40 inline Object::~Object() {
41  if (isValid() && H5Idec_ref(_hid) < 0) {
42  std::cerr << "HighFive::~Object: reference counter decrease failure"
43  << std::endl;
44  }
45 }
46 
47 inline bool Object::isValid() const {
48  return (_hid != H5I_INVALID_HID) && (H5Iis_valid(_hid) != false);
49 }
50 
51 inline hid_t Object::getId() const { return _hid; }
52 }
53 
54 #endif // H5OBJECT_MISC_HPP
hid_t getId() const
getId
bool isValid() const
isValid
Exception specific to HighFive Object interface.
Definition: H5Exception.hpp:74
Object & operator=(const Object &other)


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Mon Feb 28 2022 22:46:06