openPMD-api
 
Loading...
Searching...
No Matches
AbstractIOHandlerImpl.hpp
1/* Copyright 2018-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/Error.hpp"
24#include "openPMD/IO/AbstractIOHandler.hpp"
25#include "openPMD/IO/IOTask.hpp"
26#include "openPMD/auxiliary/DerefDynamicCast.hpp"
27
28#include <future>
29
30namespace openPMD
31{
32// class AbstractIOHandler;
33class Writable;
34
35class AbstractIOHandlerImpl
36{
37public:
38 AbstractIOHandlerImpl(AbstractIOHandler *handler);
39
40 virtual ~AbstractIOHandlerImpl() = default;
41
42 std::future<void> flush();
43
48 virtual void
50
61
84 virtual void advance(Writable *, Parameter<Operation::ADVANCE> &parameters)
85 {
86 if (parameters.isThisStepMandatory)
87 {
89 m_handler->backendName(),
90 "Variable-based encoding requires backend support for IO steps "
91 "in order to store more than one iteration (only supported in "
92 "ADIOS2 backend).");
93 }
94 *parameters.status = AdvanceStatus::RANDOMACCESS;
95 }
96
110 {}
111
118 virtual void
120
137 virtual void
148 virtual void
169 virtual void
180 virtual void
206 virtual void
219 virtual void
232 virtual void
247 virtual void
261 virtual void
272 virtual void
288 virtual void
290
316 virtual void
318 {
319 // default implementation: operation unsupported by backend
320 parameters.out->backendManagedBuffer = false;
321 }
322
339 virtual void
354 virtual void
368 virtual void
386 virtual void readAttributeAllsteps(
403 virtual void
412 virtual void
414
422 virtual void
424
427 virtual void
429
430 virtual void
431 setWritten(Writable *, Parameter<Operation::SET_WRITTEN> const &param);
432
433 AbstractIOHandler *m_handler;
434 bool m_verboseIOTasks = false;
435
436 // Args will be forwarded to std::cerr if m_verboseIOTasks is true
437 template <typename... Args>
438 void writeToStderr(Args &&...) const;
439}; // AbstractIOHandlerImpl
440} // namespace openPMD
Interface for communicating between logical and physically persistent data.
Definition AbstractIOHandler.hpp:206
virtual void deleteDataset(Writable *, Parameter< Operation::DELETE_DATASET > const &)=0
Delete an existing dataset.
virtual void writeDataset(Writable *, Parameter< Operation::WRITE_DATASET > &)=0
Write a chunk of data into an existing dataset.
virtual void readDataset(Writable *, Parameter< Operation::READ_DATASET > &)=0
Read a chunk of data from an existing dataset.
virtual void advance(Writable *, Parameter< Operation::ADVANCE > &parameters)
Advance the file/stream that this writable belongs to.
Definition AbstractIOHandlerImpl.hpp:84
virtual void getBufferView(Writable *, Parameter< Operation::GET_BUFFER_VIEW > &parameters)
Get a view into a dataset buffer that can be filled by a user.
Definition AbstractIOHandlerImpl.hpp:317
virtual void listAttributes(Writable *, Parameter< Operation::LIST_ATTS > &)=0
List all attributes associated with an object.
virtual void deregister(Writable *, Parameter< Operation::DEREGISTER > const &param)=0
Notify the backend that the Writable has been / will be deallocated.
virtual void availableChunks(Writable *, Parameter< Operation::AVAILABLE_CHUNKS > &)=0
Report chunks that are available for loading from the dataset represented by this writable.
virtual void checkFile(Writable *, Parameter< Operation::CHECK_FILE > &)=0
Check if the file specified by the parameter is already present on disk.
virtual void createDataset(Writable *, Parameter< Operation::CREATE_DATASET > const &)=0
Create a new dataset of given type, extent and storage properties.
virtual void touch(Writable *, Parameter< Operation::TOUCH > const &param)=0
Treat this writable's file as open/active/dirty.
virtual void closePath(Writable *, Parameter< Operation::CLOSE_PATH > const &)
Close an openPMD group.
Definition AbstractIOHandlerImpl.hpp:109
virtual void openDataset(Writable *, Parameter< Operation::OPEN_DATASET > &)=0
Open an existing dataset and determine its datatype and extent.
virtual void readAttribute(Writable *, Parameter< Operation::READ_ATT > &)=0
Read the value of an existing attribute.
virtual void createPath(Writable *, Parameter< Operation::CREATE_PATH > const &)=0
Create all necessary groups for a path, possibly recursively.
virtual void openFile(Writable *, Parameter< Operation::OPEN_FILE > &)=0
Open an existing file assuming it conforms to openPMD.
virtual void closeFile(Writable *, Parameter< Operation::CLOSE_FILE > const &)=0
Close the file corresponding with the writable and release file handles.
virtual void listPaths(Writable *, Parameter< Operation::LIST_PATHS > &)=0
List all paths/sub-groups inside a group, non-recursively.
virtual void extendDataset(Writable *, Parameter< Operation::EXTEND_DATASET > const &)=0
Increase the extent of an existing dataset.
virtual void writeAttribute(Writable *, Parameter< Operation::WRITE_ATT > const &)=0
Create a single attribute and fill the value, possibly overwriting an existing attribute.
virtual void deleteAttribute(Writable *, Parameter< Operation::DELETE_ATT > const &)=0
Delete an existing attribute.
virtual void readAttributeAllsteps(Writable *, Parameter< Operation::READ_ATT_ALLSTEPS > &)
Collective task to read modifiable attributes over steps.
Definition AbstractIOHandlerImpl.cpp:512
virtual void deleteFile(Writable *, Parameter< Operation::DELETE_FILE > const &)=0
Delete an existing file from physical storage.
virtual void createFile(Writable *, Parameter< Operation::CREATE_FILE > const &)=0
Create a new file in physical storage, possibly overriding an existing file.
virtual void listDatasets(Writable *, Parameter< Operation::LIST_DATASETS > &)=0
List all datasets inside a group, non-recursively.
virtual void deletePath(Writable *, Parameter< Operation::DELETE_PATH > const &)=0
Delete all objects within an existing path.
virtual void openPath(Writable *, Parameter< Operation::OPEN_PATH > const &)=0
Open all contained groups in a path, possibly recursively.
Layer to mirror structure of logical data and persistent data in file.
Definition Writable.hpp:76
An operation was requested that is not supported in a specific backend.
Definition Error.hpp:70
Public definitions of openPMD-api.
Definition Date.cpp:29
@ RANDOMACCESS
there is no stream, it will never be over
Definition Streaming.hpp:35
Typesafe description of all required arguments for a specified Operation.
Definition IOTask.hpp:148