diff --git a/CMakeLists.txt b/CMakeLists.txt index 06aabe8f9b25c3f72e46062e2dc20496187e9cb8..7f869346a6bb03539736b961ef4555f86117d5f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,9 +22,9 @@ cmake_minimum_required(VERSION 3.13) set(libcaosdb_VERSION 0.1.0) set(libcaosdb_COMPATIBLE_SERVER_VERSION_MAJOR 0) -set(libcaosdb_COMPATIBLE_SERVER_VERSION_MINOR 5) +set(libcaosdb_COMPATIBLE_SERVER_VERSION_MINOR 6) set(libcaosdb_COMPATIBLE_SERVER_VERSION_PATCH 0) -set(libcaosdb_COMPATIBLE_SERVER_VERSION_PRE_RELEASE "GRPC${libcaosdb_VERSION}") +set(libcaosdb_COMPATIBLE_SERVER_VERSION_PRE_RELEASE "") project(libcaosdb VERSION ${libcaosdb_VERSION} @@ -39,17 +39,10 @@ set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -option(BUILD_SHARED_LIBCCAOSDB "Build libccaosdb as a shared library, based on a static libcaosdb" ON) set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) -########################################### -### Special treatment for "Windows", -### a proprietary OS by "MicroSoft". -########################################### IF (WIN32) - cmake_minimum_required(VERSION 3.15) - cmake_policy(SET CMP0091 NEW) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) ENDIF() @@ -58,7 +51,7 @@ ENDIF() ########################################### message(STATUS "Build directory ${CMAKE_BINARY_DIR}") include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(KEEP_RPATHS) +conan_basic_setup() # fix grpc - remove unsecure (no-op ssl implementations) string(REGEX REPLACE "grpc\\+?\\+?_unsecure" "" CONAN_LIBS_GRPC @@ -154,87 +147,84 @@ add_custom_command( ############################################################################### if("${CMAKE_BUILD_TYPE}" MATCHES "Debug") - add_library(caosdb_grpc ${GRPC_GENERATED}) - add_library(caosdb ${libcaosdb_INCL} ${libcaosdb_SRC}) + add_library(caosdb_grpc SHARED ${GRPC_GENERATED}) + add_library(caosdb SHARED ${libcaosdb_INCL} ${libcaosdb_SRC}) target_link_libraries(caosdb caosdb_grpc) - target_link_libraries(caosdb_grpc ${CONAN_LIBS}) set(LIBCAOSDB caosdb caosdb_grpc) - target_include_directories(caosdb_grpc SYSTEM PUBLIC - ${CONAN_INCLUDE_DIRS} - ) target_include_directories(caosdb_grpc PUBLIC $<BUILD_INTERFACE:${libcaosdb_SOURCE_DIR}/include> $<BUILD_INTERFACE:${libcaosdb_BINARY_DIR}/include> $<INSTALL_INTERFACE:include> ) - - set_target_properties(caosdb_grpc PROPERTIES - COMPILE_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") + target_include_directories(caosdb_grpc SYSTEM PUBLIC + ${CONAN_INCLUDE_DIRS} + ) else() add_library(caosdb - ${libcaosdb_INCL} ${libcaosdb_SRC} ${GRPC_GENERATED}) + SHARED ${libcaosdb_INCL} ${libcaosdb_SRC} ${GRPC_GENERATED}) set(LIBCAOSDB caosdb) endif() - -set(TARGET_CAOSDB_COMPILE_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") target_link_libraries(caosdb ${CONAN_LIBS} ) +target_include_directories(caosdb PUBLIC + $<BUILD_INTERFACE:${libcaosdb_SOURCE_DIR}/include> + $<BUILD_INTERFACE:${libcaosdb_BINARY_DIR}/include> + $<INSTALL_INTERFACE:include> +) target_include_directories(caosdb SYSTEM PUBLIC ${CONAN_INCLUDE_DIRS} ) -target_include_directories(caosdb PUBLIC + +add_library(ccaosdb SHARED src/ccaosdb.cpp) +target_link_libraries(ccaosdb + ${CONAN_LIBS} + ${LIBCAOSDB} +) +target_include_directories(ccaosdb PUBLIC $<BUILD_INTERFACE:${libcaosdb_SOURCE_DIR}/include> $<BUILD_INTERFACE:${libcaosdb_BINARY_DIR}/include> $<INSTALL_INTERFACE:include> ) +target_include_directories(ccaosdb SYSTEM PUBLIC + ${CONAN_INCLUDE_DIRS} +) -################################################### -# ccaosdb - A C-Wrapper of the C++ caosdb library -################################################### -add_library(ccaosdb SHARED src/ccaosdb.cpp) - target_link_libraries(ccaosdb - "-Wl,--whole-archive" - ${LIBCAOSDB} - "-Wl,--no-whole-archive" - ) -###################################### -# ccaosdbcli - A plain C test client. -###################################### add_executable(ccaosdbcli EXCLUDE_FROM_ALL src/ccaosdbcli.c) - target_include_directories(ccaosdbcli PUBLIC $<BUILD_INTERFACE:${libcaosdb_SOURCE_DIR}/include> $<BUILD_INTERFACE:${libcaosdb_BINARY_DIR}/include> $<INSTALL_INTERFACE:include> ) +target_include_directories(ccaosdbcli SYSTEM PUBLIC + ${CONAN_INCLUDE_DIRS} +) + target_link_libraries(ccaosdbcli - ccaosdb ${CONAN_LIBS} + ${LIBCAOSDB} + ccaosdb ) -###################################### -# cxxcaosdbcli - A C++ test client. -###################################### - add_executable(cxxcaosdbcli EXCLUDE_FROM_ALL src/cxxcaosdbcli.cpp) -target_include_directories(cxxcaosdbcli SYSTEM PUBLIC - ${CONAN_INCLUDE_DIRS} -) target_include_directories(cxxcaosdbcli PUBLIC $<BUILD_INTERFACE:${libcaosdb_SOURCE_DIR}/include> $<BUILD_INTERFACE:${libcaosdb_BINARY_DIR}/include> $<INSTALL_INTERFACE:include> ) +target_include_directories(cxxcaosdbcli SYSTEM PUBLIC + ${CONAN_INCLUDE_DIRS} +) target_link_libraries(cxxcaosdbcli ${LIBCAOSDB} ${CONAN_LIBS} ) + ####################################################### ### LINTING with CLANG-TIDY and INCLUDE-WHAT-YOU-USE ####################################################### @@ -271,16 +261,17 @@ function(add_compiler_flag flag) endfunction() + option(LINTING "Enable linting with clang-tidy and iwyu when in non-Debug build-type" OFF) -if ("${CMAKE_BUILD_TYPE}" MATCHES "Debug" OR LINTING) +if("${CMAKE_BUILD_TYPE}" MATCHES "Debug" OR LINTING) set(_LINTING ON) endif() option(SKIP_LINTING "Skip linting even when in Debug build-type" OFF) -if ("${CMAKE_BUILD_TYPE}" MATCHES "Debug" AND SKIP_LINTING) +if("${CMAKE_BUILD_TYPE}" MATCHES "Debug" AND SKIP_LINTING) message(WARNING "Skipping linting due to SKIP_LINTING option") set(_LINTING OFF) endif() -if (_LINTING) +if(_LINTING) ### set paranoid compiler flags add_compiler_flag("-Wall") diff --git a/conanfile.py b/conanfile.py index 619d2d3b4729064c81aac8c5697c079100acbead..6fc869fb02b3e5577a5af06c647df1dcf3048958 100644 --- a/conanfile.py +++ b/conanfile.py @@ -15,9 +15,11 @@ class CaosdbConan(ConanFile): generators = "cmake" requires = [ ("boost/1.77.0"), - ("gtest/1.11.0"), ("grpc/1.39.1"), ] + build_requires = [ + ("gtest/1.11.0"), + ] exports = ("*.cmake", "*CMakeLists.txt", "*.in", "*.h", "*.proto", "*.c", "*.cpp", "*.rst", "*.md", diff --git a/include/caosdb/connection.h b/include/caosdb/connection.h index 3211c17d47d584b92b940a9aba6213b55528fc2e..ac1d05a419816ac21bd0a70ceafaf97428bd08da 100644 --- a/include/caosdb/connection.h +++ b/include/caosdb/connection.h @@ -27,18 +27,18 @@ * @date 2021-05-18 * @brief Configuration and setup of the connection. */ -#include "caosdb/authentication.h" // for Authenticator -#include "caosdb/configuration.h" // for ConnectionConfigura... -#include "caosdb/entity/v1alpha1/main.grpc.pb.h" // for EntityTransactionSe... -#include "caosdb/info.h" // for VersionInfo -#include "caosdb/info/v1alpha1/main.grpc.pb.h" // for GeneralInfoService:... -#include "caosdb/transaction.h" // for Transaction -#include "caosdb/transaction_status.h" // for TransactionStatus -#include <filesystem> // for path -#include <grpcpp/channel.h> // for Channel -#include <map> // for map -#include <memory> // for shared_ptr, unique_ptr -#include <string> // for string, basic_string +#include "caosdb/authentication.h" // for Authenticator +#include "caosdb/configuration.h" // for ConnectionConfigura... +#include "caosdb/entity/v1/main.grpc.pb.h" // for EntityTransactionSe... +#include "caosdb/info.h" // for VersionInfo +#include "caosdb/info/v1/main.grpc.pb.h" // for GeneralInfoService:... +#include "caosdb/transaction.h" // for Transaction +#include "caosdb/transaction_status.h" // for TransactionStatus +#include <filesystem> // for path +#include <grpcpp/channel.h> // for Channel +#include <map> // for map +#include <memory> // for shared_ptr, unique_ptr +#include <string> // for string, basic_string namespace caosdb::connection { using caosdb::authentication::Authenticator; diff --git a/include/caosdb/entity.h b/include/caosdb/entity.h index 6fea70ed8501c04d0da5628956cb9b1157f53e3c..9070453e36241c307888d226c40adf28c16dadc6 100644 --- a/include/caosdb/entity.h +++ b/include/caosdb/entity.h @@ -54,9 +54,9 @@ #include <vector> // for vector namespace caosdb::entity { +using caosdb::entity::v1::IdResponse; using std::filesystem::exists; using std::filesystem::is_directory; -using caosdb::entity::v1::IdResponse; using ProtoParent = caosdb::entity::v1::Parent; using ProtoProperty = caosdb::entity::v1::Property; using ProtoEntity = caosdb::entity::v1::Entity; @@ -774,7 +774,7 @@ public: this->value = other.value; this->properties = other.properties; this->parents = other.parents; - this->file_descriptor.local_path = boost::filesystem::path(other.file_descriptor.local_path); + this->file_descriptor.local_path = std::filesystem::path(other.file_descriptor.local_path); this->file_descriptor.file_transmission_id->CopyFrom( *other.file_descriptor.file_transmission_id); this->file_descriptor.wrapped->CopyFrom(*other.file_descriptor.wrapped); diff --git a/include/caosdb/status_code.h b/include/caosdb/status_code.h index e1a382191b5bd4559c554e2fc3e084103c27c3cc..41dad5bddd918ac5cc42e577798676bcf8b6bea4 100644 --- a/include/caosdb/status_code.h +++ b/include/caosdb/status_code.h @@ -67,7 +67,7 @@ enum StatusCode { TRANSACTION_TYPE_ERROR = 26, UNSUPPORTED_FEATURE = 27, ORIGINAL_ENTITY_MISSING_ID = 28, - EXTERN_C_ASSIGNMENT_ERROR = 29, + // EXTERN_C_ASSIGNMENT_ERROR = 29, ENTITY_CANNOT_HAVE_A_DATA_TYPE = 30, ENTITY_CANNOT_HAVE_A_VALUE = 31, NOT_A_FILE_ENTITY = 32, diff --git a/include/ccaosdb.h b/include/ccaosdb.h index ad6bafeccd8bc5b9308fce759b280f3814e044af..48d0da757351508ed194e52635670d0c24e53164 100644 --- a/include/ccaosdb.h +++ b/include/ccaosdb.h @@ -20,6 +20,8 @@ * */ +#ifndef CCAOSDB_H +#define CCAOSDB_H #ifdef __cplusplus #include <cstdint> // for int64_t extern "C" { @@ -496,3 +498,4 @@ int caosdb_entity_parent_set_name(caosdb_entity_parent *parent, const char *name #ifdef __cplusplus } #endif +#endif diff --git a/proto b/proto index 9fa41dce325d370eb8da60a77e921d4a0618f513..533c8e7341d0659e3cc43d834793a7a965703f55 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 9fa41dce325d370eb8da60a77e921d4a0618f513 +Subproject commit 533c8e7341d0659e3cc43d834793a7a965703f55 diff --git a/src/caosdb/configuration.cpp b/src/caosdb/configuration.cpp index 9a7320484a99834981cb98901a08621ff0908b7e..90cc97b3cebc1b39a1b376805ae73cc068173ef7 100644 --- a/src/caosdb/configuration.cpp +++ b/src/caosdb/configuration.cpp @@ -26,7 +26,6 @@ #include "caosdb/log_level.h" // for CAOSDB_DEFAULT... #include "caosdb/status_code.h" // for StatusCode #include "caosdb/utility.h" // for get_home_direc... -#include <boost/iterator/iterator_facade.hpp> // for iterator_facad... #include <boost/json/impl/object.hpp> // for object::at #include <boost/json/object.hpp> // for object, objec... #include <boost/json/string.hpp> // for string diff --git a/src/caosdb/logging.cpp b/src/caosdb/logging.cpp index 4070786b2bb4073da5800f4a57b9c0dfcff5d6ac..cb852d4195c332ff44b6db41792b3ee7b6486612 100644 --- a/src/caosdb/logging.cpp +++ b/src/caosdb/logging.cpp @@ -19,23 +19,25 @@ * */ #include "caosdb/logging.h" -#include "boost/core/swap.hpp" // for swap -#include "boost/iterator/iterator_facade.hpp" -#include "boost/log/attributes/clock.hpp" -#include "boost/log/core/core.hpp" // for core -#include "boost/log/core/record.hpp" -#include "boost/log/sources/record_ostream.hpp" -#include "boost/log/utility/setup/from_settings.hpp" -#include "boost/log/utility/setup/settings.hpp" -#include "boost/move/utility_core.hpp" // for move -#include "boost/multi_index/detail/bidir_node_iterator.hpp" -#include "boost/operators.hpp" -#include "boost/preprocessor/seq/limits/enum_256.hpp" -#include "boost/preprocessor/seq/limits/size_256.hpp" -#include "boost/property_tree/detail/exception_implementation.hpp" -#include "boost/smart_ptr/shared_ptr.hpp" -#include "boost/tuple/detail/tuple_basic.hpp" // for get #include "caosdb/log_level.h" +#include <boost/core/swap.hpp> // for swap +#include <boost/iterator/iterator_facade.hpp> +#include <boost/log/attributes/clock.hpp> +#include <boost/log/core/core.hpp> // for core +#include <boost/log/core/record.hpp> +#include <boost/log/sources/global_logger_storage.hpp> +#include <boost/log/sources/record_ostream.hpp> +#include <boost/log/sources/severity_channel_logger.hpp> +#include <boost/log/utility/setup/from_settings.hpp> +#include <boost/log/utility/setup/settings.hpp> +#include <boost/move/utility_core.hpp> // for move +#include <boost/multi_index/detail/bidir_node_iterator.hpp> +#include <boost/operators.hpp> +#include <boost/preprocessor/seq/limits/enum_256.hpp> +#include <boost/preprocessor/seq/limits/size_256.hpp> +#include <boost/property_tree/detail/exception_implementation.hpp> +#include <boost/smart_ptr/shared_ptr.hpp> +#include <boost/tuple/detail/tuple_basic.hpp> // for get #include <memory> #include <sstream> #include <string> diff --git a/src/caosdb/status_code_description.cpp b/src/caosdb/status_code_description.cpp index 5823943cfd7f79416cabb61662f778bac5de9bf8..a18c3fbcba3c93f66b837bbfe0d7e0ff725ff4ca 100644 --- a/src/caosdb/status_code_description.cpp +++ b/src/caosdb/status_code_description.cpp @@ -152,9 +152,9 @@ auto get_status_description(int code) -> const std::string & { {StatusCode::FILE_UPLOAD_ERROR, "The transaction failed during the upload of the files"}, {StatusCode::UNSUPPORTED_FEATURE, "This feature is not available in the this client implementation."}, - {StatusCode::EXTERN_C_ASSIGNMENT_ERROR, - "You tried to assign a new object to the wrapped void pointer. You have " - "to delete the old pointee first."}, + //{StatusCode::EXTERN_C_ASSIGNMENT_ERROR, + //"You tried to assign a new object to the wrapped void pointer. You have " + //"to delete the old pointee first."}, {StatusCode::ENUM_MAPPING_ERROR, "The role, importance, or datatype you specified does not exist."}, {StatusCode::SPOILED, diff --git a/src/ccaosdb.cpp b/src/ccaosdb.cpp index 65584805b26267baef13e5510e3c4202804d7dc6..ae1a728f62b7cdfb293eb347d1a1966b86bfd3b2 100644 --- a/src/ccaosdb.cpp +++ b/src/ccaosdb.cpp @@ -58,11 +58,6 @@ extern "C" { #define ENUM_VALUE_FROM_NAME(arg, etype) \ caosdb::utility::getEnumValueFromName<caosdb::entity::etype>(arg) -#define RETURN_ASSIGNEMENT_ERROR_IF_NON_NULL(arg) \ - if (arg) { \ - return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR; \ - } - /* * Macro for wrapping every function into a try-catch clause. If an exception * occurs, the given StatusCode is being returned. @@ -163,7 +158,6 @@ extern "C" { #define CREATE_VALUE(fname, arg) \ ERROR_RETURN_CODE(GENERIC_ERROR, \ int caosdb_entity_create_##fname(caosdb_entity_value *out, arg), { \ - RETURN_ASSIGNEMENT_ERROR_IF_NON_NULL(out->wrapped_value) \ out->wrapped_value = new caosdb::entity::Value(value); \ out->_deletable = true; \ return 0; \ @@ -175,9 +169,6 @@ extern "C" { ERROR_RETURN_CODE( \ GENERIC_ERROR, \ int caosdb_entity_create_##fname(caosdb_entity_value *out, arg, const int length), { \ - if (out->wrapped_value) { \ - return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR; \ - } \ std::vector<type> value_vec; \ for (int i = 0; i < length; i++) { \ value_vec.push_back(assign); \ @@ -245,9 +236,6 @@ ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_connection_create_pem_file_certificate_provider( caosdb_connection_certificate_provider *out, const char *path), { - if (out->wrapped_certificate_provider) { - return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR; - } out->wrapped_certificate_provider = new caosdb::configuration::PemFileCertificateProvider(std::string(path)); out->_deletable = true; @@ -272,9 +260,6 @@ ERROR_RETURN_CODE(GENERIC_ERROR, caosdb_authentication_authenticator *out, const char *username, const char *password), { - if (out->wrapped_authenticator) { - return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR; - } out->wrapped_authenticator = new caosdb::authentication::PlainPasswordAuthenticator(std::string(username), std::string(password)); @@ -302,7 +287,6 @@ ERROR_RETURN_CODE( caosdb_authentication_authenticator *authenticator, caosdb_connection_certificate_provider *provider), { - RETURN_ASSIGNEMENT_ERROR_IF_NON_NULL(out->wrapped_connection_configuration) auto host_str = std::string(host); if (authenticator != nullptr && provider != nullptr) { auto wrapped_provider = static_cast<caosdb::configuration::CertificateProvider *>( @@ -334,9 +318,6 @@ ERROR_RETURN_CODE(GENERIC_ERROR, caosdb_connection_connection_configuration *out, const char *host, const int port), { - if (out->wrapped_connection_configuration) { - return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR; - } out->wrapped_connection_configuration = new caosdb::configuration::InsecureConnectionConfiguration(host, port); out->_deletable = true; @@ -362,9 +343,6 @@ ERROR_RETURN_CODE(GENERIC_ERROR, caosdb_connection_connection *out, const caosdb_connection_connection_configuration *configuration), { - if (out->wrapped_connection) { - return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR; - } caosdb::configuration::ConnectionConfiguration *config = static_cast<caosdb::configuration::ConnectionConfiguration *>( configuration->wrapped_connection_configuration); @@ -420,9 +398,6 @@ ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_connection_connection_manager_get_default_connection( caosdb_connection_connection *out), { - if (out->wrapped_connection) { - return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR; - } out->wrapped_connection = caosdb::connection::ConnectionManager::GetDefaultConnection().get(); out->_deletable = false; @@ -433,9 +408,6 @@ ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_connection_connection_manager_get_connection( caosdb_connection_connection *out, const char *name), { - if (out->wrapped_connection) { - return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR; - } out->wrapped_connection = caosdb::connection::ConnectionManager::GetConnection(std::string(name)).get(); // managed by the connection manager now, so not @@ -451,7 +423,6 @@ ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_connection_connection_create_transaction( caosdb_connection_connection *connection, caosdb_transaction_transaction *out), { - RETURN_ASSIGNEMENT_ERROR_IF_NON_NULL(out->wrapped_transaction) auto *wrapped_connection = static_cast<caosdb::connection::Connection *>(connection->wrapped_connection); out->wrapped_transaction = wrapped_connection->CreateTransaction().release(); @@ -556,7 +527,6 @@ ERROR_RETURN_CODE( int caosdb_transaction_transaction_get_result_set(caosdb_transaction_transaction *transaction, caosdb_transaction_result_set *out), { - RETURN_ASSIGNEMENT_ERROR_IF_NON_NULL(out->wrapped_result_set) auto *wrapped_transaction = static_cast<caosdb::transaction::Transaction *>(transaction->wrapped_transaction); out->wrapped_result_set = (void *)(&(wrapped_transaction->GetResultSet())); @@ -569,9 +539,6 @@ ERROR_RETURN_CODE( int caosdb_transaction_transaction_release_result_set(caosdb_transaction_transaction *transaction, caosdb_transaction_result_set *out), { - if (out->wrapped_result_set) { - return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR; - } auto *wrapped_transaction = static_cast<caosdb::transaction::Transaction *>(transaction->wrapped_transaction); out->wrapped_result_set = (void *)(wrapped_transaction->ReleaseResultSet()); @@ -617,9 +584,6 @@ ERROR_RETURN_CODE( int caosdb_transaction_result_set_release_at(caosdb_transaction_result_set *result_set, caosdb_entity_entity *entity, int index), { - if (entity->wrapped_entity) { - return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR; - } auto *wrapped_result_set = static_cast<caosdb::transaction::MultiResultSet *>(result_set->wrapped_result_set); entity->wrapped_entity = wrapped_result_set->release_at(index); @@ -640,9 +604,6 @@ ERROR_RETURN_CODE(GENERIC_ERROR, }) ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_create_entity(caosdb_entity_entity *out), { - if (out->wrapped_entity) { - return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR; - } out->wrapped_entity = new caosdb::entity::Entity(); out->_deletable = true; return 0; @@ -658,9 +619,6 @@ ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_delete_entity(caosdb_entity_e }) ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_create_property(caosdb_entity_property *out), { - if (out->wrapped_property) { - return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR; - } out->wrapped_property = new caosdb::entity::Property(); out->_deletable = true; return 0; @@ -676,9 +634,6 @@ ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_delete_property(caosdb_entity }) ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_create_parent(caosdb_entity_parent *out), { - if (out->wrapped_parent) { - return caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR; - } out->wrapped_parent = new caosdb::entity::Parent(); out->_deletable = true; return 0; @@ -697,7 +652,6 @@ ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_create_atomic_datatype(caosdb_entity_datatype *out, const char *name), { - RETURN_ASSIGNEMENT_ERROR_IF_NON_NULL(out->wrapped_datatype) try { auto enum_value = ENUM_VALUE_FROM_NAME(std::string(name), AtomicDataType); out->wrapped_datatype = new caosdb::entity::DataType(enum_value); @@ -712,7 +666,6 @@ ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_create_reference_datatype(caosdb_entity_datatype *out, const char *name), { - RETURN_ASSIGNEMENT_ERROR_IF_NON_NULL(out->wrapped_datatype) out->wrapped_datatype = new caosdb::entity::DataType(std::string(name)); out->_deletable = true; return 0; @@ -721,7 +674,6 @@ ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_create_atomic_list_datatype(caosdb_entity_datatype *out, const char *name), { - RETURN_ASSIGNEMENT_ERROR_IF_NON_NULL(out->wrapped_datatype) try { auto enum_value = ENUM_VALUE_FROM_NAME(std::string(name), AtomicDataType); out->wrapped_datatype = @@ -737,7 +689,6 @@ ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_create_reference_list_datatype(caosdb_entity_datatype *out, const char *name), { - RETURN_ASSIGNEMENT_ERROR_IF_NON_NULL(out->wrapped_datatype) out->wrapped_datatype = new caosdb::entity::DataType( caosdb::entity::DataType::ListOf(std::string(name))); out->_deletable = true; @@ -800,7 +751,6 @@ ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_entity_get_datatype(caosdb_entity_entity *entity, caosdb_entity_datatype *out), { - RETURN_ASSIGNEMENT_ERROR_IF_NON_NULL(out->wrapped_datatype) auto *wrapped_entity = WRAPPED_ENTITY_CAST(entity); out->wrapped_datatype = (void *)(&(wrapped_entity->GetDataType())); out->_deletable = false; @@ -810,7 +760,6 @@ ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_entity_get_value(caosdb_entity_entity *entity, caosdb_entity_value *out), { - RETURN_ASSIGNEMENT_ERROR_IF_NON_NULL(out->wrapped_value) auto *wrapped_entity = WRAPPED_ENTITY_CAST(entity); out->wrapped_value = (void *)(&(wrapped_entity->GetValue())); out->_deletable = false; @@ -833,7 +782,6 @@ ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_entity_get_error(caosdb_entity_entity *entity, caosdb_entity_message *out, int index), { - RETURN_ASSIGNEMENT_ERROR_IF_NON_NULL(out->wrapped_message) auto *wrapped_entity = static_cast<caosdb::entity::Entity *>(entity->wrapped_entity); out->wrapped_message = wrapped_entity->GetErrors().mutable_at(index); @@ -855,7 +803,6 @@ ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_entity_get_warning(caosdb_entity_entity *entity, caosdb_entity_message *out, int index), { - RETURN_ASSIGNEMENT_ERROR_IF_NON_NULL(out->wrapped_message) auto *wrapped_entity = static_cast<caosdb::entity::Entity *>(entity->wrapped_entity); out->wrapped_message = wrapped_entity->GetWarnings().mutable_at(index); @@ -875,7 +822,6 @@ ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_entity_get_info(caosdb_entity_entity *entity, caosdb_entity_message *out, int index), { - RETURN_ASSIGNEMENT_ERROR_IF_NON_NULL(out->wrapped_message) auto *wrapped_entity = static_cast<caosdb::entity::Entity *>(entity->wrapped_entity); out->wrapped_message = wrapped_entity->GetInfos().mutable_at(index); @@ -897,7 +843,6 @@ ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_entity_get_property(caosdb_entity_entity *entity, caosdb_entity_property *out, int index), { - RETURN_ASSIGNEMENT_ERROR_IF_NON_NULL(out->wrapped_property) auto *wrapped_entity = static_cast<caosdb::entity::Entity *>(entity->wrapped_entity); out->wrapped_property = wrapped_entity->GetProperties().mutable_at(index); @@ -918,7 +863,6 @@ ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_entity_get_parent(caosdb_entity_entity *entity, caosdb_entity_parent *out, int index), { - RETURN_ASSIGNEMENT_ERROR_IF_NON_NULL(out->wrapped_parent) auto *wrapped_entity = static_cast<caosdb::entity::Entity *>(entity->wrapped_entity); out->wrapped_parent = wrapped_entity->GetParents().mutable_at(index); @@ -951,7 +895,6 @@ ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_property_get_datatype(caosdb_entity_property *property, caosdb_entity_datatype *out), { - RETURN_ASSIGNEMENT_ERROR_IF_NON_NULL(out->wrapped_datatype) auto *wrapped_property = WRAPPED_PROPERTY_CAST(property); out->wrapped_datatype = (void *)(&(wrapped_property->GetDataType())); out->_deletable = false; @@ -961,7 +904,6 @@ ERROR_RETURN_CODE(GENERIC_ERROR, int caosdb_entity_property_get_value(caosdb_entity_property *property, caosdb_entity_value *out), { - RETURN_ASSIGNEMENT_ERROR_IF_NON_NULL(out->wrapped_value) auto *wrapped_property = WRAPPED_PROPERTY_CAST(property); out->wrapped_value = (void *)(&(wrapped_property->GetValue())); out->_deletable = false; @@ -1089,7 +1031,6 @@ ERROR_RETURN_CODE(GENERIC_ERROR, caosdb_entity_value *out, const int index), { - RETURN_ASSIGNEMENT_ERROR_IF_NON_NULL(out->wrapped_value) auto *wrapped_value = WRAPPED_VALUE_CAST(value); out->wrapped_value = (void *)(&(wrapped_value->GetAsVector().at(index))); out->_deletable = false; diff --git a/src/cxxcaosdbcli.cpp b/src/cxxcaosdbcli.cpp index c0c423498a90fd53330797fbccbf4c058de66688..e6e5cee66e6c90ab7719434d7667cd6ad20ccbb8 100644 --- a/src/cxxcaosdbcli.cpp +++ b/src/cxxcaosdbcli.cpp @@ -21,16 +21,23 @@ */ // A simple caosdb client -#include "caosdb/connection.h" // for Connection, ConnectionManager -#include "caosdb/constants.h" // for LIBCAOSDB_VERSION_MINOR, LIBCAOSDB_V... -#include "caosdb/entity.h" // for Entity -#include "caosdb/exceptions.h" // for ConfigurationError -#include "caosdb/info.h" // for VersionInfo -#include "caosdb/logging.h" // for CAOSDB_LOG_TRACE -#include "caosdb/transaction.h" // for Transaction, ResultSet -#include <iostream> // for operator<<, basic_ostream, basic_ost... -#include <memory> // for unique_ptr, allocator, __shared_ptr_... -#include <string> // for operator<<, char_traits +#include "caosdb/connection.h" // for Connection, ConnectionManager +#include "caosdb/constants.h" // for LIBCAOSDB_VERSION_MINOR, LIBCAOSDB_V... +#include "caosdb/entity.h" // for Entity +#include "caosdb/exceptions.h" // for ConfigurationError +#include "caosdb/info.h" // for VersionInfo +#include "caosdb/logging.h" // for CAOSDB_LOG_TRACE +#include "caosdb/transaction.h" // for Transaction, ResultSet +#include "caosdb/transaction_status.h" // for TransactionSt... +#include <boost/log/core/record.hpp> // for record +#include <boost/log/detail/attachable_sstream_buf.hpp> // for basic_ostring... +#include <boost/log/sources/record_ostream.hpp> // for operator<< +#include <boost/preprocessor/seq/limits/enum_256.hpp> // for BOOST_PP_SEQ_... +#include <boost/preprocessor/seq/limits/size_256.hpp> // for BOOST_PP_SEQ_... +#include <exception> // for exception +#include <iostream> // for operator<<, basic_ostream, basic_ost... +#include <memory> // for unique_ptr, allocator, __shared_ptr_... +#include <string> // for operator<<, char_traits const auto logger_name = "libcaosdb"; diff --git a/test/test_ccaosdb.cpp b/test/test_ccaosdb.cpp index 1059f161525d513389efd4df95cdd04ec5a088db..71c2a829316b5b5418702686c6ea0fdfa48e5198 100644 --- a/test/test_ccaosdb.cpp +++ b/test/test_ccaosdb.cpp @@ -386,8 +386,8 @@ TEST_F(test_ccaosdb, test_entity) { EXPECT_EQ(return_code, 0); // cannot be created again without deletion - return_code = caosdb_entity_create_entity(&entity); - EXPECT_EQ(return_code, caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR); + // return_code = caosdb_entity_create_entity(&entity); + // EXPECT_EQ(return_code, caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR); // deletion and re-creation is ok return_code = caosdb_entity_delete_entity(&entity); @@ -431,8 +431,8 @@ TEST_F(test_ccaosdb, test_entity) { caosdb_entity_entity_set_datatype(&entity, &in_type); // verify that this doesn't work ... - return_code = caosdb_entity_entity_get_datatype(&entity, &in_type); - EXPECT_EQ(return_code, caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR); + // return_code = caosdb_entity_entity_get_datatype(&entity, &in_type); + // EXPECT_EQ(return_code, caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR); caosdb_entity_datatype out_type; // ... but does with a clean property return_code = caosdb_entity_entity_get_datatype(&entity, &out_type); @@ -827,8 +827,8 @@ TEST_F(test_ccaosdb, test_entity_with_parent_and_property) { char *out = nullptr; // NOLINT // cannot assign an already assigned property - return_code = caosdb_entity_entity_get_property(&entity, &input_property, 0); - EXPECT_EQ(return_code, caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR); + // return_code = caosdb_entity_entity_get_property(&entity, &input_property, 0); + // EXPECT_EQ(return_code, caosdb::StatusCode::EXTERN_C_ASSIGNMENT_ERROR); caosdb_entity_property output_property; return_code = caosdb_entity_entity_get_property(&entity, &output_property, 0); EXPECT_EQ(return_code, 0); diff --git a/test/test_file_transmission.cpp b/test/test_file_transmission.cpp index 7903c917f62187b86f9162c6b2f59220e11837b6..c5847a0842ae8a3bb46a8126e42b31bb5b1d6451 100644 --- a/test/test_file_transmission.cpp +++ b/test/test_file_transmission.cpp @@ -19,6 +19,7 @@ */ #include "caosdb/file_transmission/file_writer.h" #include "caosdb/file_transmission/file_reader.h" +#include <chrono> // for filesystem #include <filesystem> // for path #include <gtest/gtest-message.h> // for Message #include <gtest/gtest-test-part.h> // for TestPartResult, SuiteApiResolver diff --git a/test/test_transaction.cpp b/test/test_transaction.cpp index 535f7587aca4ef4e2b44225b5db8eef9ebdc8fd6..ef72ac93491c0d120a5b9a4478e60a0296b4b360 100644 --- a/test/test_transaction.cpp +++ b/test/test_transaction.cpp @@ -27,6 +27,7 @@ #include "caosdb/transaction_handler.h" // for MultiTransactionResponse #include "caosdb/transaction_status.h" // for ConnectionError #include "caosdb_test_utility.h" // for EXPECT_THROW_MESSAGE +#include <algorithm> // for max #include <gtest/gtest-message.h> // for Message #include <gtest/gtest-test-part.h> // for SuiteApiResolver, TestPa... #include <gtest/gtest_pred_impl.h> // for Test, TestInfo, TEST diff --git a/test_package/conanfile.py b/test_package/conanfile.py index a003a6b0b97b32b30632b12fb4659a086cf36ddf..541113405bfca3b1222de81124a13586fe4bbda5 100644 --- a/test_package/conanfile.py +++ b/test_package/conanfile.py @@ -6,6 +6,9 @@ from conans import ConanFile, CMake, tools class LibcaosdbTestConan(ConanFile): settings = "os", "compiler", "build_type", "arch" generators = "cmake" + build_requires = [ + ("gtest/1.11.0"), + ] def build(self): cmake = CMake(self)