openPMD-api
Writable.hpp
1 /* Copyright 2017-2021 Fabian Koller
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/IO/AbstractIOHandler.hpp"
24 
25 #include <memory>
26 #include <string>
27 #include <vector>
28 
29 // expose private and protected members for invasive testing
30 #ifndef OPENPMD_private
31 #define OPENPMD_private private
32 #endif
33 
34 namespace openPMD
35 {
36 namespace test
37 {
38  struct TestHelper;
39 } // namespace test
40 class AbstractFilePosition;
41 class AbstractIOHandler;
42 struct ADIOS2FilePosition;
43 template <typename FilePositionType>
45 template <typename>
46 class Span;
47 
48 namespace internal
49 {
50  class AttributableData;
51 }
52 
63 class Writable final
64 {
65  friend class internal::AttributableData;
66  friend class AttributableInterface;
67  template <typename T_elem>
68  friend class BaseRecord;
69  template <typename T, typename T_key, typename T_container>
70  friend class Container;
71  friend class Iteration;
72  friend class Mesh;
73  friend class ParticleSpecies;
74  friend class SeriesInterface;
75  friend class Record;
76  friend class ADIOS1IOHandlerImpl;
77  friend class ParallelADIOS1IOHandlerImpl;
78  friend class ADIOS2IOHandlerImpl;
79  friend class HDF5IOHandlerImpl;
80  friend class ParallelHDF5IOHandlerImpl;
81  friend class AbstractIOHandlerImplCommon<ADIOS2FilePosition>;
82  friend class JSONIOHandlerImpl;
83  friend struct test::TestHelper;
84  friend std::string concrete_h5_file_position(Writable *);
85  friend std::string concrete_bp1_file_position(Writable *);
86  template <typename>
87  friend class Span;
88 
89 private:
91 
92 public:
93  ~Writable() = default;
94 
95  Writable(Writable const &other) = delete;
96  Writable(Writable &&other) = delete;
97  Writable &operator=(Writable const &other) = delete;
98  Writable &operator=(Writable &&other) = delete;
99 
107  void seriesFlush();
108 
109  OPENPMD_private:
110  void seriesFlush(internal::FlushParams);
111  /*
112  * These members need to be shared pointers since distinct instances of
113  * Writable may share them.
114  */
115  std::shared_ptr<AbstractFilePosition> abstractFilePosition = nullptr;
116  std::shared_ptr<AbstractIOHandler> IOHandler = nullptr;
117  internal::AttributableData *attributable = nullptr;
118  Writable *parent = nullptr;
119  bool dirty = true;
126  std::vector<std::string> ownKeyWithinParent;
142  bool written = false;
143 };
144 } // namespace openPMD
Logical compilation of data from one snapshot (e.g.
Definition: Iteration.hpp:40
Definition: ADIOS2IOHandler.hpp:106
Definition: JSONIOHandlerImpl.hpp:151
Definition: ParallelHDF5IOHandlerImpl.hpp:37
Public definitions of openPMD-api.
Definition: Date.cpp:28
Layer to mirror structure of logical data and persistent data in file.
Definition: Writable.hpp:63
Definition: Record.hpp:32
Layer to manage storage of attributes associated with file objects.
Definition: Attributable.hpp:128
Definition: Attributable.hpp:68
Definition: ADIOS1IOHandlerImpl.hpp:43
Definition: BaseRecord.hpp:35
Parameters recursively passed through the openPMD hierarchy when flushing.
Definition: AbstractIOHandler.hpp:103
Implementation for the root level of the openPMD hierarchy.
Definition: Series.hpp:110
Definition: Writable.hpp:44
Subset of C++20 std::span class template.
Definition: Writable.hpp:46
Definition: ParticleSpecies.hpp:33
Container for N-dimensional, homogeneous Records.
Definition: Mesh.hpp:40
Map-like container that enforces openPMD requirements and handles IO.
Definition: Container.hpp:105
Definition: HDF5IOHandlerImpl.hpp:38
Definition: ParallelADIOS1IOHandlerImpl.hpp:44