// Copyright (C) 2022 The Qt Company Ltd. // Copyright (C) 2019 Alexey Edelev // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef QGRPCCREDENTIALS_H #define QGRPCCREDENTIALS_H #include #include #include QT_BEGIN_NAMESPACE class Q_GRPC_EXPORT QGrpcCallCredentials { public: virtual ~QGrpcCallCredentials(); virtual QGrpcCredentialMap operator()() const = 0; }; class Q_GRPC_EXPORT QGrpcChannelCredentials { public: virtual ~QGrpcChannelCredentials(); virtual QGrpcCredentialMap channelCredentials() const = 0; }; #ifdef Q_QDOC template #else template , std::is_base_of>, int> = 0> #endif class QGrpcCredentials final : public QAbstractGrpcCredentials { public: explicit QGrpcCredentials(const Call &call, const Channel &channel) : mCall(call), mChannel(channel) { } explicit QGrpcCredentials(const Call &call) : mCall(call) { } explicit QGrpcCredentials(const Channel &channel) : mChannel(channel) { } ~QGrpcCredentials() override = default; QGrpcCredentialMap callCredentials() const override { return mCall(); } QGrpcCredentialMap channelCredentials() const override { return mChannel.channelCredentials(); } private: QGrpcCredentials() = default; Call mCall; Channel mChannel; }; extern Q_GRPC_EXPORT const char *SslConfigCredential; template , std::is_base_of>, int> = 0> std::unique_ptr operator|(const Call &call, const Channel &channel) { return std::make_unique>(call, channel); } template , std::is_base_of>, int> = 0> std::unique_ptr operator|(const Channel &channel, const Call &call) { return std::make_unique>(call, channel); } QT_END_NAMESPACE #endif // QGRPCCREDENTIALS_H