-
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 3bcb3d874..22a7eab30
22a7eab30 need C++17 in this branch 99daeec9a latest from 'main' b9ea37bbf xml::lite::Validator can be moved (#648) 9cfe9a4a8 Merge branch 'master' e989b0910 createElement() needs to be virtual (#646) 4bdaf10d9 Change xml lite function to virtual (#645) d17b57a54 Merge branch 'master' fa00a5430 move debug -g flags to be turned on only if debugging (#644) 6be8f0a2e move debug -g flags to be turned on only if debugging (#644) 44ab72854 routines for simple writing to HDF5 files (#643) aabc5818e remove more C++11 work-arounds (#642) git-subtree-dir: externals/coda-oss git-subtree-split: 22a7eab3010a0074ec244142bba80fc8656ebec3
- Loading branch information
Dan Smith
authored and
Dan Smith
committed
Feb 6, 2023
1 parent
ffe62b2
commit 4aa2813
Showing
19 changed files
with
523 additions
and
63 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/* ========================================================================= | ||
* 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_SpanRC_h_INCLUDED_ | ||
#define CODA_OSS_hdf5_lite_SpanRC_h_INCLUDED_ | ||
#pragma once | ||
|
||
/*! | ||
* \file SpanRC.h | ||
* | ||
* This is a super-simple version of C++23's mdspan. It's here because 1) don't want widespread use, and | ||
* 2) CODA already has a View2D. | ||
*/ | ||
|
||
#include <assert.h> | ||
|
||
#include "config/Exports.h" | ||
#include "coda_oss/span.h" | ||
#include "types/RowCol.h" | ||
|
||
namespace hdf5 | ||
{ | ||
namespace lite | ||
{ | ||
|
||
template<typename T> | ||
struct SpanRC final | ||
{ | ||
using size_type = types::RowCol<size_t>; | ||
using element_type = T; | ||
using pointer = T*; | ||
using reference = T&; | ||
|
||
SpanRC() = default; | ||
SpanRC(pointer p, size_type rc) noexcept : s_(p, rc.area()), rc_(rc) | ||
{ | ||
} | ||
SpanRC(pointer p, size_t r, size_t c) noexcept : SpanRC(p, size_type(r, c)) | ||
{ | ||
} | ||
SpanRC(const SpanRC&) noexcept = default; | ||
|
||
constexpr pointer data() const noexcept | ||
{ | ||
return s_.data(); | ||
} | ||
|
||
/*constexpr*/ reference operator[](size_t idx) const noexcept | ||
{ | ||
assert(idx < size()); // prevents "constexpr" in C++11 | ||
return data()[idx]; | ||
} | ||
/*constexpr*/ reference operator()(size_t r, size_t c) const noexcept | ||
{ | ||
const auto offset = (r * dims().col) + c; | ||
return (*this)[offset]; | ||
} | ||
/*constexpr*/ reference operator[](size_type idx) const noexcept | ||
{ | ||
return (*this)(idx.row, idx.col); | ||
} | ||
|
||
constexpr size_t size() const noexcept | ||
{ | ||
assert(s_.size() == rc_.area()); | ||
return s_.size(); | ||
} | ||
constexpr size_t area() const noexcept | ||
{ | ||
return size(); | ||
} | ||
|
||
constexpr size_type size_bytes() const noexcept | ||
{ | ||
return s_.size_bytes(); | ||
} | ||
|
||
constexpr bool empty() const noexcept | ||
{ | ||
return s_.empty(); | ||
} | ||
|
||
const auto& dims() const | ||
{ | ||
return rc_; | ||
} | ||
|
||
private: | ||
types::RowCol<size_t> rc_; | ||
coda_oss::span<T> s_; | ||
}; | ||
|
||
} | ||
} | ||
|
||
#endif // CODA_OSS_hdf5_lite_SpanRC_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* ========================================================================= | ||
* This file is part of hdf5.lite-c++ | ||
* ========================================================================= | ||
* | ||
* (C) Copyright 2023, 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_Write_h_INCLUDED_ | ||
#define CODA_OSS_hdf5_lite_Write_h_INCLUDED_ | ||
#pragma once | ||
|
||
/*! | ||
* \file Read.h | ||
* \brief HDF File-reading API | ||
* | ||
* These are simple routines to write HDF5 files; they're loosely modeled after the MATLab API | ||
* https://www.mathworks.com/help/matlab/ref/h5create.html | ||
* https://www.mathworks.com/help/matlab/ref/h5write.html | ||
*/ | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
#include "config/Exports.h" | ||
#include "sys/filesystem.h" | ||
#include "types/RowCol.h" | ||
|
||
#include "SpanRC.h" | ||
|
||
namespace hdf5 | ||
{ | ||
namespace lite | ||
{ | ||
template<typename TDataSet> // currently implemented for float and double | ||
CODA_OSS_API void createFile(const coda_oss::filesystem::path&, const std::string& ds, const types::RowCol<size_t>&); | ||
CODA_OSS_API void createFile(const coda_oss::filesystem::path&, const std::string& ds, SpanRC<const double>); | ||
inline void createFile(const coda_oss::filesystem::path& path, const std::string& ds, SpanRC<double> data_) | ||
{ | ||
SpanRC<const double> data(data_.data(), data_.dims()); | ||
createFile(path, ds, data); | ||
} | ||
CODA_OSS_API void createFile(const coda_oss::filesystem::path&, const std::string& ds, SpanRC<const float>); | ||
inline void createFile(const coda_oss::filesystem::path& path, const std::string& ds, SpanRC<float> data_) | ||
{ | ||
SpanRC<const float> data(data_.data(), data_.dims()); | ||
createFile(path, ds, data); | ||
} | ||
|
||
CODA_OSS_API void writeFile(const coda_oss::filesystem::path&, const std::string& loc, SpanRC<const double>); | ||
inline void writeFile(const coda_oss::filesystem::path& path, const std::string& ds, SpanRC<double> data_) | ||
{ | ||
SpanRC<const double> data(data_.data(), data_.dims()); | ||
writeFile(path, ds, data); | ||
} | ||
CODA_OSS_API void writeFile(const coda_oss::filesystem::path&, const std::string& loc, SpanRC<const float>); | ||
inline void writeFile(const coda_oss::filesystem::path& path, const std::string& ds, SpanRC<float> data_) | ||
{ | ||
SpanRC<const float> data(data_.data(), data_.dims()); | ||
writeFile(path, ds, data); | ||
} | ||
|
||
} | ||
} | ||
|
||
#endif // CODA_OSS_hdf5_lite_Write_h_INCLUDED_ |
Oops, something went wrong.