diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a70cb28277060f30a0a030ddbf31f1511513374..840f85ea539a18059906cc6a439c200f568317ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ cmake_minimum_required(VERSION 3.14) -set(libcaosdb_VERSION 0.0.6) +set(libcaosdb_VERSION 0.0.7) set(libcaosdb_COMPATIBLE_SERVER_VERSION_MAJOR 0) set(libcaosdb_COMPATIBLE_SERVER_VERSION_MINOR 5) set(libcaosdb_COMPATIBLE_SERVER_VERSION_PATCH 0) @@ -31,7 +31,7 @@ project(libcaosdb DESCRIPTION "C and C++ client libraries for CaosDB" LANGUAGES CXX C) -set(CMAKE_C_STANDARD 99) +set(CMAKE_C_STANDARD 11) set(CMAKE_CXX_STANDARD 17) set(CMAKE_C_EXTENSIONS OFF) diff --git a/conanfile.py b/conanfile.py index 4ae59d5c79392e6cacc26e6dbfe2306010be3c0e..cba22bb4f2f39da55b5b0fb6ab46ab7e37511912 100644 --- a/conanfile.py +++ b/conanfile.py @@ -3,7 +3,7 @@ from conans import ConanFile, CMake, tools class CaosdbConan(ConanFile): name = "caosdb" - version = "0.0.6" + version = "0.0.7" license = "AGPL-3.0-or-later" author = "Timm C. Fitschen <t.fitschen@indiscale.com>" url = "https://gitlab.indiscale.com/caosdb/src/caosdb-cpplib.git" diff --git a/include/caosdb/transaction.h b/include/caosdb/transaction.h index 4e4fb2a76a0b4fb65824d1c2e54843062d382aef..106e0d5fff92d6da3df9d3dd19ad7f05377d9235 100644 --- a/include/caosdb/transaction.h +++ b/include/caosdb/transaction.h @@ -35,7 +35,7 @@ namespace caosdb::transaction { using caosdb::entity::Entity; using ProtoEntity = caosdb::entity::v1alpha1::Entity; using caosdb::entity::v1alpha1::EntityTransactionService; -using caosdb::entity::v1alpha1::RetrieveRequest; +using caosdb::entity::v1alpha1::SingleRetrieveRequest; using caosdb::transaction::TransactionStatus; class ResultSet { @@ -62,7 +62,7 @@ private: std::unique_ptr<ResultSet> result_set; TransactionStatus status = TransactionStatus::INITIAL(); std::shared_ptr<EntityTransactionService::Stub> service_stub; - RetrieveRequest request; // TODO(tf) + SingleRetrieveRequest request; // TODO(tf) std::string error_message; public: diff --git a/proto b/proto index 4845aa8e479b85b50a130530bbc96a0cab4f8688..72306a73676e6880a7164108ab0ab17b8978f7e1 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 4845aa8e479b85b50a130530bbc96a0cab4f8688 +Subproject commit 72306a73676e6880a7164108ab0ab17b8978f7e1 diff --git a/src/caosdb/transaction.cpp b/src/caosdb/transaction.cpp index 94156745554790ad157d446609865b0e59aafb31..302eb48e6e691b432aa58ae69e617a2d45eaaca9 100644 --- a/src/caosdb/transaction.cpp +++ b/src/caosdb/transaction.cpp @@ -19,7 +19,8 @@ */ #include "caosdb/transaction.h" #include "caosdb/entity/v1alpha1/main.grpc.pb.h" // for EntityTransactionS... -#include "caosdb/entity/v1alpha1/main.pb.h" // for RetrieveRequest +#include "caosdb/entity/v1alpha1/main.pb.h" // for SingleRetrieveRequest +#include "caosdb/status_code.h" // for StatusCode, AUTHEN... #include "grpcpp/grpcpp.h" // for CompletionQueue #include "grpcpp/impl/codegen/async_unary_call.h" // for ClientAsyncRespons... #include "grpcpp/impl/codegen/client_context.h" // for ClientContext @@ -27,7 +28,9 @@ #include "grpcpp/impl/codegen/status.h" // for Status #include "grpcpp/impl/codegen/status_code_enum.h" // for StatusCode, UNAUTH... #include <cassert> // for assert +#include <map> // for map #include <memory> // for allocator, unique_ptr +#include <stdexcept> // for out_of_range #include <utility> // for move namespace caosdb { @@ -68,8 +71,8 @@ auto get_status_description(int code) -> const std::string & { namespace caosdb::transaction { using caosdb::entity::v1alpha1::EntityTransactionService; -using caosdb::entity::v1alpha1::RetrieveRequest; -using caosdb::entity::v1alpha1::RetrieveResponse; +using caosdb::entity::v1alpha1::SingleRetrieveRequest; +using caosdb::entity::v1alpha1::SingleRetrieveResponse; using grpc::ClientAsyncResponseReader; using ProtoEntity = caosdb::entity::v1alpha1::Entity; using grpc::CompletionQueue; @@ -85,9 +88,9 @@ Transaction::Transaction( } auto Transaction::RetrieveById(const std::string &id) -> void { - RetrieveRequest request; + SingleRetrieveRequest request; // this copies the id, so we're safe. - request.mutable_by_id()->set_id(id); + request.mutable_retrieve_request()->set_id(id); this->request = request; } @@ -103,11 +106,12 @@ auto Transaction::ExecuteAsynchronously() noexcept -> void { grpc::Status grpc_status; CompletionQueue cq; - RetrieveResponse response; + SingleRetrieveResponse response; grpc::ClientContext context; - std::unique_ptr<ClientAsyncResponseReader<RetrieveResponse>> rpc( - this->service_stub->PrepareAsyncRetrieve(&context, this->request, &cq)); + std::unique_ptr<ClientAsyncResponseReader<SingleRetrieveResponse>> rpc( + this->service_stub->PrepareAsyncSingleRetrieve(&context, this->request, + &cq)); rpc->StartCall(); int tag = 1; @@ -121,9 +125,6 @@ auto Transaction::ExecuteAsynchronously() noexcept -> void { assert(recv_tag == send_tag); assert(ok); - // const grpc::Status grpc_status = - // this->service_stub->Retrieve(&context, this->request, &response); - if (!grpc_status.ok()) { switch (grpc_status.error_code()) { case grpc::StatusCode::UNAUTHENTICATED: @@ -141,7 +142,7 @@ auto Transaction::ExecuteAsynchronously() noexcept -> void { this->status = TransactionStatus::SUCCESS(); } - auto *entity = response.release_entity(); + auto *entity = response.mutable_retrieve_response()->release_entity(); this->result_set = std::make_unique<UniqueResult>(entity); }