From ab5b3f8f4ae59a10e271f457d31c657dbe6de989 Mon Sep 17 00:00:00 2001 From: Luc Grosheintz Date: Thu, 8 Feb 2024 17:25:42 +0100 Subject: [PATCH 1/4] Remove `read(T*, ...)`. (#942) --- include/highfive/H5Attribute.hpp | 10 ------- include/highfive/bits/H5Attribute_misc.hpp | 10 ------- include/highfive/bits/H5Slice_traits.hpp | 30 ------------------- include/highfive/bits/H5Slice_traits_misc.hpp | 14 --------- 4 files changed, 64 deletions(-) diff --git a/include/highfive/H5Attribute.hpp b/include/highfive/H5Attribute.hpp index 1af10cf04..c34f9e49f 100644 --- a/include/highfive/H5Attribute.hpp +++ b/include/highfive/H5Attribute.hpp @@ -113,16 +113,6 @@ class Attribute: public Object, public PathTraits { template void read(T& array) const; - /// \brief Read the attribute into a pre-allocated buffer. - /// \deprecated use `read(T&` or `read_raw`. - template - void read(T* array, const DataType& mem_datatype) const; - - /// \brief Read the attribute into a buffer. - /// \deprecated use `read(T&` or `read_raw`. - template - void read(T* array) const; - /// \brief Read the attribute into a pre-allocated buffer. /// \param array A pointer to the first byte of sufficient pre-allocated memory. /// \param mem_datatype The DataType of the array. diff --git a/include/highfive/bits/H5Attribute_misc.hpp b/include/highfive/bits/H5Attribute_misc.hpp index 3b48c143a..62f6ebd82 100644 --- a/include/highfive/bits/H5Attribute_misc.hpp +++ b/include/highfive/bits/H5Attribute_misc.hpp @@ -101,11 +101,6 @@ inline void Attribute::read(T& array) const { } } -template -inline void Attribute::read(T* array, const DataType& mem_datatype) const { - read_raw(array, mem_datatype); -} - template inline void Attribute::read_raw(T* array, const DataType& mem_datatype) const { static_assert(!std::is_const::value, @@ -114,11 +109,6 @@ inline void Attribute::read_raw(T* array, const DataType& mem_datatype) const { detail::h5a_read(getId(), mem_datatype.getId(), static_cast(array)); } -template -inline void Attribute::read(T* array) const { - read_raw(array); -} - template inline void Attribute::read_raw(T* array) const { using element_type = typename details::inspector::base_type; diff --git a/include/highfive/bits/H5Slice_traits.hpp b/include/highfive/bits/H5Slice_traits.hpp index 556683853..fd8c31d27 100644 --- a/include/highfive/bits/H5Slice_traits.hpp +++ b/include/highfive/bits/H5Slice_traits.hpp @@ -303,36 +303,6 @@ class SliceTraits { template void read(T& array, const DataTransferProps& xfer_props = DataTransferProps()) const; - /// - /// Read the entire dataset into a raw buffer - /// - /// \deprecated Use `read_raw` instead. - /// - /// No dimensionality checks will be performed, it is the user's - /// responsibility to ensure that the right amount of space has been - /// allocated. - /// \param array: A buffer containing enough space for the data - /// \param dtype: The datatype of elements of the in memory buffer. - /// \param xfer_props: Data Transfer properties - template - void read(T* array, - const DataType& dtype, - const DataTransferProps& xfer_props = DataTransferProps()) const; - - /// - /// Read the entire dataset into a raw buffer - /// - /// \deprecated Use `read_raw` instead. - /// - /// Same as `read(T*, const DataType&, const DataTransferProps&)`. However, - /// this overload deduces the HDF5 datatype of the element of `array` from - /// `T`. Note, that the file datatype is already fixed. - /// - /// \param array: A buffer containing enough space for the data - /// \param xfer_props: Data Transfer properties - template - void read(T* array, const DataTransferProps& xfer_props = DataTransferProps()) const; - /// /// Read the entire dataset into a raw buffer /// diff --git a/include/highfive/bits/H5Slice_traits_misc.hpp b/include/highfive/bits/H5Slice_traits_misc.hpp index 88804f6d0..27c103ae2 100644 --- a/include/highfive/bits/H5Slice_traits_misc.hpp +++ b/include/highfive/bits/H5Slice_traits_misc.hpp @@ -207,20 +207,6 @@ inline void SliceTraits::read(T& array, const DataTransferProps& xfer_ } } -template -template -inline void SliceTraits::read(T* array, - const DataType& mem_datatype, - const DataTransferProps& xfer_props) const { - read_raw(array, mem_datatype, xfer_props); -} - -template -template -inline void SliceTraits::read(T* array, const DataTransferProps& xfer_props) const { - read_raw(array, xfer_props); -} - template template From 0b47bad40965c7c19d3d10dec7f75489cd03119a Mon Sep 17 00:00:00 2001 From: Luc Grosheintz Date: Thu, 8 Feb 2024 17:27:05 +0100 Subject: [PATCH 2/4] Macro free dependency handling. (#892) In a prior commit the sources were restructured such that each optional dependency is contained in separate files. This commit removes the macros that controlled which dependencies are included. To include the optional dependency Boost use: #include #include the order doesn't matter. --- include/highfive/bits/H5DataType_misc.hpp | 4 ---- include/highfive/bits/H5Inspector_misc.hpp | 8 -------- include/highfive/boost.hpp | 3 --- include/highfive/eigen.hpp | 3 --- include/highfive/half_float.hpp | 4 +--- src/examples/boost_multi_array_2D.cpp | 4 +--- src/examples/boost_multiarray_complex.cpp | 5 +---- src/examples/boost_ublas_double.cpp | 5 ++--- src/examples/create_dataset_half_float.cpp | 1 + tests/unit/CMakeLists.txt | 12 ++++++++++++ tests/unit/data_generator.hpp | 2 +- tests/unit/tests_high_five.hpp | 2 ++ tests/unit/tests_high_five_base.cpp | 9 +++++++++ tests/unit/tests_high_five_multi_dims.cpp | 1 + 14 files changed, 31 insertions(+), 32 deletions(-) diff --git a/include/highfive/bits/H5DataType_misc.hpp b/include/highfive/bits/H5DataType_misc.hpp index 619e51e71..8098a675c 100644 --- a/include/highfive/bits/H5DataType_misc.hpp +++ b/include/highfive/bits/H5DataType_misc.hpp @@ -520,7 +520,3 @@ inline DataType create_datatype() { } } // namespace HighFive - -#ifdef H5_USE_HALF_FLOAT -#include -#endif diff --git a/include/highfive/bits/H5Inspector_misc.hpp b/include/highfive/bits/H5Inspector_misc.hpp index ac3872dda..d85a4de12 100644 --- a/include/highfive/bits/H5Inspector_misc.hpp +++ b/include/highfive/bits/H5Inspector_misc.hpp @@ -640,11 +640,3 @@ struct inspector { } // namespace details } // namespace HighFive - -#ifdef H5_USE_BOOST -#include -#endif - -#ifdef H5_USE_EIGEN -#include -#endif diff --git a/include/highfive/boost.hpp b/include/highfive/boost.hpp index 8992159a2..3dd4c9f9e 100644 --- a/include/highfive/boost.hpp +++ b/include/highfive/boost.hpp @@ -1,5 +1,4 @@ #pragma once -#ifdef H5_USE_BOOST #include "bits/H5Inspector_decl.hpp" #include "H5Exception.hpp" @@ -160,5 +159,3 @@ struct inspector> { } // namespace details } // namespace HighFive - -#endif diff --git a/include/highfive/eigen.hpp b/include/highfive/eigen.hpp index c47095dde..f91dab24c 100644 --- a/include/highfive/eigen.hpp +++ b/include/highfive/eigen.hpp @@ -1,5 +1,4 @@ #pragma once -#ifdef H5_USE_EIGEN #include "bits/H5Inspector_decl.hpp" #include "H5Exception.hpp" @@ -89,5 +88,3 @@ struct inspector> { } // namespace details } // namespace HighFive - -#endif diff --git a/include/highfive/half_float.hpp b/include/highfive/half_float.hpp index 998e693ff..dc2464c22 100644 --- a/include/highfive/half_float.hpp +++ b/include/highfive/half_float.hpp @@ -1,5 +1,4 @@ #pragma once -#ifdef H5_USE_HALF_FLOAT #include @@ -16,6 +15,5 @@ inline AtomicType::AtomicType() { // Floating point exponent bias detail::h5t_set_ebias(_hid, 15); } -} // namespace HighFive -#endif +} // namespace HighFive diff --git a/src/examples/boost_multi_array_2D.cpp b/src/examples/boost_multi_array_2D.cpp index 4bec1ec12..508c3a880 100644 --- a/src/examples/boost_multi_array_2D.cpp +++ b/src/examples/boost_multi_array_2D.cpp @@ -8,11 +8,9 @@ */ #include -#undef H5_USE_BOOST -#define H5_USE_BOOST - #include #include +#include using namespace HighFive; diff --git a/src/examples/boost_multiarray_complex.cpp b/src/examples/boost_multiarray_complex.cpp index 37481db62..34f18f551 100644 --- a/src/examples/boost_multiarray_complex.cpp +++ b/src/examples/boost_multiarray_complex.cpp @@ -9,12 +9,9 @@ #include #include -#undef H5_USE_BOOST -#define H5_USE_BOOST - #include -#include +#include typedef std::complex complex_t; diff --git a/src/examples/boost_ublas_double.cpp b/src/examples/boost_ublas_double.cpp index b025475b9..3889df680 100644 --- a/src/examples/boost_ublas_double.cpp +++ b/src/examples/boost_ublas_double.cpp @@ -8,11 +8,10 @@ */ #include -#undef H5_USE_BOOST -#define H5_USE_BOOST - #include +#include + // In some versions of Boost (starting with 1.64), you have to include the serialization header // before ublas #include diff --git a/src/examples/create_dataset_half_float.cpp b/src/examples/create_dataset_half_float.cpp index 837c58704..015776699 100644 --- a/src/examples/create_dataset_half_float.cpp +++ b/src/examples/create_dataset_half_float.cpp @@ -12,6 +12,7 @@ #include #include +#include const std::string FILE_NAME("create_dataset_half_float_example.h5"); const std::string DATASET_NAME("dset"); diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index a105e331e..18110d83f 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -46,6 +46,18 @@ option(HIGHFIVE_TEST_SINGLE_INCLUDES "Enable testing single includes" FALSE) if(HIGHFIVE_TEST_SINGLE_INCLUDES) file(GLOB public_headers LIST_DIRECTORIES false RELATIVE ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/include/highfive/*.hpp) foreach(PUBLIC_HEADER ${public_headers}) + if(PUBLIC_HEADER STREQUAL "highfive/boost.hpp" AND NOT HIGHFIVE_USE_BOOST) + continue() + endif() + + if(PUBLIC_HEADER STREQUAL "highfive/half_float.hpp" AND NOT HIGHFIVE_USE_HALF_FLOAT) + continue() + endif() + + if(PUBLIC_HEADER STREQUAL "highfive/eigen.hpp" AND NOT HIGHFIVE_USE_EIGEN) + continue() + endif() + get_filename_component(CLASS_NAME ${PUBLIC_HEADER} NAME_WE) configure_file(tests_import_public_headers.cpp "tests_${CLASS_NAME}.cpp" @ONLY) add_executable("tests_include_${CLASS_NAME}" "${CMAKE_CURRENT_BINARY_DIR}/tests_${CLASS_NAME}.cpp") diff --git a/tests/unit/data_generator.hpp b/tests/unit/data_generator.hpp index 9a6712d53..f5dc681c5 100644 --- a/tests/unit/data_generator.hpp +++ b/tests/unit/data_generator.hpp @@ -8,7 +8,7 @@ #include #ifdef H5_USE_BOOST -#include +#include #endif #include diff --git a/tests/unit/tests_high_five.hpp b/tests/unit/tests_high_five.hpp index 9d259c8d1..fa0cfd714 100644 --- a/tests/unit/tests_high_five.hpp +++ b/tests/unit/tests_high_five.hpp @@ -43,6 +43,8 @@ using base_test_types = std::tuple; #ifdef H5_USE_HALF_FLOAT +#include + using float16_t = half_float::half; using numerical_test_types = decltype(std::tuple_cat(std::declval(), std::tuple())); diff --git a/tests/unit/tests_high_five_base.cpp b/tests/unit/tests_high_five_base.cpp index f7cf67532..03e30438c 100644 --- a/tests/unit/tests_high_five_base.cpp +++ b/tests/unit/tests_high_five_base.cpp @@ -27,6 +27,15 @@ #include #include "tests_high_five.hpp" +#ifdef H5_USE_BOOST +#include +#endif + +#ifdef H5_USE_EIGEN +#include +#endif + + using namespace HighFive; using Catch::Matchers::Equals; diff --git a/tests/unit/tests_high_five_multi_dims.cpp b/tests/unit/tests_high_five_multi_dims.cpp index 08fbea9ce..31757d6c5 100644 --- a/tests/unit/tests_high_five_multi_dims.cpp +++ b/tests/unit/tests_high_five_multi_dims.cpp @@ -15,6 +15,7 @@ #ifdef H5_USE_BOOST #include +#include #endif #include From c22ac21767d13fb0d76a4bda6e1af7dab816a20b Mon Sep 17 00:00:00 2001 From: Luc Grosheintz Date: Thu, 8 Feb 2024 17:38:29 +0100 Subject: [PATCH 3/4] Remove `#include`. (#903) The comments state the at some point boost serialization and boost numeric had an ordering requirement of certain headers. It claimed: // starting Boost 1.64, serialization header must come before ublas #include #include If this is still true then users must include the affected boost headers before including `highfive/boost.hpp`. However, we're no longer forcing the dependency onto all HighFive + Boost users. --- include/highfive/boost.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/highfive/boost.hpp b/include/highfive/boost.hpp index 3dd4c9f9e..a4364faf3 100644 --- a/include/highfive/boost.hpp +++ b/include/highfive/boost.hpp @@ -4,8 +4,6 @@ #include "H5Exception.hpp" #include -// starting Boost 1.64, serialization header must come before ublas -#include #include namespace HighFive { From 4914dce759ceb78e0a87b3b0950c4276c64ce232 Mon Sep 17 00:00:00 2001 From: Luc Grosheintz Date: Fri, 9 Feb 2024 09:57:25 +0100 Subject: [PATCH 4/4] Fix typo in migration guide. (#951) --- doc/migration_guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/migration_guide.md b/doc/migration_guide.md index edd784a63..4aad2e67d 100644 --- a/doc/migration_guide.md +++ b/doc/migration_guide.md @@ -61,7 +61,7 @@ When genuinely performing a "raw read", one must replace `read` with `read_raw`. For example: ``` -double x = malloc(2*3 * sizeof(double)); +double* x = malloc(2*3 * sizeof(double)); dset.read_raw(x); ``` is correct in `v3`.