-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Squashed 'externals/coda-oss/' changes from df07c512d..26de66952
26de66952 Merge branch 'main' into cpp17 605d24898 duplicate existing HDF5 unittests using HighFive (#657) 134233279 add 'override'; fix ASAN-detected memory leaks (#656) git-subtree-dir: externals/coda-oss git-subtree-split: 26de66952d92ee80c1e76232dc9819d062454109
- Loading branch information
Dan Smith
authored and
Dan Smith
committed
Feb 27, 2023
1 parent
a623088
commit 3185aa7
Showing
58 changed files
with
630 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* ========================================================================= | ||
* This file is part of hdf5.lite-c++ | ||
* ========================================================================= | ||
* | ||
* (C) Copyright 2022, Maxar Technologies, Inc. | ||
* | ||
* hdf5.lite-c++ is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this program; If not, | ||
* see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
#ifndef CODA_OSS_hdf5_lite_highfive_h_INCLUDED_ | ||
#define CODA_OSS_hdf5_lite_highfive_h_INCLUDED_ | ||
#pragma once | ||
|
||
/*! | ||
* \file highfive.h | ||
* \brief Utility routines for using HighFive | ||
*/ | ||
|
||
#include <string> | ||
|
||
#include "highfive/H5Easy.hpp" | ||
#include "highfive/H5DataSet.hpp" | ||
|
||
#include "SpanRC.h" | ||
|
||
namespace hdf5 | ||
{ | ||
namespace lite | ||
{ | ||
template <typename T> | ||
inline HighFive::DataSet writeDataSet(H5Easy::File& file, SpanRC<T> data, const std::string& dataset_name /*, TODO ...*/) | ||
{ | ||
const std::vector<size_t> dims{data.dims().row, data.dims().col}; | ||
const HighFive::DataSpace dataspace{dims}; | ||
auto retval = file.createDataSet<T>(dataset_name, dataspace); | ||
retval.write_raw(data.data()); | ||
return retval; | ||
} | ||
|
||
template <typename T> | ||
inline SpanRC<T> readDataSet(HighFive::DataSet& dataSet, std::vector<T>& result /*, TODO ...*/) | ||
{ | ||
const auto dimensions = dataSet.getSpace().getDimensions(); | ||
const types::RowCol<size_t> dims(dimensions[0], dimensions[1]); | ||
|
||
result.resize(dims.area()); | ||
dataSet.read(result.data()); | ||
|
||
return SpanRC<T>(result.data(), dims); | ||
} | ||
|
||
template <typename T> | ||
inline SpanRC<T> load(H5Easy::File& file, const std::string& dataset_name, std::vector<T>& result /*, TODO ...*/) | ||
{ | ||
auto dataSet = file.getDataSet(dataset_name); | ||
return readDataSet(dataSet, result); | ||
} | ||
|
||
} | ||
} | ||
|
||
#endif // CODA_OSS_hdf5_lite_highfive_h_INCLUDED_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.