echelon  0.8.0
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_ATTRIBUTE_HPP
7 #define ECHELON_ATTRIBUTE_HPP
8 
9 #include <echelon/type.hpp>
10 #include <echelon/object.hpp>
11 
12 #include <echelon/hdf5/attribute.hpp>
13 
14 #include <utility>
15 
16 namespace echelon
17 {
18 
21 class attribute
22 {
23 public:
25 
28  attribute() = default;
29 
30  explicit attribute(native_handle_type native_handle_);
31 
39  template <typename T>
40  friend inline void operator<<=(attribute& attr, const T& value)
41  {
42  attr.attribute_handle_ <<= value;
43  }
44 
52  template <typename T>
53  friend inline void operator<<=(T& value, const attribute& attr)
54  {
55  value <<= attr.attribute_handle_;
56  }
57 
60  type datatype() const;
61 
65 
68  explicit operator bool() const;
69 private:
70  hdf5::attribute attribute_handle_;
71 };
72 }
73 
74 #endif
echelon&#39;s core namespace
Definition: attribute.cpp:10
A handle to an HDF5 attribute.
Definition: hdf5/attribute.hpp:24
A handle to an HDF5 type.
Definition: type.hpp:21
type datatype() const
The value type of the attribute.
Definition: attribute.cpp:18
friend void operator<<=(T &value, const attribute &attr)
Reads the content of an attribute into a variable.
Definition: attribute.hpp:53
native_handle_type native_handle() const
The underlying HDF5 low-level handle.
Definition: attribute.cpp:23
A handle to an echelon attribute.
Definition: attribute.hpp:21
attribute()=default
Initializes the handle with its null state.
friend void operator<<=(attribute &attr, const T &value)
Writes the content of a variable into the attribute.
Definition: attribute.hpp:40