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

Moved around some code

parent 14a14b11
No related branches found
No related tags found
1 merge request!5F multi retrieve
Pipeline #11414 passed
Pipeline: caosdb-cppinttest

#11416

    This commit is part of merge request !5. Comments created here will be created in the context of that merge request.
    ......@@ -299,7 +299,7 @@ if(_LINTING)
    else()
    message(STATUS "clang-tidy: ${clang_tidy}")
    set(_CMAKE_CXX_CLANG_TIDY_CHECKS
    "--checks=*,-fuchsia-*,-llvmlibc-*,-readability-convert-member-functions-to-static,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-hicpp-no-array-decay,-llvm-else-after-return,-readability-else-after-return,-modernize-use-trailing-return-type")
    "--checks=*,-fuchsia-*,-llvmlibc-*,-readability-convert-member-functions-to-static,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-hicpp-no-array-decay,-llvm-else-after-return,-readability-else-after-return,-modernize-use-trailing-return-type,-bugprone-branch-clone")
    set(_CMAKE_C_CLANG_TIDY_CHECKS "${_CMAKE_CXX_CLANG_TIDY_CHECKS}")
    set(_CMAKE_CXX_CLANG_TIDY "${clang_tidy}"
    "--header-filter=caosdb/.*[^\(\.pb\.h\)]$"
    ......
    ......@@ -33,6 +33,7 @@
    #include "google/protobuf/util/json_util.h" // for MessageToJsonString, Jso...
    #include <stdexcept>
    #include <iterator>
    // IWYU pragma: no_include <ext/alloc_traits.h>
    #include <memory> // for shared_ptr, unique_ptr
    #include <string> // for string
    #include <vector> // for vector
    ......@@ -119,6 +120,8 @@ using caosdb::transaction::TransactionStatus;
    using WrappedResponseCase =
    caosdb::entity::v1alpha1::TransactionResponse::WrappedResponseCase;
    class Transaction;
    static const std::string logger_name = "caosdb::transaction";
    class ResultSet {
    ......@@ -131,31 +134,7 @@ public:
    class MultiResultSet : public ResultSet {
    public:
    ~MultiResultSet() = default;
    explicit inline MultiResultSet(MultiTransactionResponse *response) {
    auto responses = response->mutable_responses();
    Entity *entity = nullptr;
    for (auto sub_response : *responses) {
    switch (sub_response.wrapped_response_case()) {
    case WrappedResponseCase::kRetrieveResponse:
    entity = new Entity(
    sub_response.mutable_retrieve_response()->release_entity());
    break;
    case WrappedResponseCase::kInsertResponse:
    entity = new Entity(sub_response.release_insert_response());
    break;
    case WrappedResponseCase::kDeleteResponse:
    entity = new Entity(sub_response.release_delete_response());
    break;
    default:
    // TODO(tf) Updates
    break;
    }
    if (entity) {
    this->entities.push_back(std::unique_ptr<Entity>(entity));
    }
    }
    }
    explicit MultiResultSet(MultiTransactionResponse *response);
    [[nodiscard]] inline auto Size() const noexcept -> int override {
    return this->entities.size();
    }
    ......
    ......@@ -39,11 +39,12 @@
    #include <cstdlib> // for getenv
    #include <cstring> // for strcmp
    #include <exception> // IWYU pragma: keep
    #include <grpcpp/security/credentials.h> // for SslCredentials
    #include <iterator> // for next
    #include <map> // for map
    #include <stdexcept> // for out_of_range
    #include <string> // for string, operator+
    // IWYU pragma: no_include <bits/exception.h>
    #include <grpcpp/security/credentials.h> // for SslCredentials
    #include <iterator> // for next
    #include <map> // for map
    #include <stdexcept> // for out_of_range
    #include <string> // for string, operator+
    namespace caosdb::configuration {
    using boost::filesystem::exists;
    ......
    ......@@ -90,6 +90,29 @@ using grpc::ClientAsyncResponseReader;
    using ProtoEntity = caosdb::entity::v1alpha1::Entity;
    using grpc::CompletionQueue;
    MultiResultSet::MultiResultSet(MultiTransactionResponse *response) {
    auto *responses = response->mutable_responses();
    for (auto sub_response : *responses) {
    switch (sub_response.wrapped_response_case()) {
    case WrappedResponseCase::kRetrieveResponse:
    this->entities.push_back(std::make_unique<Entity>(
    sub_response.mutable_retrieve_response()->release_entity()));
    break;
    case WrappedResponseCase::kInsertResponse:
    this->entities.push_back(
    std::make_unique<Entity>(sub_response.release_insert_response()));
    break;
    case WrappedResponseCase::kDeleteResponse:
    this->entities.push_back(
    std::make_unique<Entity>(sub_response.release_insert_response()));
    break;
    default:
    // TODO(tf) Updates
    break;
    }
    }
    }
    [[nodiscard]] auto UniqueResult::GetEntity() const -> const Entity & {
    const Entity *result = this->entity.get();
    return *result;
    ......@@ -239,7 +262,7 @@ auto Transaction::WaitForIt() const noexcept -> TransactionStatus {
    this->result_set = std::make_unique<UniqueResult>(deletedIdResponse);
    } break;
    default:
    // TODO(tf)
    // TODO(tf) Error and Update
    break;
    }
    } else {
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment