From 32c34cd6fead243c45095a889426acbc5b232e30 Mon Sep 17 00:00:00 2001 From: Timm Fitschen <t.fitschen@indiscale.com> Date: Thu, 29 Jul 2021 23:53:22 +0200 Subject: [PATCH] WIP: specify c-interface --- include/ccaosdb.h | 100 ++++++++++++++++++++++++++++++++++- src/caosdb/configuration.cpp | 11 ++-- 2 files changed, 106 insertions(+), 5 deletions(-) diff --git a/include/ccaosdb.h b/include/ccaosdb.h index 3d57a01..0df5f0e 100644 --- a/include/ccaosdb.h +++ b/include/ccaosdb.h @@ -1,7 +1,5 @@ #ifdef __cplusplus extern "C" { -#else -#include <stdbool.h> #endif /** @@ -236,6 +234,104 @@ int caosdb_connection_connection_manager_get_default_connection( int caosdb_connection_connection_manager_get_connection( caosdb_connection_connection *out, const char *name); +/**************************************************************************** + * ENTITY STUFF AND TRANSACTIONS + ****************************************************************************/ + +// TODO(fspreck) implementations needed, and probably these declarations are +// not sufficient yet. +typedef struct { + void *wrapped_transaction; +} caosdb_transaction_transaction; + +int caosdb_connection_connection_create_transaction( + caosdb_connection_connection *connection, + caosdb_transaction_transaction *out); +int caosdb_transaction_transaction_retrieve_by_id( + caosdb_transaction_transaction *transaction, const char *id); +int caosdb_transaction_transaction_execute( + caosdb_transaction_transaction *transaction); + +typedef struct { + void *wrapped_result_set; +} caosdb_transaction_result_set; + +int caosdb_transaction_transaction_get_result_set( + caosdb_transaction_transaction *transaction, + caosdb_transaction_result_set *out); + +typedef struct { + void *wrapped_entity; + char **id; + char **role; + char **name; + char **description; + char **datatype; + char **unit; + char **value; + char **version_id; +} caosdb_entity_entity; + +int caosdb_transaction_result_set_get_entity( + caosdb_transaction_result_set *result_set, caosdb_entity_entity *entity, + int index); + +typedef struct { + void *wrapped_property; + char **id; + char **name; + char **description; + char **datatype; + char **unit; + char **value; +} caosdb_entity_property; +typedef struct { + void *wrapped_parent; + char **id; + char **name; + char **description; +} caosdb_entity_parent; +typedef struct { + void *wrapped_message; + int *code; + char **description; +} caosdb_entity_message; + +// GETTERS FOR COMPLEX OBJECTS +int caosdb_entity_entity_get_errors_size(caosdb_entity_entity *entity, + int *out); +int caosdb_entity_entity_get_error(caosdb_entity_entity *entity, + caosdb_entity_message *out, int index); +int caosdb_entity_entity_get_warnings_size(caosdb_entity_entity *entity, + int *out); +int caosdb_entity_entity_get_warning(caosdb_entity_entity *entity, + caosdb_entity_message *out, int index); +int caosdb_entity_entity_get_infos_size(caosdb_entity_entity *entity, int *out); +int caosdb_entity_entity_get_info(caosdb_entity_entity *entity, + caosdb_entity_message *out, int index); +int caosdb_entity_entity_get_properties_size(caosdb_entity_entity *entity, + int *out); +int caosdb_entity_entity_get_property(caosdb_entity_entity *entity, + caosdb_entity_property *out, int index); +int caosdb_entity_entity_get_parents_size(caosdb_entity_entity *entity, + int *out); +int caosdb_entity_entity_get_parent(caosdb_entity_entity *entity, + caosdb_entity_parent *out, int index); + +// CONSTRUCTORS AND DESTRUCTORS +int caosdb_entity_create_entity(caosdb_entity_entity *out); +int caosdb_entity_delete_entity(caosdb_entity_entity *out); +int caosdb_entity_create_property(caosdb_entity_property *out); +int caosdb_entity_delete_property(caosdb_entity_property *out); +int caosdb_entity_create_parent(caosdb_entity_parent *out); +int caosdb_entity_delete_parent(caosdb_entity_parent *out); + +// SETTERS FOR COMPLEX OBJECTS +int caosdb_entity_entity_append_parent(caosdb_entity_entity *entity, + caosdb_entity_parent *parent); +int caosdb_entity_entity_append_property(caosdb_entity_entity *entity, + caosdb_entity_property *property); + #ifdef __cplusplus } #endif diff --git a/src/caosdb/configuration.cpp b/src/caosdb/configuration.cpp index ee81b71..58a2759 100644 --- a/src/caosdb/configuration.cpp +++ b/src/caosdb/configuration.cpp @@ -506,8 +506,6 @@ auto ConfigurationManager::InitializeDefaults() -> int { // ... and use the configuration file if (configuration_file_path != nullptr) { mLoadSingleJSONConfiguration(*configuration_file_path); - CAOSDB_LOG_INFO(logger_name) - << "Loaded configuration from" << *(configuration_file_path.get()) << "."; } if (this->json_configuration.is_object() && @@ -518,7 +516,14 @@ auto ConfigurationManager::InitializeDefaults() -> int { logging::initialize_logging(logging_configuration); } else { logging::initialize_logging_defaults(); - CAOSDB_LOG_WARN(logger_name) << "No configuration has been found."; + CAOSDB_LOG_INFO(logger_name) << "No logging configuration has been found. " + "We are using the default configuration"; + } + + if (configuration_file_path != nullptr && + this->json_configuration.is_object()) { + CAOSDB_LOG_INFO(logger_name) << "Loaded configuration from " + << *(configuration_file_path.get()) << "."; } return 0; -- GitLab