ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
h5md_specification.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2022 The ESPResSo project
3 * Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010
4 * Max-Planck-Institute for Polymer Research, Theory Group
5 *
6 * This file is part of ESPResSo.
7 *
8 * ESPResSo is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * ESPResSo is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21#ifndef CORE_IO_WRITER_H5MD_SPECIFICATION_HPP
22#define CORE_IO_WRITER_H5MD_SPECIFICATION_HPP
23
24#include <h5xx/h5xx.hpp>
25
26#include <algorithm>
27#include <string>
28#include <vector>
29
30namespace Writer {
31namespace H5md {
32
33/**
34 * @brief Layout information for H5MD files.
35 * In order to add a new particle property you have to add an entry to the
36 * H5MD_Specification::DATASETS member and extend the File::write() and the
37 * File::write_units() functions accordingly.
38 */
40
41 struct Dataset {
42 std::string path() const { return group + "/" + name; }
43
44 std::string group;
45 std::string name;
46 hsize_t rank;
47 hid_t type;
48 hsize_t data_dim;
49 bool is_link;
50 };
51
52 H5MD_Specification(unsigned int fields);
53
54 auto const &get_datasets() const { return m_datasets; }
55
56 bool is_compliant(std::string const &filename) const {
57 h5xx::file h5md_file(filename, h5xx::file::in);
58
59 auto const all_groups_exist = std::all_of(
60 m_datasets.begin(), m_datasets.end(), [&h5md_file](auto const &d) {
61 return h5xx::exists_group(h5md_file, d.group);
62 });
63 auto const all_datasets_exist = std::all_of(
64 m_datasets.begin(), m_datasets.end(), [&h5md_file](auto const &d) {
65 return h5xx::exists_dataset(h5md_file, d.path());
66 });
67 return all_groups_exist and all_datasets_exist;
68 }
69
70private:
71 std::vector<Dataset> m_datasets;
72};
73
74} // namespace H5md
75} // namespace Writer
76
77#endif
Layout information for H5MD files.
bool is_compliant(std::string const &filename) const