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 <string>
26 #include <memory>
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 
35 namespace openPMD
36 {
37 namespace test
38 {
39 struct TestHelper;
40 } // namespace test
41 class AbstractFilePosition;
42 class AbstractIOHandler;
43 struct ADIOS2FilePosition;
44 template <typename FilePositionType>
46 template<typename>
47 class Span;
48 
49 namespace internal
50 {
51 class AttributableData;
52 }
53 
54 
64 class Writable final
65 {
66  friend class internal::AttributableData;
67  friend class AttributableInterface;
68  template< typename T_elem >
69  friend class BaseRecord;
70  template<
71  typename T,
72  typename T_key,
73  typename T_container
74  >
75  friend class Container;
76  friend class Iteration;
77  friend class Mesh;
78  friend class ParticleSpecies;
79  friend class SeriesInterface;
80  friend class Record;
81  friend class ADIOS1IOHandlerImpl;
82  friend class ParallelADIOS1IOHandlerImpl;
83  friend class ADIOS2IOHandlerImpl;
84  friend class HDF5IOHandlerImpl;
85  friend class ParallelHDF5IOHandlerImpl;
87  friend class JSONIOHandlerImpl;
88  friend struct test::TestHelper;
89  friend std::string concrete_h5_file_position(Writable*);
90  friend std::string concrete_bp1_file_position(Writable*);
91  template<typename>
92  friend class Span;
93 
94 private:
96 
97 public:
98  ~Writable() = default;
99 
100  Writable( Writable const & other ) = delete;
101  Writable( Writable && other ) = delete;
102  Writable & operator=( Writable const & other ) = delete;
103  Writable & operator=( Writable && other ) = delete;
104 
112  void seriesFlush();
113 
114 OPENPMD_private:
115  void seriesFlush( FlushLevel );
116  /*
117  * These members need to be shared pointers since distinct instances of
118  * Writable may share them.
119  */
120  std::shared_ptr< AbstractFilePosition > abstractFilePosition;
121  std::shared_ptr< AbstractIOHandler > IOHandler;
122  internal::AttributableData* attributable;
123  Writable* parent;
124  bool dirty;
131  std::vector< std::string > ownKeyWithinParent;
147  bool written;
148 };
149 } // namespace openPMD
openPMD::ParticleSpecies
Definition: ParticleSpecies.hpp:34
openPMD::Writable
Layer to mirror structure of logical data and persistent data in file.
Definition: Writable.hpp:64
openPMD::internal::AttributableData
Definition: Attributable.hpp:68
openPMD::AbstractIOHandlerImplCommon
Definition: Writable.hpp:45
openPMD::BaseRecord
Definition: BaseRecord.hpp:36
openPMD::Mesh
Container for N-dimensional, homogeneous Records.
Definition: Mesh.hpp:40
openPMD::UnitDimension::T
@ T
time
openPMD::JSONIOHandlerImpl
Definition: JSONIOHandlerImpl.hpp:163
openPMD::HDF5IOHandlerImpl
Definition: HDF5IOHandlerImpl.hpp:39
openPMD::SeriesInterface
Implementation for the root level of the openPMD hierarchy.
Definition: Series.hpp:112
openPMD::Iteration
Logical compilation of data from one snapshot (e.g.
Definition: Iteration.hpp:39
openPMD::ADIOS2IOHandlerImpl
Definition: ADIOS2IOHandler.hpp:105
openPMD
Public definitions of openPMD-api.
Definition: Date.cpp:29
openPMD::Record
Definition: Record.hpp:33
openPMD::Container
Map-like container that enforces openPMD requirements and handles IO.
Definition: Container.hpp:106
openPMD::Span
Subset of C++20 std::span class template.
Definition: Writable.hpp:47
openPMD::AttributableInterface
Layer to manage storage of attributes associated with file objects.
Definition: Attributable.hpp:115
openPMD::Writable::seriesFlush
void seriesFlush()
Flush the corresponding Series object.
Definition: Writable.cpp:38
openPMD::ParallelHDF5IOHandlerImpl
Definition: ParallelHDF5IOHandlerImpl.hpp:49
openPMD::FlushLevel
FlushLevel
Determine what items should be flushed upon Series::flush()
Definition: AbstractIOHandler.hpp:63
openPMD::ADIOS1IOHandlerImpl
Definition: ADIOS1IOHandlerImpl.hpp:44
openPMD::ParallelADIOS1IOHandlerImpl
Definition: ParallelADIOS1IOHandlerImpl.hpp:101
openPMD::ADIOS2FilePosition
Definition: ADIOS2FilePosition.hpp:31