echelon  0.8.0
hdf5/attribute.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_ATTRIBUTE_HPP
7 #define ECHELON_HDF5_ATTRIBUTE_HPP
8 
9 #include <echelon/hdf5/type.hpp>
10 #include <echelon/hdf5/object.hpp>
11 
12 #include <echelon/hdf5/precursor/attribute.hpp>
13 
14 #include <echelon/hdf5/storage_layer.hpp>
15 
16 #include <utility>
17 
18 namespace echelon
19 {
20 namespace hdf5
21 {
24 class attribute
25 {
26 public:
29  using native_handle_type = hdf5::precursor::attribute;
30 
33  attribute() = default;
34 
35  attribute(const object& parent, const std::string& name, const type& datatype);
36  attribute(const object& parent, const std::string& name);
37 
45  template <typename T>
46  friend inline void operator<<=(attribute& attr, const T& value)
47  {
48  write(attr.attribute_wrapper_, value);
49  }
50 
58  template <typename T>
59  friend inline void operator<<=(T& value, const attribute& attr)
60  {
61  read(attr.attribute_wrapper_, value);
62  }
63 
66  type datatype() const;
67 
70  const native_handle_type& native_handle() const;
71 
74  explicit operator bool() const;
75 private:
76  hdf5::precursor::attribute attribute_wrapper_;
77 };
78 }
79 }
80 
81 #endif
echelon&#39;s core namespace
Definition: attribute.cpp:10
A handle to an HDF5 attribute.
Definition: hdf5/attribute.hpp:24
friend void operator<<=(T &value, const attribute &attr)
Reads the content of an attribute into a variable.
Definition: hdf5/attribute.hpp:59
attribute()=default
Initializes the handle with its null state.
type datatype() const
The value type of the attribute.
Definition: hdf5/attribute.cpp:29
friend void operator<<=(attribute &attr, const T &value)
Writes the content of a variable into the attribute.
Definition: hdf5/attribute.hpp:46
hdf5::precursor::attribute native_handle_type
Type of the underlying HDF5 low-level handle.
Definition: hdf5/attribute.hpp:29
A handle to an HDF5 type.
Definition: hdf5/type.hpp:23
const native_handle_type & native_handle() const
The underlying HDF5 low-level handle.
Definition: hdf5/attribute.cpp:34