Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-19 08:55:35

0001 /*
0002  *  Copyright (c), 2017, Adrien Devresse <adrien.devresse@epfl.ch>
0003  *
0004  *  Distributed under the Boost Software License, Version 1.0.
0005  *    (See accompanying file LICENSE_1_0.txt or copy at
0006  *          http://www.boost.org/LICENSE_1_0.txt)
0007  *
0008  */
0009 #pragma once
0010 
0011 #include <vector>
0012 
0013 #include "H5DataSpace.hpp"
0014 #include "H5DataType.hpp"
0015 #include "H5Object.hpp"
0016 #include "bits/H5_definitions.hpp"
0017 #include "bits/H5Annotate_traits.hpp"
0018 #include "bits/H5Slice_traits.hpp"
0019 #include "bits/H5Path_traits.hpp"
0020 #include "bits/H5_definitions.hpp"
0021 
0022 namespace HighFive {
0023 
0024 ///
0025 /// \brief Class representing a dataset.
0026 ///
0027 class DataSet: public Object,
0028                public SliceTraits<DataSet>,
0029                public AnnotateTraits<DataSet>,
0030                public PathTraits<DataSet> {
0031   public:
0032     const static ObjectType type = ObjectType::Dataset;
0033 
0034     ///
0035     /// \brief getStorageSize
0036     /// \return returns the amount of storage allocated for a dataset.
0037     ///
0038     uint64_t getStorageSize() const;
0039 
0040     ///
0041     /// \brief getOffset
0042     /// \return returns DataSet address in file
0043     ///
0044     uint64_t getOffset() const;
0045 
0046     ///
0047     /// \brief getDataType
0048     /// \return return the datatype associated with this dataset
0049     ///
0050     DataType getDataType() const;
0051 
0052     ///
0053     /// \brief getSpace
0054     /// \return return the dataspace associated with this dataset
0055     ///
0056     DataSpace getSpace() const;
0057 
0058     ///
0059     /// \brief getMemSpace
0060     /// \return same than getSpace for DataSet, compatibility with Selection
0061     /// class
0062     ///
0063     DataSpace getMemSpace() const;
0064 
0065 
0066     /// \brief Change the size of the dataset
0067     ///
0068     /// This requires that the dataset was created with chunking, and you would
0069     /// generally want to have set a larger maxdims setting
0070     /// \param dims New size of the dataset
0071     void resize(const std::vector<size_t>& dims);
0072 
0073 
0074     /// \brief Get the dimensions of the whole DataSet.
0075     ///       This is a shorthand for getSpace().getDimensions()
0076     /// \return The shape of the current HighFive::DataSet
0077     ///
0078     inline std::vector<size_t> getDimensions() const {
0079         return getSpace().getDimensions();
0080     }
0081 
0082     /// \brief Get the total number of elements in the current dataset.
0083     ///       E.g. 2x2x2 matrix has size 8.
0084     ///       This is a shorthand for getSpace().getTotalCount()
0085     /// \return The shape of the current HighFive::DataSet
0086     ///
0087     inline size_t getElementCount() const {
0088         return getSpace().getElementCount();
0089     }
0090 
0091     /// \brief Get the list of properties for creation of this dataset
0092     DataSetCreateProps getCreatePropertyList() const {
0093         return details::get_plist<DataSetCreateProps>(*this, H5Dget_create_plist);
0094     }
0095 
0096     /// \brief Get the list of properties for accession of this dataset
0097     DataSetAccessProps getAccessPropertyList() const {
0098         return details::get_plist<DataSetAccessProps>(*this, H5Dget_access_plist);
0099     }
0100 
0101     /// \deprecated Default constructor creates unsafe uninitialized objects
0102     H5_DEPRECATED("Default constructor creates unsafe uninitialized objects")
0103     DataSet() = default;
0104 
0105   protected:
0106     using Object::Object;  // bring DataSet(hid_t)
0107 
0108     DataSet(Object&& o) noexcept
0109         : Object(std::move(o)) {}
0110 
0111     friend class Reference;
0112     template <typename Derivate>
0113     friend class NodeTraits;
0114 };
0115 
0116 }  // namespace HighFive