echelon  0.8.0
hdf5/object.hpp
1 // Copyright (c) 2012-2014 Christopher Hinz
2 //
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5 
6 #ifndef ECHELON_HDF5_OBJECT_HPP
7 #define ECHELON_HDF5_OBJECT_HPP
8 
9 #include <echelon/hdf5/precursor/object.hpp>
10 #include <exception>
11 #include <string>
12 #include <utility>
13 
14 namespace echelon
15 {
16 namespace hdf5
17 {
21 class wrong_object_type_exception : public std::exception
22 {
23 public:
28  wrong_object_type_exception(std::string what_) : what_(std::move(what_))
29  {
30  }
31 
35  {
36  }
37 
40  const char* what() const noexcept override
41  {
42  return what_.c_str();
43  }
44 
45 private:
46  std::string what_;
47 };
48 
49 class group;
50 class dataset;
51 class scalar_dataset;
52 
53 class object_reference;
54 
57 class object
58 {
59 public:
62  using native_handle_type = hdf5::precursor::object;
63 
66  object() = default;
67 
68  explicit object(native_handle_type object_wrapper_);
69 
74  object(const group& object_);
75 
80  object(const dataset& object_);
81 
86  object(const scalar_dataset& object_);
87 
92  object& operator=(const group& object_);
93 
98  object& operator=(const dataset& object_);
99 
104  object& operator=(const scalar_dataset& object_);
105 
117  operator group() const;
118 
130  operator dataset() const;
131 
143  operator scalar_dataset() const;
144 
147  object_reference ref() const;
148 
151  const native_handle_type& native_handle() const;
152 
155  explicit operator bool() const;
156 private:
157  hdf5::precursor::object object_wrapper_;
158 };
159 }
160 }
161 
162 #endif
echelon&#39;s core namespace
Definition: attribute.cpp:10
A handle to an HDF5 dataset.
Definition: hdf5/dataset.hpp:62
Polymorphic handle to an HDF5 object.
Definition: hdf5/object.hpp:57
wrong_object_type_exception(std::string what_)
Creates a new exception with a given error description.
Definition: hdf5/object.hpp:28
Exception, which is thrown, if the conversion of a polymorphic handle to a more specialized, but incompatible, handle fails.
Definition: hdf5/object.hpp:21
A handle to an HDF5 group object.
Definition: hdf5/group.hpp:161
~wrong_object_type_exception() noexcept
The destructor.
Definition: hdf5/object.hpp:34
hdf5::precursor::object native_handle_type
Type of the underlying HDF5 low-level handle.
Definition: hdf5/object.hpp:62
const char * what() const noexceptoverride
An associated error description.
Definition: hdf5/object.hpp:40
A reference to an HDF5 object.
Definition: hdf5/object_reference.hpp:25
A handle to an HDF5 scalar dataset.
Definition: hdf5/scalar_dataset.hpp:27