24 #include "openPMD/config.hpp" 25 #include "openPMD/auxiliary/Filesystem.hpp" 26 #include "openPMD/IO/AbstractIOHandler.hpp" 27 #include "openPMD/IO/AbstractIOHandlerImpl.hpp" 28 #include "openPMD/IO/Access.hpp" 29 #include "openPMD/IO/JSON/JSONFilePosition.hpp" 31 #include <nlohmann/json.hpp> 37 #include <unordered_map> 38 #include <unordered_set> 60 explicit File( std::string s ) :
61 fileState { std::make_shared< FileState >( s ) }
71 name { std::move( s ) }
79 std::shared_ptr< FileState > fileState;
84 fileState->valid =
false;
90 return fileState->valid;
94 File & operator=( std::string s )
102 fileState = std::make_shared< FileState >( s );
112 return this->fileState == f.fileState;
116 std::string & operator*( )
const 118 return fileState->name;
122 std::string * operator->( )
const 124 return &fileState->name;
128 explicit operator bool( )
const 130 return fileState.operator bool( );
141 typedef std::size_t result_type;
144 result_type operator()( argument_type
const & s )
const noexcept
146 return std::hash< shared_ptr< openPMD::File::FileState>> {}( s.fileState );
151 template<
class T >
void to_json(nlohmann::json &j,
const std::complex< T > &p) {
152 j = nlohmann::json {p.real(), p.imag()};
155 template<
class T >
void from_json(
const nlohmann::json &j, std::complex< T > &p) {
166 using json = nlohmann::json;
234 void deleteAttribute(
274 std::future< void > flush( )
override;
279 using FILEHANDLE = std::fstream;
290 std::shared_ptr< nlohmann::json >> m_jsonVals;
293 std::unordered_set< File > m_dirty;
302 std::shared_ptr< FILEHANDLE > getFilehandle(
308 std::string fullPath( File );
310 std::string fullPath( std::string
const & );
314 static void parentDir( std::string & );
318 static std::string filepositionOf( Writable * w );
328 static void syncMultidimensionalJson(
330 Offset
const & offset,
331 Extent
const & extent,
332 Extent
const & multiplicator,
335 size_t currentdim = 0
342 static Extent getMultiplicators( Extent
const & extent );
344 static nlohmann::json initializeNDArray( Extent
const & extent );
346 static Extent getExtent( nlohmann::json & j );
350 static std::string removeSlashes( std::string );
352 template<
typename KeyT >
360 static void ensurePath(
361 nlohmann::json * json,
377 > getPossiblyExisting(
383 std::shared_ptr< nlohmann::json > obtainJsonContents( File );
386 nlohmann::json & obtainJsonContents( Writable * writable );
390 void putJsonContents(
392 bool unsetDirty =
true 398 std::shared_ptr< JSONFilePosition > setAndGetFilePosition(
406 std::shared_ptr< JSONFilePosition > setAndGetFilePosition(
414 File refreshFileFromParent( Writable * writable );
416 void associateWithFile(
422 static bool isGroup( nlohmann::json::const_iterator it );
424 static bool isDataset( nlohmann::json
const & j );
428 template<
typename Param >
430 Param
const & parameters,
434 static nlohmann::json platformSpecifics( );
438 template<
typename T >
440 nlohmann::json & json,
446 nlohmann::json & json,
454 template<
typename T >
456 nlohmann::json & json,
462 nlohmann::json & json,
467 struct AttributeWriter
469 template<
typename T >
472 Attribute::resource
const &
478 Attribute::resource
const &
483 struct AttributeReader
485 template<
typename T >
499 template<
typename T >
502 nlohmann::json operator()(
T const & );
505 template<
typename T >
506 struct CppToJSON< std::vector< T>>
508 nlohmann::json operator()( std::vector< T >
const & );
511 template<
typename T,
int n >
517 nlohmann::json operator()(
531 T operator()( nlohmann::json
const & );
534 template<
typename T >
535 struct JsonToCpp< std::vector< T > >
537 std::vector< T > operator()( nlohmann::json
const & );
540 template<
typename T,
int n >
551 > operator()( nlohmann::json
const & );
554 template<
typename T >
557 typename std::enable_if<
558 std::is_floating_point<
564 T operator()( nlohmann::json
const & );
Definition: JSONIOHandlerImpl.hpp:68
Access
File access mode to use during IO.
Definition: Access.hpp:28
Definition: IOTask.hpp:139
Definition: IOTask.hpp:223
Definition: IOTask.hpp:320
Definition: JSONIOHandlerImpl.hpp:58
Definition: JSONIOHandlerImpl.hpp:163
Definition: IOTask.hpp:123
Definition: IOTask.hpp:153
Definition: IOTask.hpp:412
Interface for communicating between logical and physically persistent data.
Definition: AbstractIOHandler.hpp:68
Public definitions of openPMD-api.
Definition: Date.cpp:29
Layer to mirror structure of logical data and persistent data in file.
Definition: Writable.hpp:55
Definition: IOTask.hpp:365
Definition: IOTask.hpp:475
Definition: IOTask.hpp:107
Definition: IOTask.hpp:516
Definition: IOTask.hpp:394
Definition: IOTask.hpp:299
Definition: IOTask.hpp:169
Definition: AbstractIOHandlerImpl.hpp:35
Definition: IOTask.hpp:428
Definition: IOTask.hpp:256
Definition: IOTask.hpp:447
Definition: IOTask.hpp:281
Definition: IOTask.hpp:207
Definition: IOTask.hpp:336
Definition: IOTask.hpp:239