Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
HAPI_HDFData.cc
Go to the documentation of this file.
1/*
2# <<BEGIN-copyright>>
3# Copyright 2019, Lawrence Livermore National Security, LLC.
4# This file is part of the gidiplus package (https://github.com/LLNL/gidiplus).
5# gidiplus is licensed under the MIT license (see https://opensource.org/licenses/MIT).
6# SPDX-License-Identifier: MIT
7# <<END-copyright>>
8*/
9
10#include "HAPI.hpp"
11
12#ifdef HAPI_USE_HDF5
13namespace HAPI {
14
15/*
16=========================================================
17 *
18 * @return
19 */
20HDFData::HDFData() :
21 m_node_id(-1),
22 m_dataspace_id(-1),
23 m_length(0) {
24
25}
26/*
27=========================================================
28 *
29 * @param a_node
30 * @return
31 */
32HDFData::HDFData( hid_t node_id ) :
33 m_node_id(node_id) {
34
35 m_dataspace_id = H5Dget_space(m_node_id);
36 hssize_t n_points = H5Sget_simple_extent_npoints(m_dataspace_id);
37 if (n_points < 0) {
38 throw std::runtime_error("HDF5 error: failed to get dataset size!");
39 }
40 m_length = (size_t)n_points;
41
42}
43/*
44=========================================================
45*/
46HDFData::~HDFData( ) {
47
48}
49
50size_t HDFData::length( ) const {
51
52 return m_length;
53}
54
55void HDFData::getDoubles(nf_Buffer<double> &buffer)
56{
57 buffer.resize(m_length);
58 H5Dread(m_node_id, H5T_NATIVE_DOUBLE, H5S_ALL, m_dataspace_id, H5P_DEFAULT, buffer.data());
59}
60
61void HDFData::getInts(nf_Buffer<int> &buffer)
62{
63 buffer.resize(m_length);
64 H5Dread(m_node_id, H5T_NATIVE_INT, H5S_ALL, m_dataspace_id, H5P_DEFAULT, buffer.data());
65}
66
67}
68#endif
Definition HAPI.hpp:34