HighFive 2.10.0
HighFive - Header-only C++ HDF5 interface
Loading...
Searching...
No Matches
H5Path_traits_misc.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c), 2020, EPFL - Blue Brain Project
3 *
4 * Distributed under the Boost Software License, Version 1.0.
5 * (See accompanying file LICENSE_1_0.txt or copy at
6 * http://www.boost.org/LICENSE_1_0.txt)
7 *
8 */
9#pragma once
10
11#include <H5Ipublic.h>
12
13#include "H5Utils.hpp"
14#include "H5Path_traits.hpp"
15
16namespace HighFive {
17
18template <typename Derivate>
20 static_assert(std::is_same<Derivate, Group>::value || std::is_same<Derivate, DataSet>::value ||
21 std::is_same<Derivate, Attribute>::value,
22 "PathTraits can only be applied to Group, DataSet and Attribute");
23 const auto& obj = static_cast<const Derivate&>(*this);
24 if (obj.isValid()) {
25 const hid_t file_id = detail::h5i_get_file_id<PropertyException>(obj.getId());
26 _file_obj.reset(new File(file_id));
27 }
29
30template <typename Derivate>
31inline std::string PathTraits<Derivate>::getPath() const {
32 return details::get_name([this](char* buffer, size_t length) {
33 return detail::h5i_get_name(static_cast<const Derivate&>(*this).getId(), buffer, length);
34 });
35}
36
37template <typename Derivate>
38inline File& PathTraits<Derivate>::getFile() const noexcept {
39 return *_file_obj;
40}
41
42} // namespace HighFive
File class.
Definition H5File.hpp:24
PathTraits()
Definition H5Path_traits_misc.hpp:19
File & getFile() const noexcept
Return a reference to the File object this object belongs.
Definition H5Path_traits_misc.hpp:38
std::string getPath() const
return the path to the current object
Definition H5Path_traits_misc.hpp:31
Definition H5_definitions.hpp:22