diff --git a/.gitignore b/.gitignore index 722d5e71d..6a8bc10ae 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .vscode +build \ No newline at end of file diff --git a/VERSION b/VERSION index f7fe56fa5..ad59b0f9c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5.13.101 +5.13.103 \ No newline at end of file diff --git a/src/fdb5/api/FDB.cc b/src/fdb5/api/FDB.cc index 9faa56016..77ff1ffcd 100644 --- a/src/fdb5/api/FDB.cc +++ b/src/fdb5/api/FDB.cc @@ -300,13 +300,17 @@ void FDB::flush() { IndexAxis FDB::axes(const FDBToolRequest& request, int level) { IndexAxis axes; AxesElement elem; - auto it = internal_->axes(request, level); + auto it = axesIterator(request, level); while (it.next(elem)) { axes.merge(elem.axes()); } return axes; } +AxesIterator FDB::axesIterator(const FDBToolRequest& request, int level) { + return internal_->axesIterator(request, level); +} + bool FDB::dirty() const { return dirty_; } diff --git a/src/fdb5/api/FDB.h b/src/fdb5/api/FDB.h index a443d6c2a..d6ec236f3 100644 --- a/src/fdb5/api/FDB.h +++ b/src/fdb5/api/FDB.h @@ -33,6 +33,7 @@ #include "fdb5/api/helpers/StatusIterator.h" #include "fdb5/api/helpers/WipeIterator.h" #include "fdb5/api/helpers/MoveIterator.h" +#include "fdb5/api/helpers/AxesIterator.h" #include "fdb5/config/Config.h" #include "fdb5/api/helpers/Callback.h" @@ -115,6 +116,8 @@ class FDB { IndexAxis axes(const FDBToolRequest& request, int level=3); + AxesIterator axesIterator(const FDBToolRequest& request, int level=3); + bool enabled(const ControlIdentifier& controlIdentifier) const; bool dirty() const; diff --git a/src/fdb5/api/FDBFactory.h b/src/fdb5/api/FDBFactory.h index 66e74fb53..9ff9739ff 100644 --- a/src/fdb5/api/FDBFactory.h +++ b/src/fdb5/api/FDBFactory.h @@ -93,7 +93,7 @@ class FDBBase : private eckit::NonCopyable { virtual MoveIterator move(const FDBToolRequest& request, const eckit::URI& dest) = 0; - virtual AxesIterator axes(const FDBToolRequest& request, int axes) { NOTIMP; } + virtual AxesIterator axesIterator(const FDBToolRequest& request, int axes) { NOTIMP; } void registerArchiveCallback(ArchiveCallback callback) {callback_ = callback;} diff --git a/src/fdb5/api/LocalFDB.cc b/src/fdb5/api/LocalFDB.cc index e9d7bfbab..8c2d680a7 100644 --- a/src/fdb5/api/LocalFDB.cc +++ b/src/fdb5/api/LocalFDB.cc @@ -125,8 +125,8 @@ ControlIterator LocalFDB::control(const FDBToolRequest& request, return queryInternal(request, action, identifiers); } -AxesIterator LocalFDB::axes(const FDBToolRequest& request, int level) { - LOG_DEBUG_LIB(LibFdb5) << "LocalFDB::axes() : " << request << std::endl; +AxesIterator LocalFDB::axesIterator(const FDBToolRequest& request, int level) { + LOG_DEBUG_LIB(LibFdb5) << "LocalFDB::axesIterator() : " << request << std::endl; return queryInternal(request, config_, level); } diff --git a/src/fdb5/api/LocalFDB.h b/src/fdb5/api/LocalFDB.h index 6f36faf9d..05c4d3c8f 100644 --- a/src/fdb5/api/LocalFDB.h +++ b/src/fdb5/api/LocalFDB.h @@ -59,7 +59,7 @@ class LocalFDB : public FDBBase { MoveIterator move(const FDBToolRequest& request, const eckit::URI& dest) override; - AxesIterator axes(const FDBToolRequest& request, int axes) override; + AxesIterator axesIterator(const FDBToolRequest& request, int axes) override; void flush() override; diff --git a/src/fdb5/api/SelectFDB.cc b/src/fdb5/api/SelectFDB.cc index 3bbd7c641..5e704e2ab 100644 --- a/src/fdb5/api/SelectFDB.cc +++ b/src/fdb5/api/SelectFDB.cc @@ -196,6 +196,14 @@ ControlIterator SelectFDB::control(const FDBToolRequest& request, }); } +AxesIterator SelectFDB::axesIterator(const FDBToolRequest& request, int level) { + LOG_DEBUG_LIB(LibFdb5) << "SelectFDB::axesIterator() >> " << request << std::endl; + return queryInternal(request, + [level](FDB& fdb, const FDBToolRequest& request) { + return fdb.axesIterator(request, level); + }); +} + void SelectFDB::flush() { for (auto& iter : subFdbs_) { FDB& fdb(iter.second); diff --git a/src/fdb5/api/SelectFDB.h b/src/fdb5/api/SelectFDB.h index 78937c358..b8678d9ab 100644 --- a/src/fdb5/api/SelectFDB.h +++ b/src/fdb5/api/SelectFDB.h @@ -68,6 +68,8 @@ class SelectFDB : public FDBBase { MoveIterator move(const FDBToolRequest& request, const eckit::URI& dest) override { NOTIMP; } + AxesIterator axesIterator(const FDBToolRequest& request, int level) override; + void flush() override; private: // methods diff --git a/src/fdb5/api/fdb_c.cc b/src/fdb5/api/fdb_c.cc index 3fcc0f43e..12f4f6b6b 100644 --- a/src/fdb5/api/fdb_c.cc +++ b/src/fdb5/api/fdb_c.cc @@ -12,6 +12,7 @@ #include "eckit/io/FileDescHandle.h" #include "eckit/message/Message.h" #include "eckit/runtime/Main.h" +#include "eckit/config/YAMLConfiguration.h" #include "metkit/mars/MarsRequest.h" #include "metkit/mars/MarsExpension.h" @@ -331,6 +332,16 @@ int fdb_new_handle(fdb_handle_t** fdb) { }); } +int fdb_new_handle_from_yaml(fdb_handle_t** fdb, const char* system_config, const char* user_config) { + return wrapApiFunction([fdb, system_config, user_config] { + Config cfg{YAMLConfiguration(std::string(system_config)), YAMLConfiguration(std::string(user_config))}; + cfg.set("configSource", "yaml"); + cfg.expandConfig(); + *fdb = new fdb_handle_t(cfg); + }); + +} + int fdb_archive(fdb_handle_t* fdb, fdb_key_t* key, const char* data, size_t length) { return wrapApiFunction([fdb, key, data, length] { ASSERT(fdb); diff --git a/src/fdb5/api/fdb_c.h b/src/fdb5/api/fdb_c.h index e3371c61a..df569fabe 100644 --- a/src/fdb5/api/fdb_c.h +++ b/src/fdb5/api/fdb_c.h @@ -310,6 +310,14 @@ typedef struct fdb_handle_t fdb_handle_t; */ int fdb_new_handle(fdb_handle_t** fdb); +/** Creates a FDB instance from a YAML configuration. + * \param fdb FDB instance. Returned instance must be deleted using #fdb_delete_handle. + * \param system_config Override the system config with this YAML string + * \param user_config Supply user level config with this YAML string + * \returns Return code (#FdbErrorValues) + */ +int fdb_new_handle_from_yaml(fdb_handle_t** fdb, const char* system_config, const char* user_config); + /** Archives binary data to a FDB instance. * \warning this is a low-level API. The provided key and the corresponding data are not checked for consistency * \param fdb FDB instance.