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

fix test clients

parent dba650f6
Branches
Tags
2 merge requests!33Release 0.1,!32fix windows build
Pipeline #15924 failed
...@@ -39,7 +39,7 @@ set(CMAKE_C_STANDARD_REQUIRED ON) ...@@ -39,7 +39,7 @@ set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS 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}) set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
...@@ -51,14 +51,6 @@ IF (WIN32) ...@@ -51,14 +51,6 @@ IF (WIN32)
cmake_minimum_required(VERSION 3.15) cmake_minimum_required(VERSION 3.15)
cmake_policy(SET CMP0091 NEW) cmake_policy(SET CMP0091 NEW)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) 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() ENDIF()
########################################### ###########################################
...@@ -177,11 +169,16 @@ if("${CMAKE_BUILD_TYPE}" MATCHES "Debug") ...@@ -177,11 +169,16 @@ if("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
$<INSTALL_INTERFACE:include> $<INSTALL_INTERFACE:include>
) )
set_target_properties(caosdb_grpc PROPERTIES
COMPILE_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
else() else()
add_library(caosdb add_library(caosdb
${libcaosdb_INCL} ${libcaosdb_SRC} ${GRPC_GENERATED}) ${libcaosdb_INCL} ${libcaosdb_SRC} ${GRPC_GENERATED})
set(LIBCAOSDB caosdb) set(LIBCAOSDB caosdb)
endif() endif()
set(TARGET_CAOSDB_COMPILE_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
target_link_libraries(caosdb target_link_libraries(caosdb
${CONAN_LIBS} ${CONAN_LIBS}
) )
...@@ -194,30 +191,21 @@ target_include_directories(caosdb PUBLIC ...@@ -194,30 +191,21 @@ target_include_directories(caosdb PUBLIC
$<INSTALL_INTERFACE:include> $<INSTALL_INTERFACE:include>
) )
###################################################
# ccaosdb - A C-Wrapper of the C++ caosdb library
###################################################
add_library(ccaosdb SHARED src/ccaosdb.cpp) 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 target_link_libraries(ccaosdb
"-Wl,--whole-archive" "-Wl,--whole-archive"
${LIBCAOSDB} ${LIBCAOSDB}
"-Wl,--no-whole-archive" "-Wl,--no-whole-archive"
${CONAN_LIBS}
) )
ENDIF()
######################################
# ccaosdbcli - A plain C test client.
######################################
add_executable(ccaosdbcli EXCLUDE_FROM_ALL src/ccaosdbcli.c) add_executable(ccaosdbcli EXCLUDE_FROM_ALL src/ccaosdbcli.c)
target_include_directories(ccaosdbcli SYSTEM PUBLIC
${CONAN_INCLUDE_DIRS}
)
target_include_directories(ccaosdbcli PUBLIC target_include_directories(ccaosdbcli PUBLIC
$<BUILD_INTERFACE:${libcaosdb_SOURCE_DIR}/include> $<BUILD_INTERFACE:${libcaosdb_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${libcaosdb_BINARY_DIR}/include> $<BUILD_INTERFACE:${libcaosdb_BINARY_DIR}/include>
...@@ -228,6 +216,10 @@ target_link_libraries(ccaosdbcli ...@@ -228,6 +216,10 @@ target_link_libraries(ccaosdbcli
${CONAN_LIBS} ${CONAN_LIBS}
) )
######################################
# cxxcaosdbcli - A C++ test client.
######################################
add_executable(cxxcaosdbcli EXCLUDE_FROM_ALL src/cxxcaosdbcli.cpp) add_executable(cxxcaosdbcli EXCLUDE_FROM_ALL src/cxxcaosdbcli.cpp)
target_include_directories(cxxcaosdbcli SYSTEM PUBLIC target_include_directories(cxxcaosdbcli SYSTEM PUBLIC
${CONAN_INCLUDE_DIRS} ${CONAN_INCLUDE_DIRS}
......
...@@ -20,10 +20,12 @@ ...@@ -20,10 +20,12 @@
* *
*/ */
#include <cstdint> // for int64_t
#ifdef __cplusplus #ifdef __cplusplus
#include <cstdint> // for int64_t
extern "C" { extern "C" {
#else
#include <stdint.h> // for int64_t
#include <stdbool.h> // for bool
#endif #endif
/** /**
...@@ -70,7 +72,7 @@ int caosdb_status_code_OTHER_CLIENT_ERROR(); ...@@ -70,7 +72,7 @@ int caosdb_status_code_OTHER_CLIENT_ERROR();
*/ */
typedef struct caosdb_connection_connection { typedef struct caosdb_connection_connection {
void *wrapped_connection; void *wrapped_connection;
bool _deletable = false; bool _deletable;
} caosdb_connection_connection; } caosdb_connection_connection;
/** /**
...@@ -82,7 +84,7 @@ typedef struct caosdb_connection_connection { ...@@ -82,7 +84,7 @@ typedef struct caosdb_connection_connection {
*/ */
typedef struct caosdb_connection_connection_configuration { typedef struct caosdb_connection_connection_configuration {
void *wrapped_connection_configuration; void *wrapped_connection_configuration;
bool _deletable = false; bool _deletable;
} caosdb_connection_connection_configuration; } caosdb_connection_connection_configuration;
/** /**
...@@ -102,12 +104,12 @@ typedef struct caosdb_info_version_info { ...@@ -102,12 +104,12 @@ typedef struct caosdb_info_version_info {
typedef struct caosdb_connection_certificate_provider { typedef struct caosdb_connection_certificate_provider {
void *wrapped_certificate_provider; void *wrapped_certificate_provider;
bool _deletable = false; bool _deletable;
} caosdb_connection_certificate_provider; } caosdb_connection_certificate_provider;
typedef struct caosdb_authentication_authenticator { typedef struct caosdb_authentication_authenticator {
void *wrapped_authenticator; void *wrapped_authenticator;
bool _deletable = false; bool _deletable;
} caosdb_authentication_authenticator; } caosdb_authentication_authenticator;
/** /**
...@@ -266,7 +268,7 @@ int caosdb_connection_connection_manager_get_connection(caosdb_connection_connec ...@@ -266,7 +268,7 @@ int caosdb_connection_connection_manager_get_connection(caosdb_connection_connec
typedef struct caosdb_transaction_transaction { typedef struct caosdb_transaction_transaction {
void *wrapped_transaction; void *wrapped_transaction;
bool _deletable = false; bool _deletable;
} caosdb_transaction_transaction; } caosdb_transaction_transaction;
/** /**
...@@ -292,12 +294,12 @@ int caosdb_transaction_transaction_execute(caosdb_transaction_transaction *trans ...@@ -292,12 +294,12 @@ int caosdb_transaction_transaction_execute(caosdb_transaction_transaction *trans
typedef struct caosdb_transaction_result_set { typedef struct caosdb_transaction_result_set {
void *wrapped_result_set; void *wrapped_result_set;
bool _deletable = false; bool _deletable;
} caosdb_transaction_result_set; } caosdb_transaction_result_set;
typedef struct caosdb_entity_entity { typedef struct caosdb_entity_entity {
void *wrapped_entity; void *wrapped_entity;
bool _deletable = false; bool _deletable;
} caosdb_entity_entity; } caosdb_entity_entity;
int caosdb_transaction_transaction_get_result_set(caosdb_transaction_transaction *transaction, 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 * ...@@ -348,27 +350,27 @@ int caosdb_transaction_transaction_delete_by_id(caosdb_transaction_transaction *
typedef struct caosdb_entity_property { typedef struct caosdb_entity_property {
void *wrapped_property; void *wrapped_property;
bool _deletable = false; bool _deletable;
} caosdb_entity_property; } caosdb_entity_property;
typedef struct caosdb_entity_parent { typedef struct caosdb_entity_parent {
void *wrapped_parent; void *wrapped_parent;
bool _deletable = false; bool _deletable;
} caosdb_entity_parent; } caosdb_entity_parent;
typedef struct caosdb_entity_message { typedef struct caosdb_entity_message {
void *wrapped_message; void *wrapped_message;
bool _deletable = false; bool _deletable;
} caosdb_entity_message; } caosdb_entity_message;
typedef struct caosdb_entity_value { typedef struct caosdb_entity_value {
void *wrapped_value; void *wrapped_value;
bool _deletable = false; bool _deletable;
} caosdb_entity_value; } caosdb_entity_value;
typedef struct caosdb_entity_datatype { typedef struct caosdb_entity_datatype {
void *wrapped_datatype; void *wrapped_datatype;
bool _deletable = false; bool _deletable;
} caosdb_entity_datatype; } caosdb_entity_datatype;
// GETTERS FOR EVERYTHING // GETTERS FOR EVERYTHING
......
...@@ -19,13 +19,15 @@ ...@@ -19,13 +19,15 @@
* *
*/ */
#include "caosdb/authentication.h" #include "caosdb/authentication.h"
#include "grpcpp/security/credentials.h" // for MetadataCredentialsPlugin #include <grpcpp/impl/codegen/interceptor.h> // for Status
#include <grpcpp/impl/codegen/status.h> // for Status, Status::OK #include <grpcpp/impl/codegen/security/auth_context.h> // for AuthContext
#include <grpcpp/impl/codegen/string_ref.h> // for string_ref #include <grpcpp/impl/codegen/status.h> // for Status, Status::OK
#include <map> // for multimap #include <grpcpp/impl/codegen/string_ref.h> // for string_ref
#include <memory> // for allocator, shared_ptr #include <grpcpp/security/credentials.h> // for MetadataCredentialsPlugin
#include <string> // for basic_string, operator+ #include <map> // for multimap
#include <utility> // for pair, move, make_pair #include <memory> // for allocator, shared_ptr
#include <string> // for basic_string, operator+
#include <utility> // for pair, move, make_pair
namespace caosdb::authentication { namespace caosdb::authentication {
using caosdb::utility::base64_encode; using caosdb::utility::base64_encode;
......
This diff is collapsed.
...@@ -53,24 +53,14 @@ auto main() -> int { ...@@ -53,24 +53,14 @@ auto main() -> int {
// retrieve an entity // retrieve an entity
auto transaction(connection->CreateTransaction()); auto transaction(connection->CreateTransaction());
transaction->RetrieveById("120"); transaction->RetrieveById("21");
transaction->ExecuteAsynchronously(); transaction->ExecuteAsynchronously();
auto t_stat = transaction->WaitForIt(); auto t_stat = transaction->WaitForIt();
CAOSDB_LOG_INFO(logger_name) << "status: " << t_stat.GetCode() << " // " CAOSDB_LOG_INFO(logger_name) << "status: " << t_stat.GetCode() << " // "
<< t_stat.GetDescription(); << t_stat.GetDescription();
const auto &result_set = transaction->GetResultSet(); const auto &result_set = transaction->GetResultSet();
if (result_set.size() > 0) { for (const auto &entity : result_set) {
// print information std::cout << entity.ToString() << std::endl;
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;
} }
// execute a query // execute a query
...@@ -82,6 +72,11 @@ auto main() -> int { ...@@ -82,6 +72,11 @@ auto main() -> int {
t_stat = q_transaction->WaitForIt(); t_stat = q_transaction->WaitForIt();
CAOSDB_LOG_INFO(logger_name) << "status: " << t_stat.GetCode() << " // " CAOSDB_LOG_INFO(logger_name) << "status: " << t_stat.GetCode() << " // "
<< t_stat.GetDescription(); << 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; return 0;
} catch (const caosdb::exceptions::ConfigurationError &exc) { } catch (const caosdb::exceptions::ConfigurationError &exc) {
std::cout << "ConfigurationError: " << exc.what() << std::endl; 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