Advanced Multi-Physics (AMP)
On-Line Documentation
HDF5_Class.h
Go to the documentation of this file.
1// This file contains helper functions and interfaces for reading/writing HDF5
2#ifndef included_AMP_HDF5_Class_h
3#define included_AMP_HDF5_Class_h
4
5#include <cstring>
6#include <memory>
7#include <string>
8#include <string_view>
9
10#include "AMP/AMP_TPLs.h"
11#include "AMP/IO/HDF.h"
12#include "AMP/utils/Array.h"
13
14
15namespace AMP::IO {
16
17
19class HDF5data : public std::enable_shared_from_this<HDF5data>
20{
21public:
23 virtual ~HDF5data() {}
24
26 virtual std::string type() const = 0;
27
29 virtual size_t size() const = 0;
30
32 virtual std::shared_ptr<HDF5data> getData( size_t i, const std::string_view &name ) = 0;
33
35 std::shared_ptr<const HDF5data> getData( size_t i, const std::string_view &name ) const;
36
38 virtual std::vector<std::string> getNames() const = 0;
39
41 virtual AMP::ArraySize getDataSize() const = 0;
42
44 template<class TYPE>
45 void getData( AMP::Array<TYPE> &data ) const;
46
48 virtual void print( int level = 1, const std::string_view &prefix = "" ) const = 0;
49
51 inline const std::string &name() const { return d_name; }
52
54 virtual bool operator==( const HDF5data &rhs ) const = 0;
55
57 inline bool operator!=( const HDF5data &rhs ) const { return !operator==( rhs ); }
58
59
60protected:
61 HDF5data( hid_t fid, const std::string_view &name ) : d_fid( fid ), d_name( name ) {}
62
64 std::string d_name;
65};
66
67
76std::unique_ptr<HDF5data> readHDF5( hid_t fid, const std::string_view &name );
77
78
79} // namespace AMP::IO
80
81
82#endif
int64_t hid_t
Definition HDF.h:23
Simple class to store the array dimensions.
Definition ArraySize.h:138
Class to wrap HDF5 data.
Definition HDF5_Class.h:20
const std::string & name() const
Return the name of the variable.
Definition HDF5_Class.h:51
void getData(AMP::Array< TYPE > &data) const
Get the data.
virtual size_t size() const =0
Number of entries.
virtual AMP::ArraySize getDataSize() const =0
Get the data.
HDF5data(hid_t fid, const std::string_view &name)
Definition HDF5_Class.h:61
virtual std::string type() const =0
Return a string identifying the class.
virtual std::vector< std::string > getNames() const =0
Get the variable names.
std::shared_ptr< const HDF5data > getData(size_t i, const std::string_view &name) const
Get the data ith block and jth child.
virtual void print(int level=1, const std::string_view &prefix="") const =0
Print information about the data.
bool operator!=(const HDF5data &rhs) const
Check if two objects are not equal.
Definition HDF5_Class.h:57
virtual ~HDF5data()
Virtual destructor.
Definition HDF5_Class.h:23
virtual std::shared_ptr< HDF5data > getData(size_t i, const std::string_view &name)=0
Get the data ith block and jth child.
std::string d_name
Definition HDF5_Class.h:64
virtual bool operator==(const HDF5data &rhs) const =0
Check if two objects are equal.
void readHDF5(hid_t fid, const std::string &name, T &data)
Read a structure from HDF5.



Advanced Multi-Physics (AMP)
Oak Ridge National Laboratory
Idaho National Laboratory
Los Alamos National Laboratory
This page automatically produced from the
source code by doxygen
Last updated: Tue Mar 10 2026 13:06:40.
Comments on this page