Nektar++
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
Nektar::LibUtilities::H5::File Class Reference

HDF5 file wrapper. More...

#include <H5.h>

Inheritance diagram for Nektar::LibUtilities::H5::File:
[legend]

Public Member Functions

 ~File () override
 
- Public Member Functions inherited from Nektar::LibUtilities::H5::CanHaveGroupsDataSets
GroupSharedPtr CreateGroup (const std::string &name, PListSharedPtr createPL=PList::Default(), PListSharedPtr accessPL=PList::Default())
 
DataSetSharedPtr CreateDataSet (const std::string &name, DataTypeSharedPtr type, DataSpaceSharedPtr space, PListSharedPtr createPL=PList::Default(), PListSharedPtr accessPL=PList::Default())
 
template<class T >
DataSetSharedPtr CreateWriteDataSet (const std::string &name, const std::vector< T > &data, PListSharedPtr createPL=PList::Default(), PListSharedPtr accessPL=PList::Default())
 
GroupSharedPtr OpenGroup (const std::string &name, PListSharedPtr accessPL=PList::Default()) const
 
DataSetSharedPtr OpenDataSet (const std::string &name, PListSharedPtr accessPL=PList::Default()) const
 
bool ContainsDataSet (std::string nm)
 
hsize_t GetNumElements ()
 
- Public Member Functions inherited from Nektar::LibUtilities::H5::Object
void Close ()
 
hid_t GetId () const
 
 operator hid_t () const
 

Static Public Member Functions

static FileSharedPtr Create (const std::string &filename, unsigned mode, PListSharedPtr createPL=PList::Default(), PListSharedPtr accessPL=PList::Default())
 
static FileSharedPtr Open (const std::string &filename, unsigned mode, PListSharedPtr accessPL=PList::Default())
 

Protected Member Functions

void v_Close () override
 
hsize_t v_GetNumElements () override
 
- Protected Member Functions inherited from Nektar::LibUtilities::H5::CanHaveGroupsDataSets
virtual hsize_t v_GetNumElements ()=0
 
LinkIterator begin ()
 
LinkIterator end ()
 
- Protected Member Functions inherited from Nektar::LibUtilities::H5::Object
 Object ()
 
 Object (hid_t id)
 
virtual ~Object ()
 
virtual void v_Close ()=0
 

Private Member Functions

 File (hid_t id)
 

Additional Inherited Members

- Protected Attributes inherited from Nektar::LibUtilities::H5::Object
hid_t m_Id
 

Detailed Description

HDF5 file wrapper.

Definition at line 467 of file H5.h.

Constructor & Destructor Documentation

◆ ~File()

Nektar::LibUtilities::H5::File::~File ( )
override

Definition at line 644 of file H5.cpp.

645{
646 if (m_Id != H5I_INVALID_HID)
647 {
648 Close();
649 }
650}

References Nektar::LibUtilities::H5::Object::Close(), and Nektar::LibUtilities::H5::Object::m_Id.

◆ File()

Nektar::LibUtilities::H5::File::File ( hid_t  id)
private

Definition at line 624 of file H5.cpp.

624 : Object(id)
625{
626}

Referenced by Create(), and Open().

Member Function Documentation

◆ Create()

FileSharedPtr Nektar::LibUtilities::H5::File::Create ( const std::string &  filename,
unsigned  mode,
PListSharedPtr  createPL = PList::Default(),
PListSharedPtr  accessPL = PList::Default() 
)
static

Definition at line 627 of file H5.cpp.

629{
630 hid_t id;
632 id, H5Fcreate,
633 (filename.c_str(), mode, createPL->GetId(), accessPL->GetId()));
634 return FileSharedPtr(new File(id));
635}
#define H5_CONSTRUCT(ans, func, args)
Definition: H5.h:50
std::shared_ptr< File > FileSharedPtr
Definition: H5.h:88

References File(), and H5_CONSTRUCT.

Referenced by Nektar::LibUtilities::FieldIOHdf5::v_Write().

◆ Open()

FileSharedPtr Nektar::LibUtilities::H5::File::Open ( const std::string &  filename,
unsigned  mode,
PListSharedPtr  accessPL = PList::Default() 
)
static

Definition at line 636 of file H5.cpp.

638{
639 hid_t id;
640 H5_CONSTRUCT(id, H5Fopen, (filename.c_str(), mode, accessPL->GetId()));
641 return FileSharedPtr(new File(id));
642}

References File(), and H5_CONSTRUCT.

Referenced by Nektar::LibUtilities::FieldIOHdf5::v_Write().

◆ v_Close()

void Nektar::LibUtilities::H5::File::v_Close ( )
overrideprotectedvirtual

Implements Nektar::LibUtilities::H5::Object.

Definition at line 652 of file H5.cpp.

653{
654 H5_CALL(H5Fclose, (m_Id));
655 m_Id = H5I_INVALID_HID;
656}
#define H5_CALL(func, args)
Definition: H5.h:58

References H5_CALL, and Nektar::LibUtilities::H5::Object::m_Id.

◆ v_GetNumElements()

hsize_t Nektar::LibUtilities::H5::File::v_GetNumElements ( )
overrideprotectedvirtual

Implements Nektar::LibUtilities::H5::CanHaveGroupsDataSets.

Definition at line 657 of file H5.cpp.

658{
659 GroupSharedPtr root = OpenGroup("/");
660 return root->GetNumElements();
661}
GroupSharedPtr OpenGroup(const std::string &name, PListSharedPtr accessPL=PList::Default()) const
Definition: H5.cpp:242
std::shared_ptr< Group > GroupSharedPtr
Definition: FieldIOHdf5.h:48

References Nektar::LibUtilities::H5::CanHaveGroupsDataSets::OpenGroup().