openPMD-api
AbstractIOHandlerImpl.hpp
1 /* Copyright 2018-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/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 
30 namespace openPMD
31 {
32 // class AbstractIOHandler;
33 class Writable;
34 
36 {
37 public:
39 
40  virtual ~AbstractIOHandlerImpl() = default;
41 
42  std::future<void> flush();
43 
48  virtual void
50 
61 
77  virtual void advance(Writable *, Parameter<Operation::ADVANCE> &parameters)
78  {
79  if (parameters.isThisStepMandatory)
80  {
82  m_handler->backendName(),
83  "Variable-based encoding requires backend support for IO steps "
84  "in order to store more than one iteration (only supported in "
85  "ADIOS2 backend).");
86  }
87  *parameters.status = AdvanceStatus::RANDOMACCESS;
88  }
89 
103  {}
104 
111  virtual void
113 
130  virtual void
141  virtual void
160  virtual void
171  virtual void
197  virtual void
210  virtual void
223  virtual void
238  virtual void
252  virtual void
263  virtual void
279  virtual void
281 
307  virtual void
309  {
310  // default implementation: operation unsupported by backend
311  parameters.out->backendManagedBuffer = false;
312  }
330  virtual void
345  virtual void
359  virtual void
376  virtual void
385  virtual void
387 
395  virtual void
397 
398  AbstractIOHandler *m_handler;
399  bool m_verboseIOTasks = false;
400 
401  // Args will be forwarded to std::cerr if m_verboseIOTasks is true
402  template <typename... Args>
403  void writeToStderr(Args &&...) const;
404 }; // AbstractIOHandlerImpl
405 } // namespace openPMD
Interface for communicating between logical and physically persistent data.
Definition: AbstractIOHandler.hpp:186
virtual std::string backendName() const =0
The currently used backend.
Definition: AbstractIOHandlerImpl.hpp:36
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:77
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:308
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 closePath(Writable *, Parameter< Operation::CLOSE_PATH > const &)
Close an openPMD group.
Definition: AbstractIOHandlerImpl.hpp:102
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 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:75
An operation was requested that is not supported in a specific backend.
Definition: Error.hpp:50
Public definitions of openPMD-api.
Definition: Date.cpp:29
@ RANDOMACCESS
there is no stream, it will never be over
std::shared_ptr< AdvanceStatus > status
output parameter
Definition: IOTask.hpp:614