Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-22 08:54:39

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     Group() = default;
0051 
0052     std::pair<unsigned int, unsigned int> getEstimatedLinkInfo() const;
0053 
0054     /// \brief Get the list of properties for creation of this group
0055     GroupCreateProps getCreatePropertyList() const {
0056         return details::get_plist<GroupCreateProps>(*this, H5Gget_create_plist);
0057     }
0058 
0059     explicit Group(Object&& o) noexcept
0060         : Object(std::move(o)) {};
0061 
0062   protected:
0063     using Object::Object;
0064 
0065     friend Group detail::make_group(hid_t);
0066     friend class File;
0067     friend class Reference;
0068 #if HIGHFIVE_HAS_FRIEND_DECLARATIONS
0069     template <typename Derivate>
0070     friend class ::HighFive::NodeTraits;
0071 #endif
0072 };
0073 
0074 inline std::pair<unsigned int, unsigned int> Group::getEstimatedLinkInfo() const {
0075     auto gcpl = getCreatePropertyList();
0076     auto eli = EstimatedLinkInfo(gcpl);
0077     return std::make_pair(eli.getEntries(), eli.getNameLength());
0078 }
0079 
0080 namespace detail {
0081 inline Group make_group(hid_t hid) {
0082     return Group(hid);
0083 }
0084 }  // namespace detail
0085 
0086 }  // namespace HighFive