RMF
Toggle main menu visibility
File.h
Go to the documentation of this file.
1
/**
2
* \file RMF/HDF5/File.h
3
* \brief Handle read/write of Model data from/to files.
4
*
5
* Copyright 2007-2022 IMP Inventors. All rights reserved.
6
*
7
*/
8
9
#ifndef RMF_HDF5_FILE_H
10
#define RMF_HDF5_FILE_H
11
12
#include "RMF/config.h"
13
#include "
Group.h
"
14
#include "
ConstFile.h
"
15
16
RMF_ENABLE_WARNINGS
namespace
RMF
{
17
/** We provide a simple set of classes for accessing core HDF5 functionality
18
from C++. This was needed since
19
- The HDF5 C interface is not trivial to use properly, particularly in
20
regards to data type conversions and resource management
21
- It is very easy to use the C interface incorrectly without knowing it.
22
- The
23
\external{https://www.hdfgroup.org/solutions/hdf5/, standard HDF5 C++ interface}
24
doesn't really simplify use of the HDF5 library and doesn't make use
25
of the features of C++.
26
27
The main classes provide access too:
28
- HDF5 files through RMF::File and RMF::HDF5::ConstFile
29
- HDF5 groups through RMF::Group and RMF::HDF5::ConstGroup
30
- HDF5 data sets through RMF::DataSetD and RMF::HDF5::ConstDataSetD
31
32
The \c Const variants are for read only files.
33
34
They allow one to create a manipulate data sets containing floating point
35
values, integers, strings, variable length arrays of floating point values
36
and a few other types. Attributes on data sets of groups of those types
37
can also be manipulated.
38
39
The top level classes are, in turn, derived from RMF::Object,
40
RMF::HDF5::ConstAttributes and RMF::HDF5::MutableAttributes which provide
41
access to general HDF5 per-object and attribute functionality (all objects
42
in HDF5 can have arbitrary small pieces of data attached to them via
43
attributes).
44
45
Not all of the functionality of the HDF5 \c C library is covered in C++.
46
You can get the corresponding native handle from most objects with methods
47
like RMF::File::get_handle() and use that for other operations if needed.
48
Or submit a patch to the library.
49
*/
50
namespace
HDF5
{
51
52
/** Store a handle to an HDF5 file. See
53
\external{https://docs.hdfgroup.org/releases/hdf5/v1_14/v1_14_4/documentation/doxygen/group___h5_f.html,
54
the HDF5 manual} for more information.*/
55
class
RMFEXPORT File :
public
Group {
56
public
:
57
#if !defined(RMF_DOXYGEN) && !defined(SWIG)
58
File(std::shared_ptr<SharedHandle> h);
59
// silliness to make RMF easier to implement
60
bool
get_is_writable()
const
{
61
unsigned
int
intent;
62
RMF_HDF5_CALL
(H5Fget_intent(get_handle(), &intent));
63
return
intent == H5F_ACC_RDWR;
64
}
65
#endif
66
RMF_SHOWABLE(File,
"File "
<< get_name());
67
File() {}
68
std::string get_name()
const
;
69
void
flush();
70
~File();
71
};
72
73
/** Create a new HDF5 file, clearing any existing file with the same
74
name if needed. The file cannot already be open.
75
76
\exception RMF::IOException couldn't create file
77
*/
78
RMFEXPORT
File
create_file
(std::string name);
79
80
/** Open an existing HDF5 file. The file cannot already be open/.
81
82
\exception RMF::IOException couldn't open file
83
*/
84
RMFEXPORT
File
open_file
(std::string name);
85
86
#ifndef RMF_DOXYGEN
87
/** Open an existing HDF5 file read only. The file cannot already
88
be open.
89
*/
90
RMFEXPORT
File
open_file_read_only_returning_nonconst(std::string name);
91
#endif
92
93
/** */
94
typedef
std::vector<Group> Groups;
95
/** */
96
typedef
std::vector<File> Files;
97
98
}
/* namespace HDF5 */
99
}
/* namespace RMF */
100
101
RMF_DISABLE_WARNINGS
102
103
#endif
/* RMF_HDF5_FILE_H */
ConstFile.h
Handle read/write of Model data from/to files.
Group.h
Handle read/write of Model data from/to files.
RMF_HDF5_CALL
#define RMF_HDF5_CALL(v)
Definition
HDF5/infrastructure_macros.h:28
RMF::HDF5::File
Definition
File.h:55
RMF::HDF5
The namespace for all HDF5 functionality in the library.
Definition
ConstAttributes.h:21
RMF::HDF5::open_file
File open_file(std::string name)
RMF::HDF5::create_file
File create_file(std::string name)
RMF
The namespace for all functionality in the library.
Definition
BufferConstHandle.h:21