IODA
Factory.h
Go to the documentation of this file.
1 #pragma once
2 /*
3  * (C) Copyright 2020-2021 UCAR
4  *
5  * This software is licensed under the terms of the Apache Licence Version 2.0
6  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
7  */
8 /*! \defgroup ioda_cxx_engines_pub Engines
9  * \brief Public API for engines
10  * \ingroup ioda_cxx_api
11  *
12  * @{
13  * \file Factory.h
14  * \brief Definitions for setting up backends with file and memory I/O.
15  */
16 #include <string>
17 
18 #include "../defs.h"
19 
20 namespace ioda {
21 class Group;
22 
23 /// The backends that implement the ioda-engines functionality.
24 namespace Engines {
25 /// \brief Backend names
26 /// \ingroup ioda_cxx_engines_pub
27 enum class BackendNames {
28  Hdf5File, ///< HDF5 file access
29  Hdf5Mem, ///< HDF5 in-memory "file"
30  ObsStore ///< ObsStore in-memory
31 };
32 
33 /// Actions for accessing a file
34 /// \ingroup ioda_cxx_engines_pub
35 enum class BackendFileActions {
36  Create, ///< Create a new file
37  Open ///< Open an existing file
38 };
39 
40 /// Options when creating a new file.
41 /// \ingroup ioda_cxx_engines_pub
42 enum class BackendCreateModes {
43  Truncate_If_Exists, ///< If the file already exists, overwrite it.
44  Fail_If_Exists ///< If the file already exists, fail with an error.
45 };
46 
47 /// Options when opening an file that already exists.
48 /// \ingroup ioda_cxx_engines_pub
49 enum class BackendOpenModes {
50  Read_Only, ///< Open the file in read-only mode.
51  Read_Write ///< Open the file in read-write mode.
52 };
53 
54 /// \brief Used to specify backend creation-time properties
55 /// \ingroup ioda_cxx_engines_pub
57 public:
58  std::string fileName;
62  std::size_t allocBytes;
63  bool flush;
64 };
65 
66 /// \brief This is a wrapper function around the constructBackend
67 /// function for creating a backend based on command-line options.
68 /// Intended for unit testing only.
69 /// \ingroup ioda_cxx_engines_pub
70 IODA_DL Group constructFromCmdLine(int argc, char** argv, const std::string& defaultFilename);
71 
72 /// \brief This is a simple factory style function that will instantiate a
73 /// different backend based on a given name an parameters.
74 /// \ingroup ioda_cxx_engines_pub
76 } // namespace Engines
77 } // namespace ioda
78 
79 /// @}
Groups are a new implementation of ObsSpaces.
Definition: Group.h:159
#define IODA_DL
A preprocessor tag that indicates that a symbol is to be exported/imported.
Definition: defs.h:110
BackendFileActions
Definition: Factory.h:35
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...
Definition: Factory.cpp:20
BackendNames
Backend names.
Definition: Factory.h:27
IODA_DL Group constructBackend(BackendNames name, BackendCreationParameters &params)
This is a simple factory style function that will instantiate a different backend based on a given na...
Definition: Factory.cpp:123
BackendCreateModes
Definition: Factory.h:42
@ 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.
Definition: Factory.h:56