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

fix test clients

parent dba650f6
No related branches found
No related tags found
2 merge requests!33Release 0.1,!32fix windows build
Pipeline #15924 failed
This commit is part of merge request !33. Comments created here will be created in the context of that merge request.
......@@ -39,7 +39,7 @@ 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_LIBS "Build using shared libraries" 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})
......@@ -51,14 +51,6 @@ IF (WIN32)
cmake_minimum_required(VERSION 3.15)
cmake_policy(SET CMP0091 NEW)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded")
if("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
set(CMAKE_MSVC_RUNTIME_LIBRARY "${CMAKE_MSVC_RUNTIME_LIBRARY}Debug")
endif()
if(BUILD_SHARED_LIBS)
set(CMAKE_MSVC_RUNTIME_LIBRARY "${CMAKE_MSVC_RUNTIME_LIBRARY}DLL")
endif()
message(STATUS "CMAKE_MSVC_RUNTIME_LIBRARY=${CMAKE_MSVC_RUNTIME_LIBRARY}")
ENDIF()
###########################################
......@@ -177,11 +169,16 @@ if("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
$<INSTALL_INTERFACE:include>
)
set_target_properties(caosdb_grpc PROPERTIES
COMPILE_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
else()
add_library(caosdb
${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}
)
......@@ -194,30 +191,21 @@ target_include_directories(caosdb PUBLIC
$<INSTALL_INTERFACE:include>
)
###################################################
# ccaosdb - A C-Wrapper of the C++ caosdb library
###################################################
add_library(ccaosdb SHARED src/ccaosdb.cpp)
IF (WIN32)
set_target_properties(caosdb PROPERTIES
LINK_FLAGS "/WHOLEARCHIVE"
)
target_link_libraries(ccaosdb
${LIBCAOSDB}
${CONAN_LIBS}
)
ELSE()
set_target_properties(caosdb PROPERTIES
COMPILE_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
target_link_libraries(ccaosdb
"-Wl,--whole-archive"
${LIBCAOSDB}
"-Wl,--no-whole-archive"
${CONAN_LIBS}
)
ENDIF()
######################################
# ccaosdbcli - A plain C test client.
######################################
add_executable(ccaosdbcli EXCLUDE_FROM_ALL src/ccaosdbcli.c)
target_include_directories(ccaosdbcli SYSTEM PUBLIC
${CONAN_INCLUDE_DIRS}
)
target_include_directories(ccaosdbcli PUBLIC
$<BUILD_INTERFACE:${libcaosdb_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${libcaosdb_BINARY_DIR}/include>
......@@ -228,6 +216,10 @@ target_link_libraries(ccaosdbcli
${CONAN_LIBS}
)
######################################
# cxxcaosdbcli - A C++ test client.
######################################
add_executable(cxxcaosdbcli EXCLUDE_FROM_ALL src/cxxcaosdbcli.cpp)
target_include_directories(cxxcaosdbcli SYSTEM PUBLIC
${CONAN_INCLUDE_DIRS}
......
......@@ -20,10 +20,12 @@
*
*/
#include <cstdint> // for int64_t
#ifdef __cplusplus
#include <cstdint> // for int64_t
extern "C" {
#else
#include <stdint.h> // for int64_t
#include <stdbool.h> // for bool
#endif
/**
......@@ -70,7 +72,7 @@ int caosdb_status_code_OTHER_CLIENT_ERROR();
*/
typedef struct caosdb_connection_connection {
void *wrapped_connection;
bool _deletable = false;
bool _deletable;
} caosdb_connection_connection;
/**
......@@ -82,7 +84,7 @@ typedef struct caosdb_connection_connection {
*/
typedef struct caosdb_connection_connection_configuration {
void *wrapped_connection_configuration;
bool _deletable = false;
bool _deletable;
} caosdb_connection_connection_configuration;
/**
......@@ -102,12 +104,12 @@ typedef struct caosdb_info_version_info {
typedef struct caosdb_connection_certificate_provider {
void *wrapped_certificate_provider;
bool _deletable = false;
bool _deletable;
} caosdb_connection_certificate_provider;
typedef struct caosdb_authentication_authenticator {
void *wrapped_authenticator;
bool _deletable = false;
bool _deletable;
} caosdb_authentication_authenticator;
/**
......@@ -266,7 +268,7 @@ int caosdb_connection_connection_manager_get_connection(caosdb_connection_connec
typedef struct caosdb_transaction_transaction {
void *wrapped_transaction;
bool _deletable = false;
bool _deletable;
} caosdb_transaction_transaction;
/**
......@@ -292,12 +294,12 @@ int caosdb_transaction_transaction_execute(caosdb_transaction_transaction *trans
typedef struct caosdb_transaction_result_set {
void *wrapped_result_set;
bool _deletable = false;
bool _deletable;
} caosdb_transaction_result_set;
typedef struct caosdb_entity_entity {
void *wrapped_entity;
bool _deletable = false;
bool _deletable;
} caosdb_entity_entity;
int caosdb_transaction_transaction_get_result_set(caosdb_transaction_transaction *transaction,
......@@ -348,27 +350,27 @@ int caosdb_transaction_transaction_delete_by_id(caosdb_transaction_transaction *
typedef struct caosdb_entity_property {
void *wrapped_property;
bool _deletable = false;
bool _deletable;
} caosdb_entity_property;
typedef struct caosdb_entity_parent {
void *wrapped_parent;
bool _deletable = false;
bool _deletable;
} caosdb_entity_parent;
typedef struct caosdb_entity_message {
void *wrapped_message;
bool _deletable = false;
bool _deletable;
} caosdb_entity_message;
typedef struct caosdb_entity_value {
void *wrapped_value;
bool _deletable = false;
bool _deletable;
} caosdb_entity_value;
typedef struct caosdb_entity_datatype {
void *wrapped_datatype;
bool _deletable = false;
bool _deletable;
} caosdb_entity_datatype;
// GETTERS FOR EVERYTHING
......
......@@ -19,13 +19,15 @@
*
*/
#include "caosdb/authentication.h"
#include "grpcpp/security/credentials.h" // for MetadataCredentialsPlugin
#include <grpcpp/impl/codegen/status.h> // for Status, Status::OK
#include <grpcpp/impl/codegen/string_ref.h> // for string_ref
#include <map> // for multimap
#include <memory> // for allocator, shared_ptr
#include <string> // for basic_string, operator+
#include <utility> // for pair, move, make_pair
#include <grpcpp/impl/codegen/interceptor.h> // for Status
#include <grpcpp/impl/codegen/security/auth_context.h> // for AuthContext
#include <grpcpp/impl/codegen/status.h> // for Status, Status::OK
#include <grpcpp/impl/codegen/string_ref.h> // for string_ref
#include <grpcpp/security/credentials.h> // for MetadataCredentialsPlugin
#include <map> // for multimap
#include <memory> // for allocator, shared_ptr
#include <string> // for basic_string, operator+
#include <utility> // for pair, move, make_pair
namespace caosdb::authentication {
using caosdb::utility::base64_encode;
......
This diff is collapsed.
......@@ -53,24 +53,14 @@ auto main() -> int {
// retrieve an entity
auto transaction(connection->CreateTransaction());
transaction->RetrieveById("120");
transaction->RetrieveById("21");
transaction->ExecuteAsynchronously();
auto t_stat = transaction->WaitForIt();
CAOSDB_LOG_INFO(logger_name) << "status: " << t_stat.GetCode() << " // "
<< t_stat.GetDescription();
const auto &result_set = transaction->GetResultSet();
if (result_set.size() > 0) {
// print information
const auto &ent = result_set.at(0);
const auto &props = ent.GetProperties();
std::cout << "Entity Name: " << ent.GetName() << std::endl;
std::cout << "Entity Description: " << ent.GetDescription() << std::endl;
std::cout << "Entity Properties: " << std::endl;
for (const auto &prop : props) {
std::cout << "----------\n" << prop.ToString() << std::endl;
}
} else {
std::cout << "No entity \"120\" retrieved, maybe it does not exist?\n" << std::endl;
for (const auto &entity : result_set) {
std::cout << entity.ToString() << std::endl;
}
// execute a query
......@@ -82,6 +72,11 @@ auto main() -> int {
t_stat = q_transaction->WaitForIt();
CAOSDB_LOG_INFO(logger_name) << "status: " << t_stat.GetCode() << " // "
<< t_stat.GetDescription();
const auto &result_set_2 = q_transaction->GetResultSet();
for (const auto &entity : result_set_2) {
std::cout << entity.ToString() << std::endl;
}
return 0;
} catch (const caosdb::exceptions::ConfigurationError &exc) {
std::cout << "ConfigurationError: " << exc.what() << std::endl;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment