Git Product home page Git Product logo

h5cpp's Introduction

A modern C++ interface for HDF5

Build Status github workflow docs Conan package DOI Join the chat at https://gitter.im/h5cpp/community

h5cpp is a modern C++ wrapper for HDF5's C-API.

Motivation

HDF5 is a powerful binary format. There is virtually nothing that cannot be stored in an HDF5 file. You can either use the C-API or one of the wrappers for a scripting language (for Python there is for instance h5py or pytables). To keep their interfaces simple, many of these wrappers do not provide the full functionality HDF5 has to offer. If you want to use all features available, you must use the C-API, which is, however, quite unwieldy and not conducive to modern C++ idioms.

h5cpp provides a domain-agnostic and easy-to-use modern C++ interface to the full functionality of HDF5.

We currently support:

  • Linux
  • Windows
  • macOS

Although this and Steven Varga's h5cpp project share the same name they are entirely unrelated.

How to use h5cpp

You may bring in h5cpp as a conan package or build and install the library manually as described below.

In either case, you can bring it into your program by adding something like this in your CMakeLists.txt file:

find_package(h5cpp REQUIRED)
.
.
.
add_executable(some_target some_code.cpp)
target_link_libraries(some_target h5cpp::h5cpp)

and adding the following:

#include <h5cpp/hdf5.hpp>

to your your source file. Here is a small example of how to make use of the library in code:

using namespace hdf5;

// create a file
file::File f = file::create("writing_vector.h5",file::AccessFlags::Truncate);

// create a group
node::Group root_group = f.root();
node::Group my_group = root_group.create_group("my_group");

// create a dataset
using data_type = std::vector<int>;
data_type data{1,2,3,4};
node::Dataset dataset = my_group.create_dataset("data",
                                                datatype::create<data_type>(),
                                                dataspace::create(data));

// write to dataset
dataset.write(data);

For more, please see the full API documentation.

How to build h5cpp

The minimum requirements for building the library are:

  • a C++ compiler, gcc>=4.9 should do well
  • the HDF5 C library (>=1.8.13 would do but >=1.10.0 is prefered)
  • cmake >= 3.10
  • either the boost libraries or a compiler with std::filesystem or std::experimental::filesystem (and specify H5CPP_WITH_BOOST=OFF to CMake)
  • sphinx, breathe (with python) and doxygen for the documentation build
  • catch2 to build the unit tests

The external library dependencies can be acquired and built using Conan. Conan can be installed with PyPI:

pip install conan

and that's it, CMake will handle the rest!

Alternatively you can manually install the dependencies to typical system locations. In this case please disable Conan by using the -DH5CPP_CONAN=DISABLE option when you run CMake.

Building the library is standard cmake & make fare, out of source. For example, in linux shell, you would do the following:

git clone https://github.com/ess-dmsc/h5cpp.git
cd h5cpp
mkdir build
cd build
cmake ..
make

In any case you should run the tests after the build.

$ make test

To install the library to system, you would follow this up with:

sudo make install

Alternate install directory

If you do not wish to install h5cpp to your system folders you can slightly modify the above steps. When building the library, invoke CMake with the following option:

cmake -DCMAKE_INSTALL_PREFIX=/home/user1/some/path ..

and accordingly, when building the client program:

cmake -Dh5cpp_DIR=/home/user1/some/path/lib/cmake/h5cpp-0.6.0 path/to/your/source

where version number may vary.

For OSX and Windows instructions, as well as instructions for building tests and documentation, see the online documentation.

h5cpp's People

Contributors

amues avatar dominikwerder avatar elggem avatar eugenwintersberger avatar florianben avatar garethcmurphy avatar gitter-badger avatar jkotan avatar martukas avatar mattclarke avatar matthew-d-jones avatar planetmarshall avatar rerpha avatar sekoenig avatar shivupa avatar skytoground avatar v1tzl1 avatar yuelongyu avatar zjttoefs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

h5cpp's Issues

Debian issue with GTest

There is an issue with GTest on Debian. Debian ships google tests for 8 as well as for 9 as a source distribution. It would be possible to use a conan package for the build but this would complicate things for
Debian package maintainers as conan is not available in the current Debian distributions.

The source distribution shipped with Debian could be built from within cmake using the ExternalProject module.

Migrate to google test

I have already begun this in the gtest branch.
./test/CMakeLists.txt has a short section of the find-replace steps that are needed to easily convert from boost unit test. Fixtures may require additional work.
Most tests and add_subdirectory statements are commented out pending conversion to gtest.

Warnings in dataset_creation_list.cpp

Quite a few along the lines of:

/home/bdv/dev/h5cpp/src/property/dataset_creation_list.cpp: In function β€˜std::ostream& hdf5::property::operator<<(std::ostream&, const hdf5::property::DatasetFillValueStatus&)’: /home/bdv/dev/h5cpp/src/property/dataset_creation_list.cpp:44:1: warning: control reaches end of non-void function [-Wreturn-type] } ^

This is after after switch statements for stream output of enums. Should theoretically never happen, but who knows. What's the right way to deal with this? Return stream unaltered or insert some sort of FU? :)

Implicit constructor for Path?

Syntax such as copy(gt, g2, Path("gt")) feels superfluous.
Perhaps Path could be constructed from std::string implicitly?
We may keep it this way for now while we are testing and developing, but relax this later. Any arguments for or against?

Modify nodes when they are moved or removed

Use global context to do the following:

  1. find all open instances of a node referenced by the path we want to move (look for ID)
  2. within this set we have to find all instances which have used the very path we want to move
    to access the node
  3. we have to change all the paths for these nodes to the new path once the move was successful.

Intuitive way to get node's relative path?

Right now, if you want to get the Node's parent, you can do this:
source.link().parent(), which give you a Group object, which is not bad

If you want it's path relative to the parent, you have to do this:
Path(object.link().path().back()) which is a bit crazy

Maybe there should be some more convenient functions for this? Or maybe we only need these internally and the user will never need them?

What comes to mind as a good example is something like boost::filesystem::path::stem() which gives you just the filename without the rest of the path. But maybe there is some deeper question here, or need of some general functions to resolve relative paths?

Cobertura reporting not working

This is referring to the gtest branch.

Taking example from Morten's EFU setup and my adaptation of it for daquiri, I have factored out code relevant to providing gcc test coverage and placed it all in here:

./cmake/TestCoverage.cmake

The functions are called in ./test/CMakeLists.txt
Everything is generated when I run it on my system, but on the Jenkins node it fails to produce browsable coverage reports. Last we looked with Afonso, it seemed that the coverage xml file was empty for whatever reason. The code is virtually identical to what I have for daquiri and they both run on the Fedora node, so I am quite puzzled as to why this is not coming out right.

Refactor coverage compile options

I thought to file this as an enhancement, but it looks like the way it's set up now, it actually prevents it from compiling on OSX. So everything to do with coverage should be a CMake option.

Implementation of hdf5::node::copy functions

See function prototypes in

src/include/h5cpp/node/functions.hpp

Tasks

  • clarify the behavior of theses functions. We must distinguish between copying links and objects.
  • complete the documentation
  • implement the functionality
  • write tests

Implementation of == and != operator for hdf5::node::Node

As we have now a working ID implementation we could use this to implement the operators

bool operator==(const hdf5::node::Node &lhs,const hdf5::node::Node &rhs);
bool operator!=(const hdf5::node::Node &lhs,const hdf5::node::Node &rhs);

The implementation should be straight forward using the id() member method.

Implementation of hdf5::node::move functions

The prototypes of theses functions are defined in

src/include/h5cpp/node/functions.hpp

This includes the following tasks

  • reason about the declared prototypes
  • add convenience functions if required
  • write tests for the functions

NodeView::exists does not work correctly

Came across this while developing tests for node copy functions. I will attempt to develop a test suite for NodeView. Hopefully I can track down the problem myself. Else, you may have some insight.

Implement basic attribute interface

This includes implementation of the following classes

  • hdf5::attribute::Attribute
  • hdf5::attribute::AttributeManager
  • hdf5::attribute::AttributeIterator

More tests for node operations

Need more extensive tests for global node functions, such as node::copy to ensure all features of C API work correctly, i.e. copying must work across files.
Does it make sense that we test all permutations of property list settings, or is that redundant and we simply trust the underlying H5 functionality?

Modify copy constructors for utility types

We other copy constructors and assignment on the following types

  • datatyeps
  • dataspaces
  • and property lists

These classes have a slightly different copy semantics than node objects.

Paths in "#include"-statements in headers

The header files in src/include/h5cpp/ include other headers either by relative path or by assuming that include/h5cpp/ is an include directory. This should probably changed such that paths are always absolute and that the root include path is include and not include/h5cpp. This is the method used by Boost and many other libraries as it prevents unintentionally including the wrong header file.

Please comment, I can make the relevant changes.

Implement string IO

String need some special treatment in HDF5. Deal with this in this special issue.

Iterator tests

Base iterator class is missing tests for most functions, also has warnings.

Remove Eclipse files from the repository

I definitely have to remove my eclipse files from the repository. They mess up the pull requestes and are only of importance to me. Thus I definitely should find a better way to distribute my Eclipse configurations.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.