Skip to content
Snippets Groups Projects
Verified Commit 7bca36c6 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

Merge branch 'f-error-handling' into f-insert

parents 2baf5bfc bae8f8ac
No related branches found
No related tags found
1 merge request!4ENH: Allow insertion and deletion of single entities
Pipeline #10881 passed
Pipeline: caosdb-cppinttest

#10884

    ...@@ -41,6 +41,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) ...@@ -41,6 +41,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
    set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
    IF (WIN32)
    set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
    ENDIF()
    ########################################### ###########################################
    ### DEPENDENCY MANAGEMENT with CONAN ### DEPENDENCY MANAGEMENT with CONAN
    ########################################### ###########################################
    ...@@ -79,8 +83,13 @@ set(PROTO_FILES ...@@ -79,8 +83,13 @@ set(PROTO_FILES
    set(PROTO_PATH ${PROJECT_SOURCE_DIR}/proto/proto) set(PROTO_PATH ${PROJECT_SOURCE_DIR}/proto/proto)
    # compiler binaries # compiler binaries
    set(_PROTOBUF_PROTOC "${CMAKE_BINARY_DIR}/build_tools/protoc") IF (WIN32)
    set(_GRPC_CPP_PLUGIN_EXECUTABLE "${CMAKE_BINARY_DIR}/build_tools/grpc_cpp_plugin") set(_PROTOBUF_PROTOC "${CMAKE_BINARY_DIR}/build_tools/protoc.exe")
    set(_GRPC_CPP_PLUGIN_EXECUTABLE "${CMAKE_BINARY_DIR}/build_tools/grpc_cpp_plugin.exe")
    ELSE()
    set(_PROTOBUF_PROTOC "${CMAKE_BINARY_DIR}/build_tools/protoc")
    set(_GRPC_CPP_PLUGIN_EXECUTABLE "${CMAKE_BINARY_DIR}/build_tools/grpc_cpp_plugin")
    ENDIF()
    # Generated sources # Generated sources
    list(LENGTH PROTO_FILES len_proto_files) list(LENGTH PROTO_FILES len_proto_files)
    ...@@ -248,6 +257,7 @@ if(_LINTING) ...@@ -248,6 +257,7 @@ if(_LINTING)
    add_compiler_flag("-pedantic") add_compiler_flag("-pedantic")
    add_compiler_flag("-Werror") add_compiler_flag("-Werror")
    message(STATUS "PEDANTIC_CMAKE_CXX_FLAGS: [${PEDANTIC_CMAKE_CXX_FLAGS}]")
    set(TARGET_CAOSDB_COMPILE_FLAGS "${TARGET_CAOSDB_COMPILE_FLAGS} ${PEDANTIC_CMAKE_CXX_FLAGS}") set(TARGET_CAOSDB_COMPILE_FLAGS "${TARGET_CAOSDB_COMPILE_FLAGS} ${PEDANTIC_CMAKE_CXX_FLAGS}")
    set(TARGET_CCAOSDB_COMPILE_FLAGS "${TARGET_CCAOSDB_COMPILE_FLAGS} ${PEDANTIC_CMAKE_C_FLAGS}") set(TARGET_CCAOSDB_COMPILE_FLAGS "${TARGET_CCAOSDB_COMPILE_FLAGS} ${PEDANTIC_CMAKE_C_FLAGS}")
    set(TARGET_CXXCAOSDBCLI_COMPILE_FLAGS "${TARGET_CXXCAOSDBCLI_COMPILE_FLAGS} ${PEDANTIC_CMAKE_CXX_FLAGS}") set(TARGET_CXXCAOSDBCLI_COMPILE_FLAGS "${TARGET_CXXCAOSDBCLI_COMPILE_FLAGS} ${PEDANTIC_CMAKE_CXX_FLAGS}")
    ......
    ...@@ -34,6 +34,20 @@ have to add `build/lib/` (or, alternatively after installation, ...@@ -34,6 +34,20 @@ have to add `build/lib/` (or, alternatively after installation,
    `CMAKE_INSTALL_PREFIX/lib`) to your `DYLD_LIBRARY_PATH` environmental `CMAKE_INSTALL_PREFIX/lib`) to your `DYLD_LIBRARY_PATH` environmental
    variable. variable.
    ### How to build on Windows
    We use [Visual Studio 2019](https://visualstudio.microsoft.com/de/vs/features/cplusplus/)
    as compiler. We use [cmake](https://cmake.org/download/) as build tool.
    0. clone/update the subrepo `git submodule update --init proto`
    1. `mkdir build`
    2. `cd build`
    3. `conan install .. -g visual_studio -s arch=x86_64 -s build_type=Release -s compiler.toolset=v142 -s compiler.version=16 -s compiler.runtime=MD --build=missing --update`
    4. `cmake -B . ..`
    5. open ` libcaosdb.sln` with Visual Studio, change the buildtype to `Release`
    and build the project. (You can open Tools/Command Line/Developer Command
    Prompt and execute `msbuild libcaosdb.sln /property:Configuration=Release`)
    ## Creating a Local Conan Build ## ## Creating a Local Conan Build ##
    Building and installing libcaosdb with Conan is just a single command: Building and installing libcaosdb with Conan is just a single command:
    ......
    ...@@ -28,7 +28,7 @@ class CaosdbConan(ConanFile): ...@@ -28,7 +28,7 @@ class CaosdbConan(ConanFile):
    def imports(self): def imports(self):
    self.copy("protoc*", "build_tools", "bin") self.copy("protoc*", "build_tools", "bin")
    self.copy("grpc_cpp_plugin", "build_tools", "bin") self.copy("grpc_cpp_plugin*", "build_tools", "bin")
    def build(self): def build(self):
    cmake = CMake(self) cmake = CMake(self)
    ......
    ...@@ -228,6 +228,7 @@ public: ...@@ -228,6 +228,7 @@ public:
    return out; return out;
    } }
    auto SetRole(const std::string &role) -> void;
    auto SetId(const std::string &id) -> void; auto SetId(const std::string &id) -> void;
    auto SetName(const std::string &name) -> void; auto SetName(const std::string &name) -> void;
    auto SetVersionId(const std::string &id) -> void; auto SetVersionId(const std::string &id) -> void;
    ......
    ...@@ -19,29 +19,30 @@ ...@@ -19,29 +19,30 @@
    * *
    */ */
    #include "caosdb/configuration.h" #include "caosdb/configuration.h"
    #include "boost/iterator/iterator_facade.hpp" // for iterator_facad... #include "boost/iterator/iterator_facade.hpp" // for iterator_facad...
    #include "boost/json/impl/object.hpp" // for object::at #include "boost/json/impl/object.hpp" // for object::at
    #include "boost/json/string.hpp" // for string #include "boost/json/string.hpp" // for string
    #include "boost/json/string_view.hpp" // for string_view #include "boost/json/string_view.hpp" // for string_view
    #include "boost/log/core/record.hpp" // for record #include "boost/log/core/record.hpp" // for record
    #include "boost/log/sources/record_ostream.hpp" // for basic_record_o... #include "boost/log/detail/attachable_sstream_buf.hpp" // for basic_ostring...
    #include "boost/preprocessor/seq/limits/enum_256.hpp" // for BOOST_PP_SEQ_E... #include "boost/log/sources/record_ostream.hpp" // for basic_record_o...
    #include "boost/preprocessor/seq/limits/size_256.hpp" // for BOOST_PP_SEQ_S... #include "boost/preprocessor/seq/limits/enum_256.hpp" // for BOOST_PP_SEQ_E...
    #include "caosdb/authentication.h" // for Authenticator #include "boost/preprocessor/seq/limits/size_256.hpp" // for BOOST_PP_SEQ_S...
    #include "caosdb/connection.h" // for ConnectionManager #include "caosdb/authentication.h" // for Authenticator
    #include "caosdb/constants.h" // for LIBCAOSDB_CONF... #include "caosdb/connection.h" // for ConnectionManager
    #include "caosdb/exceptions.h" // for ConfigurationE... #include "caosdb/constants.h" // for LIBCAOSDB_CONF...
    #include "caosdb/log_level.h" // for CAOSDB_DEFAULT... #include "caosdb/exceptions.h" // for ConfigurationE...
    #include "caosdb/status_code.h" // for StatusCode #include "caosdb/log_level.h" // for CAOSDB_DEFAULT...
    #include "caosdb/utility.h" // for get_home_direc... #include "caosdb/status_code.h" // for StatusCode
    #include <bits/exception.h> // for exception #include "caosdb/utility.h" // for get_home_direc...
    #include <cassert> // for assert #include <bits/exception.h> // for exception
    #include <cstdlib> // for getenv #include <cassert> // for assert
    #include <grpcpp/security/credentials.h> // for SslCredentials #include <cstdlib> // for getenv
    #include <iterator> // for next #include <grpcpp/security/credentials.h> // for SslCredentials
    #include <map> // for map #include <iterator> // for next
    #include <stdexcept> // for out_of_range #include <map> // for map
    #include <string> // for string, operator+ #include <stdexcept> // for out_of_range
    #include <string> // for string, operator+
    namespace caosdb::configuration { namespace caosdb::configuration {
    using boost::filesystem::exists; using boost::filesystem::exists;
    ...@@ -506,7 +507,7 @@ auto ConfigurationManager::InitializeDefaults() -> int { ...@@ -506,7 +507,7 @@ auto ConfigurationManager::InitializeDefaults() -> int {
    if (configuration_file_path != nullptr) { if (configuration_file_path != nullptr) {
    mLoadSingleJSONConfiguration(*configuration_file_path); mLoadSingleJSONConfiguration(*configuration_file_path);
    CAOSDB_LOG_INFO(logger_name) CAOSDB_LOG_INFO(logger_name)
    << "Loaded configuration from" << configuration_file_path << "."; << "Loaded configuration from" << *(configuration_file_path.get()) << ".";
    } }
    if (this->json_configuration.is_object() && if (this->json_configuration.is_object() &&
    ......
    ...@@ -94,4 +94,12 @@ auto Entity::Switch(ProtoEntity *entity) -> void { ...@@ -94,4 +94,12 @@ auto Entity::Switch(ProtoEntity *entity) -> void {
    this->wrapped = entity; this->wrapped = entity;
    } }
    auto Entity::SetRole(const std::string &role) -> void {
    this->wrapped->set_role(role);
    }
    auto Entity::SetName(const std::string &name) -> void {
    this->wrapped->set_name(name);
    }
    } // namespace caosdb::entity } // namespace caosdb::entity
    ...@@ -84,6 +84,7 @@ include(CodeCoverage) ...@@ -84,6 +84,7 @@ include(CodeCoverage)
    if (LCOV_PATH) if (LCOV_PATH)
    message(STATUS "Found LCOV: ${LCOV_PATH}") message(STATUS "Found LCOV: ${LCOV_PATH}")
    target_link_libraries(caosdb gcov) target_link_libraries(caosdb gcov)
    target_link_libraries(ccaosdb gcov)
    setup_target_for_coverage_lcov( setup_target_for_coverage_lcov(
    NAME unit_test_coverage NAME unit_test_coverage
    EXECUTABLE ctest -L caosdb-cpplib-unit-tests EXECUTABLE ctest -L caosdb-cpplib-unit-tests
    ...@@ -93,11 +94,13 @@ if (LCOV_PATH) ...@@ -93,11 +94,13 @@ if (LCOV_PATH)
    GENHTML_ARGS --rc lcov_branch_coverage=1 GENHTML_ARGS --rc lcov_branch_coverage=1
    ) )
    message(STATUS "Adding COMPILE_FLAGS for coverage: ${COVERAGE_COMPILER_FLAGS}") message(STATUS "Adding COMPILE_FLAGS for coverage: ${COVERAGE_COMPILER_FLAGS}")
    set(TARGET_CAOSDB_COMPILE_FLAGS "${TARGET_CAOSDB_COMPILE_FLAGS} ${COVERAGE_COMPILER_FLAGS}" PARENT_SCOPE) set(TARGET_CAOSDB_COMPILE_FLAGS "${TARGET_CAOSDB_COMPILE_FLAGS} ${COVERAGE_COMPILER_FLAGS}")
    set(TARGET_CCAOSDB_COMPILE_FLAGS "${TARGET_CCAOSDB_COMPILE_FLAGS} ${COVERAGE_COMPILER_FLAGS}" PARENT_SCOPE) set(TARGET_CCAOSDB_COMPILE_FLAGS "${TARGET_CCAOSDB_COMPILE_FLAGS} ${COVERAGE_COMPILER_FLAGS}")
    set(TARGET_CAOSDB_COMPILE_FLAGS ${TARGET_CAOSDB_COMPILE_FLAGS} PARENT_SCOPE)
    set(TARGET_CCAOSDB_COMPILE_FLAGS ${TARGET_CCAOSDB_COMPILE_FLAGS} PARENT_SCOPE)
    set_target_properties(caosdb PROPERTIES set_target_properties(caosdb PROPERTIES
    COMPILE_FLAGS "${TARGET_CAOSDB_COMPILE_FLAGS}") COMPILE_FLAGS "${TARGET_CAOSDB_COMPILE_FLAGS}")
    set_target_properties(caosdb PROPERTIES set_target_properties(ccaosdb PROPERTIES
    COMPILE_FLAGS "${TARGET_CCAOSDB_COMPILE_FLAGS}") COMPILE_FLAGS "${TARGET_CCAOSDB_COMPILE_FLAGS}")
    else () else ()
    message(WARNING "Could not generate code coverage report. Please install lcov.") message(WARNING "Could not generate code coverage report. Please install lcov.")
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment