diff --git a/CMakeLists.txt b/CMakeLists.txt index f19cc2946637dea895b30bc22a2df922ac12088b..288c5461e6c05aca02057c7c3b1abfed83823418 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,10 @@ cmake_minimum_required(VERSION 3.14) set(libcaosdb_VERSION 0.0.5) +set(libcaosdb_COMPATIBLE_SERVER_VERSION_MAJOR 0) +set(libcaosdb_COMPATIBLE_SERVER_VERSION_MINOR 5) +set(libcaosdb_COMPATIBLE_SERVER_VERSION_PATCH 0) +set(libcaosdb_COMPATIBLE_SERVER_VERSION_PRE_RELEASE "GRPC${libcaosdb_VERSION}") project(libcaosdb VERSION ${libcaosdb_VERSION} diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 5ea0ae59c1110413bc35461d47e068b572641c09..090df1c53c4c7cfc99ee9943d68c97b22b854eae 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -21,9 +21,11 @@ find_package(Doxygen) if (DOXYGEN_FOUND) - string(REPLACE ";" " " DOXYGEN_INPUT "${libcaosdb_INCL}") + string(REPLACE ";" " " DOXYGEN_INPUT "${PROJECT_INCLUDE_DIR} ${CMAKE_BINARY_DIR}/include") + string(REPLACE ";" " " DOXYGEN_STRIP_FROM_PATH "${PROJECT_INCLUDE_DIR} ${CMAKE_BINARY_DIR}/include") configure_file(Doxyfile.in Doxyfile) + # Note: do not put "ALL" - this builds docs together with application EVERY TIME! add_custom_target(doc-doxygen COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile @@ -35,7 +37,9 @@ if (DOXYGEN_FOUND) if (SPHINX_CMD) configure_file(conf.py.in conf.py) configure_file(index.rst.in index.rst) - configure_file(api/index.rst.in api/index.rst) + + # create C++ docs + configure_file(cppapi/index.rst.in cppapi/index.rst) # create rst pages for every header file list(LENGTH libcaosdb_INCL len_header_files) @@ -43,20 +47,28 @@ if (DOXYGEN_FOUND) foreach (i RANGE "${len_header_files}") list(GET libcaosdb_INCL ${i} HEADER_FILE) string(REPLACE - "${PROJECT_INCLUDE_DIR}/caosdb/" + "${PROJECT_INCLUDE_DIR}/" "" HEADER_FILE_NAME ${HEADER_FILE}) string(REPLACE - "${CMAKE_BINARY_DIR}/include/caosdb/" + "${CMAKE_BINARY_DIR}/include/" "" HEADER_FILE_NAME ${HEADER_FILE_NAME}) configure_file( - api/header_file.rst.in - api/_${HEADER_FILE_NAME}.rst) + header_file.rst.in + cppapi/_${HEADER_FILE_NAME}.rst) endforeach () + # create (plain) C docs + configure_file(capi/index.rst.in capi/index.rst) + set(HEADER_FILE_NAME ccaosdb.h) + set(HEADER_FILE ccaosdb.h) + configure_file( + header_file.rst.in + capi/_ccaosdb.rst) + add_custom_target(doc-sphinx COMMAND ${SPHINX_CMD} -b html diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in index d0f329b99f37f6baeb05424f73decdb96ccc4cef..798198a973a2996a22402e771d4712b9ec31eafa 100644 --- a/doc/Doxyfile.in +++ b/doc/Doxyfile.in @@ -68,7 +68,7 @@ OUTPUT_DIRECTORY = doxygen_out # performance problems for the file system. # The default value is: NO. -CREATE_SUBDIRS = NO +CREATE_SUBDIRS = YES # If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII # characters to appear in the names of generated files. If set to NO, non-ASCII @@ -170,7 +170,7 @@ FULL_PATH_NAMES = YES # will be relative from the directory where doxygen is started. # This tag requires that the tag FULL_PATH_NAMES is set to YES. -STRIP_FROM_PATH = +STRIP_FROM_PATH = @DOXYGEN_STRIP_FROM_PATH@ # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the # path mentioned in the documentation of a class, which tells the reader which @@ -944,7 +944,7 @@ FILE_PATTERNS = *.c \ # be searched for input files as well. # The default value is: NO. -RECURSIVE = NO +RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should be # excluded from the INPUT source files. This way you can easily exclude a diff --git a/doc/api/.gitignore b/doc/api/.gitignore deleted file mode 100644 index a463abd406508c6ad4c99ff83aa59e4196947228..0000000000000000000000000000000000000000 --- a/doc/api/.gitignore +++ /dev/null @@ -1 +0,0 @@ -_*.rst diff --git a/doc/api/index.rst.in b/doc/capi/index.rst.in similarity index 97% rename from doc/api/index.rst.in rename to doc/capi/index.rst.in index 8a34c64d35cc72179a07ca96d1ba5914b0d741f1..b4fe4a88bc38dc40cbf09023cc4a3140ea0dded8 100644 --- a/doc/api/index.rst.in +++ b/doc/capi/index.rst.in @@ -21,10 +21,11 @@ .. _api_root: -API -=== +C API +===== .. toctree:: :glob: - * + _* + _*/* diff --git a/doc/cppapi/index.rst.in b/doc/cppapi/index.rst.in new file mode 100644 index 0000000000000000000000000000000000000000..f0639ce79c10e118c09b82eee75595756dfb62eb --- /dev/null +++ b/doc/cppapi/index.rst.in @@ -0,0 +1,31 @@ +.. + # + # This file is a part of the CaosDB Project. + # + # Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com> + # Copyright (C) 2021 IndiScale GmbH <info@indiscale.com> + # + # This program is free software: you can redistribute it and/or modify + # it under the terms of the GNU Affero General Public License as + # published by the Free Software Foundation, either version 3 of the + # License, or (at your option) any later version. + # + # This program is distributed in the hope that it will be useful, + # but WITHOUT ANY WARRANTY; without even the implied warranty of + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + # GNU Affero General Public License for more details. + # + # You should have received a copy of the GNU Affero General Public License + # along with this program. If not, see <https://www.gnu.org/licenses/>. + # + +.. _api_root: + +C++ API +======= + +.. toctree:: + :glob: + + _* + _*/* diff --git a/doc/api/header_file.rst.in b/doc/header_file.rst.in similarity index 100% rename from doc/api/header_file.rst.in rename to doc/header_file.rst.in diff --git a/doc/index.rst.in b/doc/index.rst.in index 086a2f4096ca7d54a57c1dc01db1898f46f1a230..a4061607a924db8080e9a3970b08d1bce28d8944 100644 --- a/doc/index.rst.in +++ b/doc/index.rst.in @@ -35,6 +35,7 @@ This is work in progress. :caption: Contents: Welcome <self> - api/index + cppapi/index + capi/index * :ref:`genindex` diff --git a/include/caosdb/authentication.h b/include/caosdb/authentication.h index 703fcf51bae519a1f1fe0112ba1e8f84246d16a9..6b26dd68f1e7465763f63f7b638be23fa78c0429 100644 --- a/include/caosdb/authentication.h +++ b/include/caosdb/authentication.h @@ -22,7 +22,7 @@ #ifndef CAOSDB_AUTHENTICATION_H #define CAOSDB_AUTHENTICATION_H /** - * @file authentication.h + * @file caosdb/authentication.h * @author Timm Fitschen * @date 2021-06-28 * @brief Configuration and setup of the client authentication. diff --git a/include/caosdb/connection.h b/include/caosdb/connection.h index 7f45319a837e2e0131dc1337fab032638bd0ef0d..4e87702fa8289dce7157955f046838c2fdffce43 100644 --- a/include/caosdb/connection.h +++ b/include/caosdb/connection.h @@ -46,41 +46,40 @@ using caosdb::info::v1alpha1::GeneralInfoService; using caosdb::transaction::Transaction; using grpc::ChannelCredentials; -class CACertificateProvider { +class CertificateificateProvider { public: - [[nodiscard]] auto virtual GetCACertPem() const -> std::string = 0; + [[nodiscard]] auto virtual GetCertificatePem() const -> std::string = 0; }; -class PemFileCACertProvider : public CACertificateProvider { +class PemFileCertificateProvider : public CertificateificateProvider { private: std::string cacert; public: - explicit PemFileCACertProvider(const std::string &path); - [[nodiscard]] auto GetCACertPem() const -> std::string override; + explicit PemFileCertificateProvider(const std::string &path); + [[nodiscard]] auto GetCertificatePem() const -> std::string override; }; -class PemCACertProvider : public CACertificateProvider { +class PemCertificateProvider : public CertificateificateProvider { private: std::string cacert; public: - explicit PemCACertProvider(const std::string &cacert); - [[nodiscard]] auto GetCACertPem() const -> std::string override; + explicit PemCertificateProvider(const std::string &cacert); + [[nodiscard]] auto GetCertificatePem() const -> std::string override; }; /** * @brief Configuration of the CaosDB connection. */ -class CaosDBConnectionConfig { +class ConnectionConfig { private: std::string host; int port; public: - CaosDBConnectionConfig(const std::string &host, int port); - friend auto operator<<(std::ostream &out, - const CaosDBConnectionConfig &config) + ConnectionConfig(const std::string &host, int port); + friend auto operator<<(std::ostream &out, const ConnectionConfig &config) -> std::ostream &; [[nodiscard]] auto virtual ToString() const -> std::string = 0; @@ -90,31 +89,31 @@ public: -> std::shared_ptr<ChannelCredentials> = 0; }; -class InsecureCaosDBConnectionConfig : public CaosDBConnectionConfig { +class InsecureConnectionConfig : public ConnectionConfig { private: std::shared_ptr<ChannelCredentials> credentials; public: - InsecureCaosDBConnectionConfig(const std::string &host, int port); + InsecureConnectionConfig(const std::string &host, int port); [[nodiscard]] auto GetChannelCredentials() const -> std::shared_ptr<ChannelCredentials> override; [[nodiscard]] auto ToString() const -> std::string override; }; -class SslCaosDBConnectionConfig : public CaosDBConnectionConfig { +class TlsConnectionConfig : public ConnectionConfig { private: std::shared_ptr<ChannelCredentials> credentials; std::string cacert; public: - SslCaosDBConnectionConfig(const std::string &host, int port); - SslCaosDBConnectionConfig(const std::string &host, int port, - const Authenticator &authenticator); - SslCaosDBConnectionConfig(const std::string &host, int port, - const CACertificateProvider &cacert); - SslCaosDBConnectionConfig(const std::string &host, int port, - const CACertificateProvider &cacert, - const Authenticator &authenticator); + TlsConnectionConfig(const std::string &host, int port); + TlsConnectionConfig(const std::string &host, int port, + const Authenticator &authenticator); + TlsConnectionConfig(const std::string &host, int port, + const CertificateificateProvider &cacert); + TlsConnectionConfig(const std::string &host, int port, + const CertificateificateProvider &cacert, + const Authenticator &authenticator); [[nodiscard]] auto GetChannelCredentials() const -> std::shared_ptr<ChannelCredentials> override; [[nodiscard]] auto ToString() const -> std::string override; @@ -123,14 +122,14 @@ public: /** * @brief A reusable connection to a CaosDBServer. */ -class CaosDBConnection { +class Connection { std::shared_ptr<grpc::Channel> channel; std::unique_ptr<GeneralInfoService::Stub> general_info_service; std::shared_ptr<EntityTransactionService::Stub> entity_transaction_service; public: - explicit CaosDBConnection(const CaosDBConnectionConfig &config); - friend auto operator<<(std::ostream &out, const CaosDBConnection &connection) + explicit Connection(const ConnectionConfig &config); + friend auto operator<<(std::ostream &out, const Connection &connection) -> std::ostream &; [[nodiscard]] auto GetVersionInfo() const -> std::unique_ptr<VersionInfo>; [[nodiscard]] auto CreateTransaction() const -> std::unique_ptr<Transaction>; diff --git a/include/caosdb/constants.h.in b/include/caosdb/constants.h.in index 566cbb1c87e17f03a548c1e1386dc0ddb06decd4..b13176cc30414a2f90bd38c042e2b668cbb71776 100644 --- a/include/caosdb/constants.h.in +++ b/include/caosdb/constants.h.in @@ -29,6 +29,10 @@ namespace caosdb { const int LIBCAOSDB_VERSION_MAJOR = @libcaosdb_VERSION_MAJOR@; const int LIBCAOSDB_VERSION_MINOR = @libcaosdb_VERSION_MINOR@; const int LIBCAOSDB_VERSION_PATCH = @libcaosdb_VERSION_PATCH@; +const int COMPATIBLE_SERVER_VERSION_MAJOR = @libcaosdb_COMPATIBLE_SERVER_VERSION_MAJOR@; +const int COMPATIBLE_SERVER_VERSION_MINOR = @libcaosdb_COMPATIBLE_SERVER_VERSION_MINOR@; +const int COMPATIBLE_SERVER_VERSION_PATCH = @libcaosdb_COMPATIBLE_SERVER_VERSION_PATCH@; +const char* COMPATIBLE_SERVER_VERSION_PRE_RELEASE = "@libcaosdb_COMPATIBLE_SERVER_VERSION_PRE_RELEASE@"; // clang-format on #ifdef __cplusplus } // namespace caosdb diff --git a/include/ccaosdb.h b/include/ccaosdb.h index 2c32888be20b47dd17be959cdf1204425e91ae31..24f478a2b53467db0f302cfd7c5c5b27c3a4d052 100644 --- a/include/ccaosdb.h +++ b/include/ccaosdb.h @@ -5,22 +5,51 @@ extern "C" { #endif /** - * A wrapper of the C++ CaosDBConnection class. + * Return the constant caosdb::LIBCAOSDB_VERSION_MAJOR. + */ +const int caosdb_constants_LIBCAOSDB_VERSION_MAJOR(); +/** + * Return the constant caosdb::LIBCAOSDB_VERSION_MINOR + */ +const int caosdb_constants_LIBCAOSDB_VERSION_MINOR(); +/** + * Return the constant caosdb::LIBCAOSDB_VERSION_PATCH. + */ +const int caosdb_constants_LIBCAOSDB_VERSION_PATCH(); +/** + * Return the constant caosdb::COMPATIBLE_SERVER_VERSION_MAJOR. + */ +const int caosdb_constants_COMPATIBLE_SERVER_VERSION_MAJOR(); +/** + * Return the constant caosdb::COMPATIBLE_SERVER_VERSION_MINOR. + */ +const int caosdb_constants_COMPATIBLE_SERVER_VERSION_MINOR(); +/** + * Return the constant caosdb::COMPATIBLE_SERVER_VERSION_PATCH. + */ +const int caosdb_constants_COMPATIBLE_SERVER_VERSION_PATCH(); +/** + * Return the constant caosdb::COMPATIBLE_SERVER_VERSION_PRE_RELEASE. + */ +const char *caosdb_constants_COMPATIBLE_SERVER_VERSION_PRE_RELEASE(); + +/** + * A wrapper of the C++ Connection class. * * We use a wrapper for future extensibility and in order to have a minimal * capability for type checking in C even though the C++ class - * CaosDBConnection is opaque in C. + * Connection is opaque in C. */ typedef struct { void *wrapped_connection; } caosdb_connection_connection; /** - * A wrapper of the C++ CaosDBConnectionConfig class. + * A wrapper of the C++ ConnectionConfig class. * * We use a wrapper for future extensibility and in order to have a minimal * capability for type checking in C even though the C++ class - * CaosDBConnection is opaque in C. + * Connection is opaque in C. */ typedef struct { void *wrapped_connection_configuration; @@ -31,7 +60,7 @@ typedef struct { * * We use a wrapper for future extensibility and in order to have a minimal * capability for type checking in C even though the C++ class - * CaosDBConnection is opaque in C. + * Connection is opaque in C. */ typedef struct { int major; diff --git a/src/caosdb/connection.cpp b/src/caosdb/connection.cpp index 09a219cb394b77a2da0b85770e5ae7d5dee49807..5f271a4a711ecfa040dd5aa710f436cd33946c62 100644 --- a/src/caosdb/connection.cpp +++ b/src/caosdb/connection.cpp @@ -52,102 +52,99 @@ using grpc::InsecureChannelCredentials; using grpc::SslCredentials; using grpc::SslCredentialsOptions; -PemFileCACertProvider::PemFileCACertProvider(const std::string &path) { +PemFileCertificateProvider::PemFileCertificateProvider( + const std::string &path) { this->cacert = load_string_file(path); } -auto PemFileCACertProvider::GetCACertPem() const -> std::string { +auto PemFileCertificateProvider::GetCertificatePem() const -> std::string { return this->cacert; } -PemCACertProvider::PemCACertProvider(const std::string &cacert) { +PemCertificateProvider::PemCertificateProvider(const std::string &cacert) { this->cacert = cacert; } -auto PemCACertProvider::GetCACertPem() const -> std::string { +auto PemCertificateProvider::GetCertificatePem() const -> std::string { return this->cacert; } -CaosDBConnectionConfig::CaosDBConnectionConfig(const std::string &host, - int port) { +ConnectionConfig::ConnectionConfig(const std::string &host, int port) { this->host = host; this->port = port; } -auto CaosDBConnectionConfig::GetHost() const -> std::string { - return this->host; -} +auto ConnectionConfig::GetHost() const -> std::string { return this->host; } -auto CaosDBConnectionConfig::GetPort() const -> int { return this->port; } +auto ConnectionConfig::GetPort() const -> int { return this->port; } -auto operator<<(std::ostream &out, const CaosDBConnectionConfig &config) +auto operator<<(std::ostream &out, const ConnectionConfig &config) -> std::ostream & { out << config.ToString(); return out; } -InsecureCaosDBConnectionConfig::InsecureCaosDBConnectionConfig( - const std::string &host, int port) - : CaosDBConnectionConfig(host, port) { +InsecureConnectionConfig::InsecureConnectionConfig(const std::string &host, + int port) + : ConnectionConfig(host, port) { this->credentials = InsecureChannelCredentials(); } -auto InsecureCaosDBConnectionConfig::GetChannelCredentials() const +auto InsecureConnectionConfig::GetChannelCredentials() const -> std::shared_ptr<ChannelCredentials> { return this->credentials; } -auto InsecureCaosDBConnectionConfig::ToString() const -> std::string { - return "InsecureCaosDBConnectionConfig(" + this->GetHost() + "," + +auto InsecureConnectionConfig::ToString() const -> std::string { + return "InsecureConnectionConfig(" + this->GetHost() + "," + std::to_string(this->GetPort()) + ")"; } -SslCaosDBConnectionConfig::SslCaosDBConnectionConfig(const std::string &host, - int port) - : CaosDBConnectionConfig(host, port) { +TlsConnectionConfig::TlsConnectionConfig(const std::string &host, int port) + : ConnectionConfig(host, port) { SslCredentialsOptions options; this->credentials = SslCredentials(options); } -SslCaosDBConnectionConfig::SslCaosDBConnectionConfig( - const std::string &host, int port, const CACertificateProvider &cacert) - : CaosDBConnectionConfig(host, port) { +TlsConnectionConfig::TlsConnectionConfig( + const std::string &host, int port, const CertificateificateProvider &cacert) + : ConnectionConfig(host, port) { SslCredentialsOptions options; - options.pem_root_certs = cacert.GetCACertPem(); + options.pem_root_certs = cacert.GetCertificatePem(); this->credentials = SslCredentials(options); } -SslCaosDBConnectionConfig::SslCaosDBConnectionConfig( - const std::string &host, int port, const Authenticator &authenticator) - : CaosDBConnectionConfig(host, port) { +TlsConnectionConfig::TlsConnectionConfig(const std::string &host, int port, + const Authenticator &authenticator) + : ConnectionConfig(host, port) { SslCredentialsOptions options; this->credentials = grpc::CompositeChannelCredentials( SslCredentials(options), authenticator.GetCallCredentials()); } -SslCaosDBConnectionConfig::SslCaosDBConnectionConfig( - const std::string &host, int port, const CACertificateProvider &cacert, +TlsConnectionConfig::TlsConnectionConfig( + const std::string &host, int port, const CertificateificateProvider &cacert, const Authenticator &authenticator) - : CaosDBConnectionConfig(host, port) { + : ConnectionConfig(host, port) { SslCredentialsOptions options; - options.pem_root_certs = cacert.GetCACertPem(); + options.pem_root_certs = cacert.GetCertificatePem(); this->credentials = grpc::CompositeChannelCredentials( SslCredentials(options), authenticator.GetCallCredentials()); } -auto SslCaosDBConnectionConfig::GetChannelCredentials() const +auto TlsConnectionConfig::GetChannelCredentials() const -> std::shared_ptr<ChannelCredentials> { return this->credentials; } -auto SslCaosDBConnectionConfig::ToString() const -> std::string { - return "SslCaosDBConnectionConfig(" + this->GetHost() + "," + +auto TlsConnectionConfig::ToString() const -> std::string { + return "TlsConnectionConfig(" + this->GetHost() + "," + std::to_string(this->GetPort()) + "," + this->cacert + ")"; } -CaosDBConnection::CaosDBConnection(const CaosDBConnectionConfig &config) { +Connection::Connection(const ConnectionConfig &config) { const std::string target = config.GetHost() + ":" + std::to_string(config.GetPort()); this->channel = grpc::CreateChannel(target, config.GetChannelCredentials()); @@ -156,13 +153,13 @@ CaosDBConnection::CaosDBConnection(const CaosDBConnectionConfig &config) { std::make_shared<EntityTransactionService::Stub>(this->channel); } -auto operator<<(std::ostream &out, const CaosDBConnection & /*connection*/) +auto operator<<(std::ostream &out, const Connection & /*connection*/) -> std::ostream & { - out << "CaosDBConnection()"; + out << "Connection()"; return out; } -[[nodiscard]] auto CaosDBConnection::GetVersionInfo() const +[[nodiscard]] auto Connection::GetVersionInfo() const -> std::unique_ptr<VersionInfo> { const GetVersionInfoRequest request; GetVersionInfoResponse response; @@ -185,7 +182,7 @@ auto operator<<(std::ostream &out, const CaosDBConnection & /*connection*/) return std::make_unique<VersionInfo>(response.release_version_info()); } -[[nodiscard]] auto CaosDBConnection::CreateTransaction() const +[[nodiscard]] auto Connection::CreateTransaction() const -> std::unique_ptr<Transaction> { auto service_stub = this->entity_transaction_service; return std::make_unique<Transaction>(service_stub); diff --git a/src/ccaosdb.cpp b/src/ccaosdb.cpp index 4465c78654f76548d64ad6b7fa012fdfea386591..412f37358a9dc8bee72ab691c679cb8a937d60a3 100644 --- a/src/ccaosdb.cpp +++ b/src/ccaosdb.cpp @@ -1,5 +1,6 @@ #include <iostream> #include <stdio.h> +#include "caosdb/constants.h" #include "caosdb/utility.h" #include "caosdb/constants.h" #include "caosdb/connection.h" @@ -7,6 +8,34 @@ extern "C" { +const int caosdb_constants_LIBCAOSDB_VERSION_MAJOR() { + return caosdb::LIBCAOSDB_VERSION_MAJOR; +} + +const int caosdb_constants_LIBCAOSDB_VERSION_MINOR() { + return caosdb::LIBCAOSDB_VERSION_MINOR; +} + +const int caosdb_constants_LIBCAOSDB_VERSION_PATCH() { + return caosdb::LIBCAOSDB_VERSION_PATCH; +} + +const int caosdb_constants_COMPATIBLE_SERVER_VERSION_MAJOR() { + return caosdb::COMPATIBLE_SERVER_VERSION_MAJOR; +} + +const int caosdb_constants_COMPATIBLE_SERVER_VERSION_MINOR() { + return caosdb::COMPATIBLE_SERVER_VERSION_MINOR; +} + +const int caosdb_constants_COMPATIBLE_SERVER_VERSION_PATCH() { + return caosdb::COMPATIBLE_SERVER_VERSION_PATCH; +} + +const char *caosdb_constants_COMPATIBLE_SERVER_VERSION_PRE_RELEASE() { + return caosdb::COMPATIBLE_SERVER_VERSION_PRE_RELEASE; +} + const char *caosdb_utility_get_env_var(const char *name, const char *fall_back) { return caosdb::utility::get_env_var(name, fall_back); @@ -15,13 +44,13 @@ const char *caosdb_utility_get_env_var(const char *name, int caosdb_connection_create_pem_file_certificate_provider( caosdb_connection_certificate_provider *out, const char *path) { out->wrapped_certificate_provider = - new caosdb::connection::PemFileCACertProvider(std::string(path)); + new caosdb::connection::PemFileCertificateProvider(std::string(path)); return 0; } int caosdb_connection_delete_certificate_provider( caosdb_connection_certificate_provider *provider) { - delete static_cast<caosdb::connection::CACertificateProvider *>( + delete static_cast<caosdb::connection::CertificateificateProvider *>( provider->wrapped_certificate_provider); return 0; } @@ -50,31 +79,31 @@ int caosdb_connection_create_tls_connection_configuration( auto host_str = std::string(host); if (authenticator != nullptr && provider != nullptr) { auto wrapped_provider = - static_cast<caosdb::connection::CACertificateProvider *>( + static_cast<caosdb::connection::CertificateificateProvider *>( provider->wrapped_certificate_provider); auto wrapped_authenticator = static_cast<caosdb::authentication::Authenticator *>( authenticator->wrapped_authenticator); out->wrapped_connection_configuration = - new caosdb::connection::SslCaosDBConnectionConfig( + new caosdb::connection::TlsConnectionConfig( host_str, port, *wrapped_provider, *wrapped_authenticator); } else if (authenticator != nullptr) { auto wrapped_authenticator = static_cast<caosdb::authentication::Authenticator *>( authenticator->wrapped_authenticator); out->wrapped_connection_configuration = - new caosdb::connection::SslCaosDBConnectionConfig(host_str, port, - *wrapped_authenticator); + new caosdb::connection::TlsConnectionConfig(host_str, port, + *wrapped_authenticator); } else if (provider != nullptr) { auto wrapped_provider = - static_cast<caosdb::connection::CACertificateProvider *>( + static_cast<caosdb::connection::CertificateificateProvider *>( provider->wrapped_certificate_provider); out->wrapped_connection_configuration = - new caosdb::connection::SslCaosDBConnectionConfig(host_str, port, - *wrapped_provider); + new caosdb::connection::TlsConnectionConfig(host_str, port, + *wrapped_provider); } else { out->wrapped_connection_configuration = - new caosdb::connection::SslCaosDBConnectionConfig(host_str, port); + new caosdb::connection::TlsConnectionConfig(host_str, port); } return 0; } @@ -83,13 +112,13 @@ int caosdb_connection_create_insecure_connection_configuration( caosdb_connection_connection_configuration *out, const char *host, const int port) { out->wrapped_connection_configuration = - new caosdb::connection::InsecureCaosDBConnectionConfig(host, port); + new caosdb::connection::InsecureConnectionConfig(host, port); return 0; } int caosdb_connection_delete_connection_configuration( caosdb_connection_connection_configuration *configuration) { - delete static_cast<caosdb::connection::CaosDBConnectionConfig *>( + delete static_cast<caosdb::connection::ConnectionConfig *>( configuration->wrapped_connection_configuration); return 0; } @@ -97,16 +126,16 @@ int caosdb_connection_delete_connection_configuration( int caosdb_connection_create_connection( caosdb_connection_connection *out, const caosdb_connection_connection_configuration *configuration) { - caosdb::connection::CaosDBConnectionConfig *config = - static_cast<caosdb::connection::CaosDBConnectionConfig *>( + caosdb::connection::ConnectionConfig *config = + static_cast<caosdb::connection::ConnectionConfig *>( configuration->wrapped_connection_configuration); - out->wrapped_connection = new caosdb::connection::CaosDBConnection(*config); + out->wrapped_connection = new caosdb::connection::Connection(*config); return 0; } int caosdb_connection_delete_connection( caosdb_connection_connection *connection) { - delete static_cast<caosdb::connection::CaosDBConnection *>( + delete static_cast<caosdb::connection::Connection *>( connection->wrapped_connection); return 0; } @@ -114,9 +143,8 @@ int caosdb_connection_delete_connection( int caosdb_connection_get_version_info( caosdb_info_version_info *out, const caosdb_connection_connection *connection) { - auto *wrapped_connection = - static_cast<caosdb::connection::CaosDBConnection *>( - connection->wrapped_connection); + auto *wrapped_connection = static_cast<caosdb::connection::Connection *>( + connection->wrapped_connection); auto version_info = wrapped_connection->GetVersionInfo(); out->major = (int)version_info->GetMajor(); diff --git a/src/cxxcaosdbcli.cpp b/src/cxxcaosdbcli.cpp index af83b403bc49ed68c8947f57e04a27959736908d..81fd99cece84e35239b5c4a9f7cf2e8717b95d3b 100644 --- a/src/cxxcaosdbcli.cpp +++ b/src/cxxcaosdbcli.cpp @@ -54,10 +54,10 @@ auto main() -> int { // setup the connection auto auth = caosdb::authentication::PlainPasswordAuthenticator(user, password); - auto cacert = caosdb::connection::PemFileCACertProvider(pem_file); + auto cacert = caosdb::connection::PemFileCertificateProvider(pem_file); auto config = - caosdb::connection::SslCaosDBConnectionConfig(host, port, cacert, auth); - caosdb::connection::CaosDBConnection connection(config); + caosdb::connection::TlsConnectionConfig(host, port, cacert, auth); + caosdb::connection::Connection connection(config); // get version info of the server const auto &v_info = connection.GetVersionInfo(); diff --git a/test/test_connection.cpp b/test/test_connection.cpp index eb2cea11410f5959a899ee98b8d89521a9cd7591..4ea1a7c739b4bbbeaae73aa386baa7fdbb2715cd 100644 --- a/test/test_connection.cpp +++ b/test/test_connection.cpp @@ -23,13 +23,13 @@ #include <gtest/gtest-message.h> // for Message #include <gtest/gtest-test-part.h> // for TestPartResult, SuiteApiRes... #include <memory> // for allocator, operator!=, shar... -#include "caosdb/connection.h" // for PemCACertProvider, Insecure... +#include "caosdb/connection.h" // for PemCertificateProvider, Insecure... #include "gtest/gtest_pred_impl.h" // for Test, AssertionResult, EXPE... namespace caosdb::connection { TEST(test_connection, configure_insecure_localhost_8080) { - InsecureCaosDBConnectionConfig config("localhost", 8000); + InsecureConnectionConfig config("localhost", 8000); EXPECT_EQ("localhost", config.GetHost()); EXPECT_EQ(8000, config.GetPort()); @@ -38,8 +38,8 @@ TEST(test_connection, configure_insecure_localhost_8080) { } TEST(test_connection, configure_ssl_localhost_8080) { - auto cacert = PemCACertProvider("ca chain"); - SslCaosDBConnectionConfig config("localhost", 44300, cacert); + auto cacert = PemCertificateProvider("ca chain"); + TlsConnectionConfig config("localhost", 44300, cacert); EXPECT_EQ("localhost", config.GetHost()); EXPECT_EQ(44300, config.GetPort()); diff --git a/test/test_transaction.cpp b/test/test_transaction.cpp index 7570e5c557165163dc1824bec954d72f488440df..ca4ab51f860c24a744a446533f1b49943cf4b0d9 100644 --- a/test/test_transaction.cpp +++ b/test/test_transaction.cpp @@ -21,7 +21,7 @@ */ #include <memory> // for allocator, make_shared -#include "caosdb/connection.h" // for InsecureCaosDBConnection... +#include "caosdb/connection.h" // for InsecureConnection... #include "caosdb/entity.h" // for Entity #include "caosdb/entity/v1alpha1/main.pb.h" // for Entity #include "caosdb/exceptions.h" // for ConnectionError @@ -32,16 +32,16 @@ #include "gtest/gtest_pred_impl.h" // for Test, TestInfo, TEST namespace caosdb::transaction { -using caosdb::connection::CaosDBConnection; -using caosdb::connection::InsecureCaosDBConnectionConfig; +using caosdb::connection::Connection; +using caosdb::connection::InsecureConnectionConfig; using caosdb::exceptions::ConnectionError; using caosdb::transaction::UniqueResult; using ProtoEntity = caosdb::entity::v1alpha1::Entity; TEST(test_transaction, create_transaction) { const auto *host = "localhost"; - auto config = InsecureCaosDBConnectionConfig(host, 8000); - CaosDBConnection connection(config); + auto config = InsecureConnectionConfig(host, 8000); + Connection connection(config); auto transaction = connection.CreateTransaction(); transaction->RetrieveById("100");