Back to home page

EIC code displayed by LXR

 
 

    


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

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 <H5Gpublic.h>
0012 
0013 #include "H5Object.hpp"
0014 #include "bits/H5Friends.hpp"
0015 #include "bits/H5_definitions.hpp"
0016 #include "bits/H5Annotate_traits.hpp"
0017 #include "bits/H5Node_traits.hpp"
0018 #include "bits/H5Path_traits.hpp"
0019 
0020 namespace HighFive {
0021 
0022 namespace detail {
0023 /// \brief Internal hack to create an `Group` from an ID.
0024 ///
0025 /// WARNING: Creating an Group from an ID has implications w.r.t. the lifetime of the object
0026 ///          that got passed via its ID. Using this method careless opens up the suite of issues
0027 ///          related to C-style resource management, including the analog of double free, dangling
0028 ///          pointers, etc.
0029 ///
0030 /// NOTE: This is not part of the API and only serves to work around a compiler issue in GCC which
0031 ///       prevents us from using `friend`s instead. This function should only be used for internal
0032 ///       purposes. The problematic construct is:
0033 ///
0034 ///           template<class Derived>
0035 ///           friend class SomeCRTP<Derived>;
0036 ///
0037 /// \private
0038 Group make_group(hid_t);
0039 }  // namespace detail
0040 
0041 ///
0042 /// \brief Represents an hdf5 group
0043 class Group: public Object,
0044              public NodeTraits<Group>,
0045              public AnnotateTraits<Group>,
0046              public PathTraits<Group> {
0047   public:
0048     const static ObjectType type = ObjectType::Group;
0049 
0050     /// \deprecated Default constructor creates unsafe uninitialized objects
0051     H5_DEPRECATED("Default constructor creates unsafe uninitialized objects")
0052     Group() = default;
0053 
0054     std::pair<unsigned int, unsigned int> getEstimatedLinkInfo() const;
0055 
0056     /// \brief Get the list of properties for creation of this group
0057     GroupCreateProps getCreatePropertyList() const {
0058         return details::get_plist<GroupCreateProps>(*this, H5Gget_create_plist);
0059     }
0060 
0061     Group(Object&& o) noexcept
0062         : Object(std::move(o)){};
0063 
0064   protected:
0065     using Object::Object;
0066 
0067     friend Group detail::make_group(hid_t);
0068     friend class File;
0069     friend class Reference;
0070 #if HIGHFIVE_HAS_FRIEND_DECLARATIONS
0071     template <typename Derivate>
0072     friend class ::HighFive::NodeTraits;
0073 #endif
0074 };
0075 
0076 inline std::pair<unsigned int, unsigned int> Group::getEstimatedLinkInfo() const {
0077     auto gcpl = getCreatePropertyList();
0078     auto eli = EstimatedLinkInfo(gcpl);
0079     return std::make_pair(eli.getEntries(), eli.getNameLength());
0080 }
0081 
0082 namespace detail {
0083 inline Group make_group(hid_t hid) {
0084     return Group(hid);
0085 }
0086 }  // namespace detail
0087 
0088 }  // namespace HighFive