hops
H5Node_traits.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c), 2017, Adrien Devresse <adrien.devresse@epfl.ch>
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 #ifndef H5NODE_TRAITS_HPP
10 #define H5NODE_TRAITS_HPP
11 
12 #include <string>
13 
14 #include "../H5PropertyList.hpp"
15 #include "H5_definitions.hpp"
16 
17 namespace HighFive {
18 
22 template <typename Derivate>
23 class NodeTraits {
24  public:
35  DataSet
36  createDataSet(const std::string& dataset_name,
37  const DataSpace& space,
38  const DataType& type,
39  const DataSetCreateProps& createProps = DataSetCreateProps(),
40  const DataSetAccessProps& accessProps = DataSetAccessProps());
41 
51  template <typename Type>
52  DataSet
53  createDataSet(const std::string& dataset_name,
54  const DataSpace& space,
55  const DataSetCreateProps& createProps = DataSetCreateProps(),
56  const DataSetAccessProps& accessProps = DataSetAccessProps());
57 
67  template <typename T>
68  DataSet
69  createDataSet(const std::string& dataset_name,
70  const T& data,
71  const DataSetCreateProps& createProps = DataSetCreateProps(),
72  const DataSetAccessProps& accessProps = DataSetAccessProps());
73 
74 
75  template <std::size_t N>
76  DataSet
77  createDataSet(const std::string& dataset_name,
78  const FixedLenStringArray<N>& data,
79  const DataSetCreateProps& createProps = DataSetCreateProps(),
80  const DataSetAccessProps& accessProps = DataSetAccessProps());
81 
87  DataSet getDataSet(
88  const std::string& dataset_name,
89  const DataSetAccessProps& accessProps = DataSetAccessProps()) const;
90 
97  Group createGroup(const std::string& group_name, bool parents = true);
98 
103  Group getGroup(const std::string& group_name) const;
104 
108  size_t getNumberObjects() const;
109 
113  std::string getObjectName(size_t index) const;
114 
118  std::string getPath() const;
119 
126  bool rename(const std::string& src_path,
127  const std::string& dest_path,
128  bool parents = true) const;
129 
133  std::vector<std::string> listObjectNames() const;
134 
139  bool exist(const std::string& node_name) const;
140 
144  void unlink(const std::string& node_name) const;
145 
149  LinkType getLinkType(const std::string& node_name) const;
150 
154  inline ObjectType getObjectType(const std::string& node_name) const;
155 
156  private:
157  typedef Derivate derivate_type;
158 
159  // A wrapper over the low-level H5Lexist
160  // It makes behavior consistent among versions and by default transforms
161  // errors to exceptions
162  bool _exist(const std::string& node_name, bool raise_errors = true) const;
163 
164  // Opens an arbitrary object to obtain info
165  Object _open(const std::string& node_name,
166  const DataSetAccessProps& accessProps = DataSetAccessProps()) const;
167 };
168 
169 
173 enum class LinkType {
174  Hard,
175  Soft,
176  External,
177  Other // Reserved or User-defined
178 };
179 
180 
181 } // namespace HighFive
182 
183 
184 #endif // H5NODE_TRAITS_HPP
HighFive::DataSetAccessProps
PropertyList< PropertyType::DATASET_ACCESS > DataSetAccessProps
Definition: H5PropertyList.hpp:80
HighFive::NodeTraits::getLinkType
LinkType getLinkType(const std::string &node_name) const
Returns the kind of link of the given name (soft, hard...)
Definition: H5Node_traits_misc.hpp:261
HighFive::NodeTraits::getPath
std::string getPath() const
return the path to the current object
Definition: H5Node_traits_misc.hpp:154
HighFive::NodeTraits::getDataSet
DataSet getDataSet(const std::string &dataset_name, const DataSetAccessProps &accessProps=DataSetAccessProps()) const
get an existing dataset in the current file
Definition: H5Node_traits_misc.hpp:95
HighFive::LinkType::Soft
@ Soft
HighFive::LinkType::External
@ External
HighFive::LinkType::Hard
@ Hard
HighFive::DataSetCreateProps
PropertyList< PropertyType::DATASET_CREATE > DataSetCreateProps
Definition: H5PropertyList.hpp:79
HighFive::LinkType::Other
@ Other
HighFive::NodeTraits::getObjectType
ObjectType getObjectType(const std::string &node_name) const
A shorthand to get the kind of object pointed to (group, dataset, type...)
Definition: H5Node_traits_misc.hpp:273
HighFive::NodeTraits::getNumberObjects
size_t getNumberObjects() const
return the number of leaf objects of the node / group
Definition: H5Node_traits_misc.hpp:135
HighFive::ObjectType
ObjectType
Enum of the types of objects (H5O api)
Definition: H5Object.hpp:25
HighFive::NodeTraits::getObjectName
std::string getObjectName(size_t index) const
return the name of the object with the given index
Definition: H5Node_traits_misc.hpp:145
HighFive::NodeTraits::getGroup
Group getGroup(const std::string &group_name) const
open an existing group with the name group_name
Definition: H5Node_traits_misc.hpp:124
HighFive::NodeTraits::unlink
void unlink(const std::string &node_name) const
unlink the given dataset or group
Definition: H5Node_traits_misc.hpp:231
HighFive::NodeTraits::rename
bool rename(const std::string &src_path, const std::string &dest_path, bool parents=true) const
moves an object and its content within an HDF5 file.
Definition: H5Node_traits_misc.hpp:161
HighFive::NodeTraits::createGroup
Group createGroup(const std::string &group_name, bool parents=true)
create a new group, and eventually intermediate groups
Definition: H5Node_traits_misc.hpp:107
string
NAME string(REPLACE ".cpp" "_bin" example_name ${example_filename}) if($
Definition: hops/Third-party/HighFive/src/examples/CMakeLists.txt:6
HighFive::ObjectType::Group
@ Group
HighFive::NodeTraits::exist
bool exist(const std::string &node_name) const
check a dataset or group exists in the current node / group
Definition: H5Node_traits_misc.hpp:218
HighFive::NodeTraits::createDataSet
DataSet createDataSet(const std::string &dataset_name, const DataSpace &space, const DataType &type, const DataSetCreateProps &createProps=DataSetCreateProps(), const DataSetAccessProps &accessProps=DataSetAccessProps())
createDataSet Create a new dataset in the current file of datatype type and of size space
Definition: H5Node_traits_misc.hpp:36
HighFive
Definition: H5_definitions.hpp:15
H5_definitions.hpp
HighFive::LinkType
LinkType
The possible types of group entries (link concept)
Definition: H5Node_traits.hpp:173
HighFive::NodeTraits::listObjectNames
std::vector< std::string > listObjectNames() const
list all leaf objects name of the node / group
Definition: H5Node_traits_misc.hpp:178