Version.hpp
Go to the documentation of this file.
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 /// \file
5 /// Defines class h5::Version for storing version history of files
6 
7 #pragma once
8 
9 #include <cstdint>
10 #include <hdf5.h>
11 #include <string>
12 
13 #include "IO/H5/Object.hpp"
14 #include "IO/H5/OpenGroup.hpp"
15 
16 namespace h5 {
17 /*!
18  * \ingroup HDF5Group
19  * \brief Used to store the version of the file
20  *
21  * A Version object should be stored inside each H5 object that is to represent
22  * a file, e.g. Dat, or Text.
23  *
24  * \example
25  * To write the version use:
26  * \snippet Test_H5.cpp h5file_write_version
27  * To read the version use:
28  * \snippet Test_H5.cpp h5file_read_version
29  *
30  */
31 class Version : public h5::Object {
32  public:
33  /// \cond HIDDEN_SYMOLS
34  static std::string extension() { return ".ver"; }
35 
36  Version(bool exists, detail::OpenGroup&& group, hid_t location,
37  std::string name, uint32_t version = 1);
38 
39  Version(const Version& /*rhs*/) = delete;
40  Version& operator=(const Version& /*rhs*/) = delete;
41 
42  Version(Version&& /*rhs*/) noexcept = default; // NOLINT
43  Version& operator=(Version&& /*rhs*/) noexcept = default; // NOLINT
44  ~Version() override = default;
45  /// \endcond
46 
47  uint32_t get_version() const noexcept { return version_; }
48 
49  private:
50  /// \cond HIDDEN_SYMBOLS
51  uint32_t version_;
52  // group_ is necessary since the when the h5::Object is destroyed it closes
53  // all groups that were opened to get to it.
54  detail::OpenGroup group_;
55  /// \endcond
56 };
57 } // namespace h5
Defines class OpenGroup for opening groups in HDF5.
Contains functions and classes for manipulating HDF5 files.
Definition: AccessType.cpp:10
Defines class h5::Object abstract base class.
Abstract base class representing an object in an HDF5 file.
Definition: Object.hpp:14
Used to store the version of the file.
Definition: Version.hpp:31