Skip to content

Commit

Permalink
Proposal to create an FDB instance from config path via C-API (for py…
Browse files Browse the repository at this point in the history
…fdb)
  • Loading branch information
geier1993 committed Mar 18, 2024
1 parent bab5ebb commit dc74ee0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/fdb5/api/FDB.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@
#include "fdb5/api/FDB.h"
#include "fdb5/api/FDBFactory.h"
#include "fdb5/api/helpers/FDBToolRequest.h"
#include "fdb5/config/Config.h"
#include "fdb5/database/Key.h"
#include "fdb5/io/HandleGatherer.h"
#include "fdb5/message/MessageDecoder.h"


namespace fdb5 {

//----------------------------------------------------------------------------------------------------------------------
Expand Down
6 changes: 6 additions & 0 deletions src/fdb5/api/fdb_c.cc
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,12 @@ int fdb_new_handle(fdb_handle_t** fdb) {
});
}

int fdb_new_handle_from_config_path(fdb_handle_t** fdb, const char* path) {
return wrapApiFunction([fdb, path] {
*fdb = new fdb_handle_t(Config::make(path));
});
}

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);
Expand Down
9 changes: 8 additions & 1 deletion src/fdb5/api/fdb_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ int fdb_delete_datareader(fdb_datareader_t* dr);


/** \defgroup FDB API */
/** @{ */
/** @{*/

struct fdb_handle_t;
/** Opaque type for the FDB object. */
Expand All @@ -294,6 +294,13 @@ typedef struct fdb_handle_t fdb_handle_t;
* \returns Return code (#FdbErrorValues)
*/
int fdb_new_handle(fdb_handle_t** fdb);

/** Creates a FDB instance from a given path to an FDB (alternative to read FDB5_CONFIG_FILE).
* \param fdb FDB instance. Returned instance must be deleted using #fdb_delete_handle.
* \param path Path to an fdb config file
* \returns Return code (#FdbErrorValues)
*/
int fdb_new_handle_from_config_path(fdb_handle_t** fdb, const char* path);

/** 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
Expand Down

0 comments on commit dc74ee0

Please sign in to comment.