Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .github/workflows/cmake-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -249,5 +249,15 @@ jobs:
cmake --build . -- -j 2
- name: run tests
run: |
cd build
ctest --extra-verbose --no-tests=error
working-directory: build
- name: install with cmake
run: |
cmake --build . --target install
working-directory: build
- name: build examples
run: |
mkdir examples_build
cd examples_build
cmake ../examples -DCMAKE_BUILD_TYPE=Release
cmake --build . -- -j 2
15 changes: 13 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ if (NOT H5CPP_BUILD_SHARED)
set(BUILD_SHARED_LIBS OFF)
endif()
option(H5CPP_LOCAL_MODULES "Build h5cpp using cmake local modules first")
option(H5CPP_BUILD_EXAMPLES "Include the examples in the project" OFF)

#=============================================================================
# Conan
Expand Down Expand Up @@ -117,6 +118,9 @@ option(H5CPP_BUILD_DOCS "Build documentation" ON)
if(H5CPP_BUILD_DOCS)
add_subdirectory(doc)
endif()
if (H5CPP_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()

#=============================================================================
# install the examples directory to the documentation directory
Expand Down Expand Up @@ -158,13 +162,20 @@ install(FILES ${PROJECT_BINARY_DIR}/${PACKAGE_VERSION_FILE_NAME}
COMPONENT development)

#
# create and install the package file
# create and install the package file and cmake modules
#
configure_file("${PACKAGE_CONFIG_FILE_NAME}.in" ${PACKAGE_CONFIG_FILE_NAME} @ONLY)
install(FILES ${PROJECT_BINARY_DIR}/${PACKAGE_CONFIG_FILE_NAME}
install(FILES
${PROJECT_BINARY_DIR}/${PACKAGE_CONFIG_FILE_NAME}
cmake/FindSZIP.cmake
DESTINATION ${CMAKE_INSTALL_PACKAGEDIR}
COMPONENT development)

install(FILES
cmake/FindHDF5.cmake
DESTINATION ${CMAKE_INSTALL_PACKAGEDIR}/hdf5
COMPONENT development)

#
# uninstall target
#
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# C++ wrapper for the HDF5 C-library

[![docs](https://img.shields.io/badge/Documentation-webpages-ADD8E6.svg)](https://ess-dmsc.github.io/h5cpp/index.html) [![DOI](https://zenodo.org/badge/99373936.svg)](https://zenodo.org/badge/latestdoi/99373936) [![Join the chat at https://gitter.im/h5cpp/community](https://badges.gitter.im/h5cpp/community.svg)](https://gitter.im/h5cpp/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
![github workflow](https://github.com/ess-dmsc/h5cpp/actions/workflows/cmake-build.yml/badge.svg) [![docs](https://img.shields.io/badge/Documentation-webpages-ADD8E6.svg)](https://ess-dmsc.github.io/h5cpp/index.html) [![DOI](https://zenodo.org/badge/99373936.svg)](https://zenodo.org/badge/latestdoi/99373936) [![Join the chat at https://gitter.im/h5cpp/community](https://badges.gitter.im/h5cpp/community.svg)](https://gitter.im/h5cpp/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)


*h5cpp* is a new C++ wrapper for HDF5s C-API.
Expand Down
13 changes: 10 additions & 3 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
cmake_minimum_required(VERSION 3.0.0)
project(h5cpp-examples LANGUAGES CXX C)
set(CMAKE_CXX_STANDARD 11)

find_package(h5cpp REQUIRED)
get_directory_property(IS_TOP_LEVEL PARENT_DIRECTORY)
if (NOT IS_TOP_LEVEL)
find_package(h5cpp REQUIRED)
endif()

if (NOT H5CPP_BOOST_ENABLED)
set(CMAKE_CXX_STANDARD 17)
else()
set(CMAKE_CXX_STANDARD 11)
endif()

add_executable(basic_files basic_files.cpp)
target_link_libraries(basic_files PRIVATE h5cpp::h5cpp)
Expand Down Expand Up @@ -60,4 +68,3 @@ endif ()
if (H5CPP_MPI_ENABLED)
add_subdirectory(mpi)
endif ()

26 changes: 14 additions & 12 deletions examples/append_scalar_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,23 @@

using namespace hdf5;

node::Dataset create_dataset(const node::Group parent_group)
{
property::LinkCreationList lcpl;
property::DatasetCreationList dcpl;
namespace {
node::Dataset create_dataset(const node::Group & parent_group)
{
property::LinkCreationList lcpl;
property::DatasetCreationList dcpl;

// in order to append data we have to use a chunked layout of the dataset
dcpl.layout(property::DatasetLayout::Chunked);
dcpl.chunk(Dimensions{1024});
// in order to append data we have to use a chunked layout of the dataset
dcpl.layout(property::DatasetLayout::Chunked);
dcpl.chunk(Dimensions{1024});

// create dataspace (infinitely extensible) and datatype
dataspace::Simple space({0},{dataspace::Simple::unlimited});
auto type = datatype::create<int>();
// create dataspace (infinitely extensible) and datatype
dataspace::Simple space({0},{dataspace::Simple::unlimited});
auto type = datatype::create<int>();

// finally create the dataset
return node::Dataset(parent_group,"data",type,space,lcpl,dcpl);
// finally create the dataset
return node::Dataset(parent_group,"data",type,space,lcpl,dcpl);
}
}

int main()
Expand Down
35 changes: 18 additions & 17 deletions examples/append_vector_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,28 @@ using namespace hdf5;
using Bins = std::vector<int>;
static const int nbins = 6;

node::Dataset create_dataset(const node::Group parent_group,const Bins bins)
{
property::LinkCreationList lcpl;
property::DatasetCreationList dcpl;
dcpl.layout(property::DatasetLayout::Chunked);
dcpl.chunk({100,bins.size()});
namespace {
node::Dataset create_dataset(const node::Group & parent_group,const Bins & bins)
{
property::LinkCreationList lcpl;
property::DatasetCreationList dcpl;
dcpl.layout(property::DatasetLayout::Chunked);
dcpl.chunk({100,bins.size()});

dataspace::Simple space{{0,bins.size()},{dataspace::Simple::unlimited,nbins}};
auto type = datatype::create(bins);
dataspace::Simple space{{0,bins.size()},{dataspace::Simple::unlimited,nbins}};
auto type = datatype::create(bins);

return node::Dataset(parent_group,"data",type,space,lcpl,dcpl);
}
return node::Dataset(parent_group,"data",type,space,lcpl,dcpl);
}

void print_data(const std::string &prefix,const Bins &bins)
{
std::cout<<prefix;
std::for_each(bins.begin(),bins.end(),
[](int value) { std::cout<<value<<" "; });
std::cout<<std::endl;
void print_data(const std::string &prefix,const Bins &bins)
{
std::cout<<prefix;
std::for_each(bins.begin(),bins.end(),
[](int value) { std::cout<<value<<" "; });
std::cout<<std::endl;
}
}

int main()
{
file::File f = file::create("append_vector_data.h5",
Expand Down
2 changes: 2 additions & 0 deletions examples/complex_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
// Created on: Oct 07, 2017
//
#include <h5cpp/hdf5.hpp>
#include <h5cpp/contrib/stl/stl.hpp>

#include <iostream>
#include <complex>

Expand Down
3 changes: 2 additions & 1 deletion examples/image_h5.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ class TypeTrait<Image<PixelT>>
hdf5::Dimensions{value.ny(),value.nx()});
}

const static DataspaceType & get(const Image<PixelT> &value)
const static DataspaceType & get(const Image<PixelT> &value, DataspacePool &)
{
const static DataspaceType & cref_ = Simple(hdf5::Dimensions{value.ny(),value.nx()},
hdf5::Dimensions{value.ny(),value.nx()});
return cref_;
}

static void *ptr(Image<PixelT> &value)
Expand Down
4 changes: 2 additions & 2 deletions examples/mpi/writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ int main(int argc,char **argv)

node::Dataset dataset = root_group.create_dataset("mpi_ids",
datatype::create<int>(),
dataspace::Simple{{total_procs}});
dataspace::Hyperslab slab{{my_id},{1},{1},{1}};
dataspace::Simple{{static_cast<hsize_t>(total_procs)}});
dataspace::Hyperslab slab{{static_cast<hsize_t>(my_id)},{1},{1},{1}};
dataset.write(my_id,slab);
}

Expand Down
2 changes: 1 addition & 1 deletion examples/mpi/writer_extend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ node::Dataset create_dataset(const node::Group &base)
dcpl.layout(property::DatasetLayout::Chunked);
dcpl.chunk({1024*1024});

return base.create_dataset("extended_data",file_type,file_space,lcpl,dcpl);
return base.create_dataset("extended_data",file_type,file_space,dcpl,lcpl);
}

int main(int argc,char **argv)
Expand Down
2 changes: 1 addition & 1 deletion examples/std_vector_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ int main()
//
// retrieving the data back from disk
//
DataType read_data(dataset.dataspace().size()); //allocate enough memory
DataType read_data(static_cast<size_t>(dataset.dataspace().size())); //allocate enough memory
dataset.read(read_data);

//
Expand Down
36 changes: 12 additions & 24 deletions h5cpp-config.cmake.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
include(CMakeFindDependencyMacro)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
if(CMAKE_VERSION VERSION_LESS 3.19)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/hdf5")
endif()

#
# add some additional information via cached variables
#
Expand All @@ -20,47 +27,28 @@ if(H5CPP_BOOST_ENABLED)
if(NOT TARGET Boost::system)
list(APPEND BOOST_COMPONENTS system)
endif()

find_package(Boost @Boost_MAJOR_VERSION@.@Boost_MINOR_VERSION@.@Boost_SUBMINOR_VERSION@ EXACT REQUIRED COMPONENTS ${BOOST_COMPONENTS})
find_dependency(Boost ${BOOST_VERSION} ${BOOST_EXACT} COMPONENTS ${BOOST_COMPONENTS})
if(NOT Boost_FOUND)
message(FATAL_ERROR "Could not find Boost filesystem library - cannot load h5cpp targets")
endif()

link_directories(${Boost_LIBRARY_DIRS})
endif()

find_dependency(Threads)
find_package(SZIP) # optional dependency so use find_package
find_dependency(ZLIB)

#
# checking for hdf5
#
set(HDF5_PREFER_PARALLEL @H5CPP_WITH_MPI@)
find_package(HDF5 @HDF5_VERSION@ EXACT REQUIRED COMPONENTS C)

#
# as the libraries are attached to the imported target we have to add the
# directory where to find them according to the previous find_package call
#
foreach(HDF5_LIB ${HDF5_LIBRARIES})
get_filename_component(LIB_PATH ${HDF5_LIB} DIRECTORY)
link_directories(${LIB_PATH})
endforeach()

foreach(HDF5_LIB ${HDF5_HL_LIBRARIES})
get_filename_component(LIB_PATH ${HDF5_LIB} DIRECTORY)
link_directories(${LIB_PATH})
endforeach()
find_dependency(HDF5 @HDF5_VERSION@ EXACT COMPONENTS C HL)

if(H5CPP_MPI_ENABLED AND (NOT HDF5_IS_PARALLEL))
message(FATAL_ERROR "HDF5 library with MPI support required!")
endif()


#
# load targets
#
include(${CMAKE_CURRENT_LIST_DIR}/h5cpp_targets.cmake)

#
# add the include directories for the HDF5 library
#
include_directories(${HDF5_INCLUDE_DIRS})
2 changes: 1 addition & 1 deletion src/h5cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ endif()
target_link_libraries(h5cpp
PUBLIC
${H5CPP_LINKS}
hdf5::hdf5
PRIVATE ${COVERAGE_LIBRARIES}
hdf5::hdf5_hl
hdf5::hdf5
Threads::Threads
${H5CPP_FILTER_TARGETS}
${CMAKE_DL_LIBS}
Expand Down
7 changes: 0 additions & 7 deletions src/h5cpp/attribute/attribute.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,6 @@ class DLL_EXPORT Attribute
//!
Attribute() = default;

//!
//! \brief copy assignment operator
//!
//! Uses default compiler implementation.
//!
Attribute(const Attribute &) = default;

//!
//! \brief return the data type of the attribute
//!
Expand Down
9 changes: 0 additions & 9 deletions src/h5cpp/core/object_id.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,6 @@ class DLL_EXPORT ObjectId
//!
ObjectId(const ObjectHandle &handle);

//!
//! \brief copy constructor
//!
//! We need this for compliance with STL containers. As all memebers of
//! this class support copy construction and assignment we can safely use
//! the default implementation, provided by the compiler, here.
//!
ObjectId(const ObjectId &id) = default;

//!
//! \brief Equality operator for IDs
//!
Expand Down
5 changes: 0 additions & 5 deletions src/h5cpp/core/path.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@ class DLL_EXPORT Path
//!
Path(const_iterator first_element, const_iterator last_element);

//!
//! \brief copy constructor
//!
Path(const Path &p) = default;

explicit operator std::string() const
{
return to_string();
Expand Down
8 changes: 0 additions & 8 deletions src/h5cpp/core/version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,6 @@ class DLL_EXPORT Version
//!
Version(NumberType major_number, NumberType minor_number, NumberType patch) noexcept;

//!
//! @brief copy constructor
//!
//! We can use the compiler provided default implementation here as all
//! members are trivially copyable.
//!
Version(const Version &) = default;

//!
//! @brief return the major version number
//!
Expand Down
7 changes: 0 additions & 7 deletions src/h5cpp/dataspace/simple.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,6 @@ class DLL_EXPORT Simple : public Dataspace {
//!
Simple(const Dataspace &space);

//!
//! \brief copy constructor
//!
//! Use default implementation of the copy constructor
//!
Simple(const Simple &) = default;

//!
//! \brief constructor
//!
Expand Down
4 changes: 2 additions & 2 deletions src/h5cpp/file/mpi_driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class DLL_EXPORT MPIDriver : public Driver
MPIDriver(MPI_Comm comm,MPI_Info info);
MPIDriver(const MPIDriver &) = default;

virtual void operator()(const property::FileAccessList &fapl) const;
virtual DriverID id() const noexcept;
virtual void operator()(const property::FileAccessList &fapl) const override;
virtual DriverID id() const noexcept override;
private:

MPI_Comm comm_;
Expand Down
7 changes: 0 additions & 7 deletions src/h5cpp/node/dataset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,6 @@ class DLL_EXPORT Dataset : public Node
//!
Dataset() = default;

//!
//! \brief copy constructor
//!
//! Use default implementation here.
//!
Dataset(const Dataset &) = default;

//!
//! \brief construct
//!
Expand Down
Loading