CMS 3D CMS Logo

h5_File.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: CondCore/CondHDF5ESSource
4 // Class : File
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author: Christopher Jones
10 // Created: Fri, 30 Jun 2023 15:26:16 GMT
11 //
12 
13 // system include files
14 
15 // user include files
16 #include "h5_File.h"
17 #include "h5_Group.h"
18 #include "h5_DataSet.h"
19 #include "h5_Attribute.h"
21 
22 namespace cms::h5 {
23  //
24  // constants, enums and typedefs
25  //
26 
27  //
28  // static data member definitions
29  //
30 
31  //
32  // constructors and destructor
33  //
34  File::File(std::string const& iName, CtrOption) : id_(H5Fopen(iName.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT)) {
35  if (id_ < 0) {
36  throw cms::Exception("FailedHDF5FileOpen") << "failed to open HDF5 file " << iName;
37  }
38  }
39 
40  // File::File(const File& rhs)
41  // {
42  // // do actual copying here;
43  // }
44 
45  File::~File() { H5Fclose(id_); }
46 
47  //
48  // assignment operators
49  //
50  // const File& File::operator=(const File& rhs)
51  // {
52  // //An exception safe implementation is
53  // File temp(rhs);
54  // swap(rhs);
55  //
56  // return *this;
57  // }
58 
59  //
60  // member functions
61  //
62 
63  //
64  // const member functions
65  //
66  std::shared_ptr<Group> File::findGroup(std::string const& iName) const { return std::make_shared<Group>(id_, iName); }
67  std::shared_ptr<DataSet> File::findDataSet(std::string const& iName) const {
68  return std::make_shared<DataSet>(id_, iName);
69  }
70 
71  std::shared_ptr<Attribute> File::findAttribute(std::string const& iName) const {
72  return std::make_shared<Attribute>(id_, iName);
73  }
74 
75  std::shared_ptr<Group> File::derefGroup(hobj_ref_t iRef) const { return std::make_shared<Group>(id_, &iRef); }
76 
77  std::shared_ptr<DataSet> File::derefDataSet(hobj_ref_t iRef) const { return std::make_shared<DataSet>(id_, &iRef); }
78 
79  //
80  // static member functions
81  //
82 } // namespace cms::h5
std::shared_ptr< Group > derefGroup(hobj_ref_t iRef) const
Definition: h5_File.cc:75
std::shared_ptr< Group > findGroup(std::string const &iName) const
Definition: h5_File.cc:66
std::shared_ptr< Attribute > findAttribute(std::string const &iName) const
Definition: h5_File.cc:71
std::shared_ptr< DataSet > findDataSet(std::string const &iName) const
Definition: h5_File.cc:67
hid_t id_
Definition: h5_File.h:62
File(std::string const &iName, CtrOption)
Definition: h5_File.cc:34
std::shared_ptr< DataSet > derefDataSet(hobj_ref_t iRef) const
Definition: h5_File.cc:77