Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:36:26

0001 // -*- C++ -*-
0002 //
0003 // Package:     CondCore/CondHDF5ESSource
0004 // Class  :     File
0005 //
0006 // Implementation:
0007 //     [Notes on implementation]
0008 //
0009 // Original Author:  Christopher Jones
0010 //         Created:  Fri, 30 Jun 2023 15:26:16 GMT
0011 //
0012 
0013 // system include files
0014 
0015 // user include files
0016 #include "h5_File.h"
0017 #include "h5_Group.h"
0018 #include "h5_DataSet.h"
0019 #include "h5_Attribute.h"
0020 #include "FWCore/Utilities/interface/Exception.h"
0021 
0022 namespace cms::h5 {
0023   //
0024   // constants, enums and typedefs
0025   //
0026 
0027   //
0028   // static data member definitions
0029   //
0030 
0031   //
0032   // constructors and destructor
0033   //
0034   File::File(std::string const& iName, CtrOption) : id_(H5Fopen(iName.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT)) {
0035     if (id_ < 0) {
0036       throw cms::Exception("FailedHDF5FileOpen") << "failed to open HDF5 file " << iName;
0037     }
0038   }
0039 
0040   // File::File(const File& rhs)
0041   // {
0042   //    // do actual copying here;
0043   // }
0044 
0045   File::~File() { H5Fclose(id_); }
0046 
0047   //
0048   // assignment operators
0049   //
0050   // const File& File::operator=(const File& rhs)
0051   // {
0052   //   //An exception safe implementation is
0053   //   File temp(rhs);
0054   //   swap(rhs);
0055   //
0056   //   return *this;
0057   // }
0058 
0059   //
0060   // member functions
0061   //
0062 
0063   //
0064   // const member functions
0065   //
0066   std::shared_ptr<Group> File::findGroup(std::string const& iName) const { return std::make_shared<Group>(id_, iName); }
0067   std::shared_ptr<DataSet> File::findDataSet(std::string const& iName) const {
0068     return std::make_shared<DataSet>(id_, iName);
0069   }
0070 
0071   std::shared_ptr<Attribute> File::findAttribute(std::string const& iName) const {
0072     return std::make_shared<Attribute>(id_, iName);
0073   }
0074 
0075   std::shared_ptr<Group> File::derefGroup(hobj_ref_t iRef) const { return std::make_shared<Group>(id_, &iRef); }
0076 
0077   std::shared_ptr<DataSet> File::derefDataSet(hobj_ref_t iRef) const { return std::make_shared<DataSet>(id_, &iRef); }
0078 
0079   //
0080   // static member functions
0081   //
0082 }  // namespace cms::h5