h5cpp  0.5.1
A modern C++ wrapper for the HDF5 C library
datatype.hpp
Go to the documentation of this file.
1 //
2 // (c) Copyright 2017 DESY,ESS
3 //
4 // This file is part of h5pp.
5 //
6 // This library is free software; you can redistribute it and/or modify it
7 // under the terms of the GNU Lesser General Public License as published
8 // by the Free Software Foundation; either version 2.1 of the License, or
9 // (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY
13 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 // License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with this library; if not, write to the
18 // Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor
19 // Boston, MA 02110-1301 USA
20 // ===========================================================================
21 //
22 // Authors:
23 // Eugen Wintersberger <eugen.wintersberger@desy.de>
24 // Martin Shetty <martin.shetty@esss.se>
25 // Created on: Aug 15, 2017
26 //
27 #pragma once
28 
29 #include <type_traits>
30 #include <h5cpp/core/hdf5_capi.hpp>
32 #include <h5cpp/datatype/types.hpp>
33 #include <h5cpp/core/windows.hpp>
34 
35 namespace hdf5 {
36 namespace datatype {
37 
42 {
43  public:
49  virtual ~Datatype();
50 
60  Datatype() = default;
61 
70 
76  Datatype(Datatype &&type) = default;
77 
83  Datatype(const Datatype &type);
84 
90  Datatype &operator=(const Datatype &type);
91 
97  Datatype &operator=(Datatype &&type) = default;
98 
104  Class get_class() const;
105 
115  Datatype super() const;
116 
125 
131  bool has_class(Class type_class) const;
132 
138  virtual size_t size() const;
139 
145  virtual void size(size_t size) const;
146 
147  explicit operator hid_t() const
148  {
149  return static_cast<hid_t>(handle_);
150  }
151 
159  bool is_valid() const;
160  private:
161 
162  ObjectHandle handle_;
163 
167  void swap(const Datatype &type);
168 
169 };
170 
181 DLL_EXPORT bool operator==(const Datatype &lhs, const Datatype &rhs);
182 
192 DLL_EXPORT bool operator!=(const Datatype &lhs, const Datatype &rhs);
193 
194 } // namespace datatype
195 } // namespace hdf5
Wrapper for hid_t object identifiers.
Definition: object_handle.hpp:67
base class for all data types
Definition: datatype.hpp:42
Datatype native_type(Direction dir=Direction::Ascend) const
get native type
Datatype(Datatype &&type)=default
move constructor
Class get_class() const
returns the datatypes class
Datatype & operator=(Datatype &&type)=default
move assignment
virtual size_t size() const
get size of type in bytes
Datatype(const Datatype &type)
copy constructor
Datatype()=default
default constructor
virtual ~Datatype()
destructor
Datatype & operator=(const Datatype &type)
copy assignment
bool has_class(Class type_class) const
search for a type class
Datatype super() const
get the base type
Datatype(ObjectHandle &&handle)
constructor
virtual void size(size_t size) const
set the size of a type in bytes
bool is_valid() const
check status of the object
bool operator==(const Datatype &lhs, const Datatype &rhs)
equality check for datatypes
bool operator!=(const Datatype &lhs, const Datatype &rhs)
inequality check for datatypes
Class
Definition: types.hpp:53
Direction
Definition: types.hpp:173
top-level namespace of the entire library
Definition: attribute.hpp:45
#define DLL_EXPORT
Definition: windows.hpp:29