Skip to content

Commit

Permalink
Make closing and reopening work in HDF5
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Nov 20, 2020
1 parent 65d14d9 commit 529f185
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 108 deletions.
13 changes: 12 additions & 1 deletion include/openPMD/IO/HDF5/HDF5IOHandlerImpl.hpp
Expand Up @@ -23,6 +23,9 @@
#include "openPMD/config.hpp"
#if openPMD_HAVE_HDF5
# include "openPMD/IO/AbstractIOHandlerImpl.hpp"

# include "openPMD/auxiliary/Option.hpp"

# include <hdf5.h>
# include <unordered_map>
# include <unordered_set>
Expand Down Expand Up @@ -58,7 +61,7 @@ namespace openPMD
void listDatasets(Writable*, Parameter< Operation::LIST_DATASETS > &) override;
void listAttributes(Writable*, Parameter< Operation::LIST_ATTS > &) override;

std::unordered_map< Writable*, hid_t > m_fileIDs;
std::unordered_map< Writable*, std::string > m_fileNames;
std::unordered_map< std::string, hid_t > m_fileNamesWithID;

std::unordered_set< hid_t > m_openFileIDs;
Expand All @@ -71,6 +74,14 @@ namespace openPMD
hid_t m_H5T_CFLOAT;
hid_t m_H5T_CDOUBLE;
hid_t m_H5T_CLONG_DOUBLE;

private:
struct File
{
std::string name;
hid_t id;
};
auxiliary::Option< File > getFile( Writable * );
}; // HDF5IOHandlerImpl
#else
class HDF5IOHandlerImpl
Expand Down
6 changes: 4 additions & 2 deletions include/openPMD/auxiliary/Option.hpp
Expand Up @@ -24,6 +24,7 @@
#include "VariantSrc.hpp"

#include <utility> // std::forward, std::move
#include <type_traits>


namespace openPMD
Expand Down Expand Up @@ -162,10 +163,11 @@ namespace auxiliary
};

template< typename T >
Option< T >
Option< typename std::decay< T >::type >
makeOption( T && val )
{
return Option< T >( std::forward< T >( val ) );
return Option< typename std::decay< T >::type >(
std::forward< T >( val ) );
}
} // namespace auxiliary
} // namespace openPMD

0 comments on commit 529f185

Please sign in to comment.