42 std::vector<string> opts(argc);
43 for (
size_t i = 0; i < (size_t)argc; ++i) opts[i] =
string(argv[i]);
47 auto it = std::find(opts.cbegin(), opts.cend(),
"--ioda-engine-options");
48 if (it == opts.cend()) {
51 params.fileName = defaultFilename;
56 if (it == opts.cend()) {
57 throw Exception(
"Bad option --ioda-engine-options. Got the "
58 "--ioda-engine-options token but nothing else.",
ioda_Here());
62 auto readOpts = [&opts, &it](
size_t n) -> std::vector<string> {
63 std::vector<string> res(n);
64 for (
size_t i = 0; i < n; ++i) {
66 if (it == opts.cend())
67 throw Exception(
"Bad option --ioda-engine-options. "
68 "Wrong number of elements.",
ioda_Here()).
add(
"Expected", n);
69 res[i] = std::string(*it);
75 if (sEngine ==
"HDF5-file") {
76 auto engineOpts = readOpts(3);
78 params.fileName = engineOpts[0];
80 enum class open_or_create {
84 = (engineOpts[1] ==
"create") ? open_or_create::create : open_or_create::open;
85 if (
action == open_or_create::open) {
96 }
else if (sEngine ==
"HDF5-mem") {
97 auto engineOpts = readOpts(3);
104 params.fileName = engineOpts[0];
108 string sAllocLen_MB = engineOpts[1];
109 string sFlush = engineOpts[2];
111 params.allocBytes = gsl::narrow<size_t>(((
size_t)std::stoul(sAllocLen_MB)) * 1024 * 1024);
112 params.flush = (sFlush ==
"true");
113 }
else if (sEngine ==
"obs-store") {
116 throw Exception(
"Bad option --ioda-engine-options. "
Definitions for setting up backends with file and memory I/O.
Interfaces for ioda::Group and related classes.
The ioda exception class.
Exception & add(const std::string &key, const T value)
Add a key-value pair to the error message.
Groups are a new implementation of ObsSpaces.
Common preprocessor definitions used throughout IODA.
IODA_DL Group createFile(const std::string &filename, BackendCreateModes mode, HDF5_Version_Range compat=defaultVersionRange())
Create a ioda::Group backed by an HDF5 file.
IODA_DL Group openFile(const std::string &filename, BackendOpenModes mode, HDF5_Version_Range compat=defaultVersionRange())
Open a ioda::Group backed by an HDF5 file.
IODA_DL Group openMemoryFile(const std::string &filename, BackendOpenModes mode=BackendOpenModes::Read_Only, bool flush_on_close=false, size_t increment_len_bytes=1000000, HDF5_Version_Range compat=defaultVersionRange())
Map an HDF5 file in memory and open a ioda::Group.
IODA_DL Group createMemoryFile(const std::string &filename, BackendCreateModes mode, bool flush_on_close=false, size_t increment_len_bytes=1000000, HDF5_Version_Range compat=defaultVersionRange())
Create a ioda::Group backed by the HDF5 in-memory-store.
std::pair< HDF5_Version, HDF5_Version > HDF5_Version_Range
@ V18
Use the latest HDF5 v1.8 format for storing objects.
@ V110
Use the latest HDF5 v1.10 format for storing objects.
IODA_DL Group createRootGroup()
Create a ioda::Group backed by an OsbStore Group object.
IODA_DL Group constructFromCmdLine(int argc, char **argv, const std::string &defaultFilename)
This is a wrapper function around the constructBackend function for creating a backend based on comma...
BackendNames
Backend names.
IODA_DL Group constructBackend(BackendNames name, BackendCreationParameters ¶ms)
This is a simple factory style function that will instantiate a different backend based on a given na...
@ Create
Create a new file.
@ Open
Open an existing file.
@ Hdf5Mem
HDF5 in-memory "file".
@ Hdf5File
HDF5 file access.
@ ObsStore
ObsStore in-memory.
@ Fail_If_Exists
If the file already exists, fail with an error.
@ Truncate_If_Exists
If the file already exists, overwrite it.
@ Read_Write
Open the file in read-write mode.
@ Read_Only
Open the file in read-only mode.
Used to specify backend creation-time properties.