openPMD-api
 
Loading...
Searching...
No Matches
Record.hpp
1/* Copyright 2017-2025 Fabian Koller, Axel Huebl, Franz Poeschel
2 *
3 * This file is part of openPMD-api.
4 *
5 * openPMD-api is free software: you can redistribute it and/or modify
6 * it under the terms of of either the GNU General Public License or
7 * the GNU Lesser General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * openPMD-api is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License and the GNU Lesser General Public License
15 * for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * and the GNU Lesser General Public License along with openPMD-api.
19 * If not, see <http://www.gnu.org/licenses/>.
20 */
21#pragma once
22
23#include "openPMD/RecordComponent.hpp"
24#include "openPMD/UnitDimension.hpp"
25#include "openPMD/backend/BaseRecord.hpp"
26
27#include <string>
28#include <type_traits>
29
30namespace openPMD
31{
32class Record : public BaseRecord<RecordComponent>
33{
34 friend class Container<Record>;
35 friend class Iteration;
36 friend class ParticleSpecies;
37
38public:
39 Record(Record const &) = default;
40 Record &operator=(Record const &) = default;
41 ~Record() override = default;
42
43 Record &setUnitDimension(unit_representations::AsMap const &);
44 Record &setUnitDimension(unit_representations::AsArray const &);
45
46 template <typename T>
47 T timeOffset() const;
48 template <typename T>
49 Record &setTimeOffset(T);
50
51private:
52 Record();
53
54 void
55 flush_impl(std::string const &, internal::FlushParams const &) override;
56
57 [[nodiscard]] internal::HomogenizeExtents read();
58}; // Record
59
60template <typename T>
61inline T Record::timeOffset() const
62{
63 return readFloatingpoint<T>("timeOffset");
64}
65
66template <typename T>
67inline Record &Record::setTimeOffset(T to)
68{
69 static_assert(
70 std::is_floating_point<T>::value,
71 "Type of attribute must be floating point");
72
73 setAttribute("timeOffset", to);
74 return *this;
75}
76} // namespace openPMD
T readFloatingpoint(std::string const &key) const
Retrieve the value of a floating point Attribute of user-defined precision with ensured type-safety.
Definition Attributable.hpp:658
bool setAttribute(std::string const &key, T value)
Populate Attribute of provided name with provided value.
Definition Attributable.hpp:621
Map-like container that enforces openPMD requirements and handles IO.
Definition Container.hpp:104
Public definitions of openPMD-api.
Definition Date.cpp:29
@ T
time
Definition UnitDimension.hpp:41
Parameters recursively passed through the openPMD hierarchy when flushing.
Definition AbstractIOHandler.hpp:106
Definition RecordComponent.hpp:550