onboardapi-sys 9.10.0

Raw FFI to the Rheinmetall onboardapi C++ SDK through a generated extern "C" shim
Documentation
// @generated by onboardapi-codegen from the onboardapi .rmodel data model. Do not edit.
// SPDX-License-Identifier: EPL-2.0
#include "wire_Auth.hpp"
#include "../obapi_runtime.hpp"

#include <type_traits>

static_assert(static_cast<uint32_t>(::M_Auth::AuthStateKind::Unauthenticated) == 0u, "enum value M_Auth::AuthStateKind::Type::Unauthenticated differs from the data model");
static_assert(static_cast<uint32_t>(::M_Auth::AuthStateKind::Authenticated) == 1u, "enum value M_Auth::AuthStateKind::Type::Authenticated differs from the data model");
static_assert(static_cast<uint32_t>(::M_Auth::LoginFailureKind::Unknown) == 0u, "enum value M_Auth::LoginFailureKind::Type::Unknown differs from the data model");
static_assert(static_cast<uint32_t>(::M_Auth::LoginFailureKind::InvalidPassword) == 1u, "enum value M_Auth::LoginFailureKind::Type::InvalidPassword differs from the data model");
static_assert(static_cast<uint32_t>(::M_Auth::LoginFailureKind::UserNotFound) == 2u, "enum value M_Auth::LoginFailureKind::Type::UserNotFound differs from the data model");
static_assert(static_cast<uint32_t>(::M_Auth::LoginFailureKind::ExpiredCredentials) == 3u, "enum value M_Auth::LoginFailureKind::Type::ExpiredCredentials differs from the data model");
static_assert(static_cast<uint32_t>(::M_Auth::LoginFailureKind::Locked) == 4u, "enum value M_Auth::LoginFailureKind::Type::Locked differs from the data model");
static_assert(static_cast<uint32_t>(::M_Auth::LoginFailureKind::LockedExternal) == 5u, "enum value M_Auth::LoginFailureKind::Type::LockedExternal differs from the data model");
static_assert(std::is_same<decltype(::M_Auth::FailureReasonType::Reason), ::M_Auth::LoginFailureKind::Type>::value, "M_Auth::FailureReasonType field Reason differs from the data model");
static_assert(std::is_same<::M_Auth::FailureReasonOptionalType, std::vector<::M_Auth::FailureReasonType>>::value, "typedef M_Auth::FailureReasonOptionalType differs from the data model");
static_assert(std::is_same<decltype(::M_Auth::LoginEventType::Result), ::M_Auth::AuthStateKind::Type>::value, "M_Auth::LoginEventType field Result differs from the data model");
static_assert(std::is_same<decltype(::M_Auth::LoginEventType::FailureReason), std::vector<::M_Auth::FailureReasonType>>::value, "M_Auth::LoginEventType field FailureReason differs from the data model");
static_assert(std::is_same<decltype(::M_Auth::UserIdentityType::Username), std::string>::value, "M_Auth::UserIdentityType field Username differs from the data model");
static_assert(std::is_same<decltype(::M_Auth::UserIdentityType::Roles), std::vector<uint32_t>>::value, "M_Auth::UserIdentityType field Roles differs from the data model");
static_assert(std::is_same<::M_Auth::UserIdentityOptionalType, std::vector<::M_Auth::UserIdentityType>>::value, "typedef M_Auth::UserIdentityOptionalType differs from the data model");
static_assert(std::is_same<decltype(::M_Auth::AuthStatusType::State), ::M_Auth::AuthStateKind::Type>::value, "M_Auth::AuthStatusType field State differs from the data model");
static_assert(std::is_same<decltype(::M_Auth::AuthStatusType::UserIdentity), std::vector<::M_Auth::UserIdentityType>>::value, "M_Auth::AuthStatusType field UserIdentity differs from the data model");

namespace M_Auth {
    void obapi_put(::obapi::Writer& w, FailureReasonType const& v) {
        ::obapi::put(w, v.Reason);
    }
    void obapi_get(::obapi::Reader& r, FailureReasonType& v) {
        ::obapi::get(r, v.Reason);
    }
    void obapi_put(::obapi::Writer& w, LoginEventType const& v) {
        ::obapi::put(w, v.Result);
        ::obapi::put(w, v.FailureReason);
    }
    void obapi_get(::obapi::Reader& r, LoginEventType& v) {
        ::obapi::get(r, v.Result);
        ::obapi::get(r, v.FailureReason);
    }
    void obapi_put(::obapi::Writer& w, UserIdentityType const& v) {
        ::obapi::put(w, v.Username);
        ::obapi::put(w, v.Roles);
    }
    void obapi_get(::obapi::Reader& r, UserIdentityType& v) {
        ::obapi::get(r, v.Username);
        ::obapi::get(r, v.Roles);
    }
    void obapi_put(::obapi::Writer& w, AuthStatusType const& v) {
        ::obapi::put(w, v.State);
        ::obapi::put(w, v.UserIdentity);
    }
    void obapi_get(::obapi::Reader& r, AuthStatusType& v) {
        ::obapi::get(r, v.State);
        ::obapi::get(r, v.UserIdentity);
    }
} // namespace M_Auth

namespace {
    struct ServiceCallbacks final : ::M_Auth::IService {
        ::obapi::Dispatcher dispatcher;
        void CmdLogoutUser(std::string const& KeyUserId) override {
            ::obapi::Writer w;
            ::obapi::put(w, KeyUserId);
            dispatcher.dispatch(0u, w);
        }
    };

    struct ClientCallbacks final : ::M_Auth::IClient {
        ::obapi::Dispatcher dispatcher;
        void EventLogin(std::string const& KeyUserId, ::M_Auth::LoginEventType const& LoginEvent) override {
            ::obapi::Writer w;
            ::obapi::put(w, KeyUserId);
            ::obapi::put(w, LoginEvent);
            dispatcher.dispatch(0u, w);
        }
        void ReportAuthStatus(std::string const& KeyUserId, ::M_Auth::AuthStatusType const& Status, bool IsRemoved) override {
            ::obapi::Writer w;
            ::obapi::put(w, KeyUserId);
            ::obapi::put(w, Status);
            ::obapi::put(w, IsRemoved);
            dispatcher.dispatch(1u, w);
        }
    };

    void service_send(::obapi::Holder<::M_Auth::Service, ServiceCallbacks>& h, uint32_t op, ::obapi::Reader& r) {
        switch (op) {
            case 0u: {
                std::string KeyUserId{};
                ::obapi::get(r, KeyUserId);
                ::M_Auth::LoginEventType LoginEvent{};
                ::obapi::get(r, LoginEvent);
                r.finish();
                h.endpoint->EventLogin(KeyUserId, LoginEvent);
                return;
            }
            case 1u: {
                std::string KeyUserId{};
                ::obapi::get(r, KeyUserId);
                ::M_Auth::AuthStatusType Status{};
                ::obapi::get(r, Status);
                bool IsRemoved{};
                ::obapi::get(r, IsRemoved);
                r.finish();
                h.endpoint->ReportAuthStatus(KeyUserId, Status, IsRemoved);
                return;
            }
            default: throw ::obapi::UnknownOp(op);
        }
    }

    void client_send(::obapi::Holder<::M_Auth::Client, ClientCallbacks>& h, uint32_t op, ::obapi::Reader& r) {
        switch (op) {
            case 0u: {
                std::string KeyUserId{};
                ::obapi::get(r, KeyUserId);
                r.finish();
                h.endpoint->CmdLogoutUser(KeyUserId);
                return;
            }
            default: throw ::obapi::UnknownOp(op);
        }
    }

} // namespace

extern "C" const obapi_vtable obapi_Auth_service_vtable = ::obapi::Endpoint<::M_Auth::Service, ServiceCallbacks, &service_send, false>::vtable("M_Auth", "Service");
extern "C" const obapi_vtable obapi_Auth_client_vtable = ::obapi::Endpoint<::M_Auth::Client, ClientCallbacks, &client_send, true>::vtable("M_Auth", "Client");