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_ErrorMemory.hpp"
#include "../obapi_runtime.hpp"

#include <type_traits>

static_assert(static_cast<uint32_t>(::M_ErrorMemory::ErrorClassKind::Undefined) == 0u, "enum value M_ErrorMemory::ErrorClassKind::Type::Undefined differs from the data model");
static_assert(static_cast<uint32_t>(::M_ErrorMemory::ErrorClassKind::Warning) == 1u, "enum value M_ErrorMemory::ErrorClassKind::Type::Warning differs from the data model");
static_assert(static_cast<uint32_t>(::M_ErrorMemory::ErrorClassKind::Reduced_Performance_Error) == 2u, "enum value M_ErrorMemory::ErrorClassKind::Type::Reduced_Performance_Error differs from the data model");
static_assert(static_cast<uint32_t>(::M_ErrorMemory::ErrorClassKind::Fatal_Error) == 3u, "enum value M_ErrorMemory::ErrorClassKind::Type::Fatal_Error differs from the data model");
static_assert(static_cast<uint32_t>(::M_ErrorMemory::ErrorClassKind::OK) == 4u, "enum value M_ErrorMemory::ErrorClassKind::Type::OK differs from the data model");
static_assert(static_cast<uint32_t>(::M_ErrorMemory::ErrorIdentificationMethodKind::PBIT) == 0u, "enum value M_ErrorMemory::ErrorIdentificationMethodKind::Type::PBIT differs from the data model");
static_assert(static_cast<uint32_t>(::M_ErrorMemory::ErrorIdentificationMethodKind::CBIT) == 1u, "enum value M_ErrorMemory::ErrorIdentificationMethodKind::Type::CBIT differs from the data model");
static_assert(static_cast<uint32_t>(::M_ErrorMemory::ErrorIdentificationMethodKind::FP) == 2u, "enum value M_ErrorMemory::ErrorIdentificationMethodKind::Type::FP differs from the data model");
static_assert(static_cast<uint32_t>(::M_ErrorMemory::ErrorIdentificationMethodKind::FL) == 3u, "enum value M_ErrorMemory::ErrorIdentificationMethodKind::Type::FL differs from the data model");
static_assert(std::is_same<decltype(::M_ErrorMemory::ErrorEntryType::Timestamp), ::M_Common::TimeType>::value, "M_ErrorMemory::ErrorEntryType field Timestamp differs from the data model");
static_assert(std::is_same<decltype(::M_ErrorMemory::ErrorEntryType::ErrorCode), std::string>::value, "M_ErrorMemory::ErrorEntryType field ErrorCode differs from the data model");
static_assert(std::is_same<decltype(::M_ErrorMemory::ErrorEntryType::ErrorClass), ::M_ErrorMemory::ErrorClassKind::Type>::value, "M_ErrorMemory::ErrorEntryType field ErrorClass differs from the data model");
static_assert(std::is_same<decltype(::M_ErrorMemory::ErrorEntryType::ErrorSource), std::string>::value, "M_ErrorMemory::ErrorEntryType field ErrorSource differs from the data model");
static_assert(std::is_same<decltype(::M_ErrorMemory::ErrorEntryType::ErrorMethod), ::M_ErrorMemory::ErrorIdentificationMethodKind::Type>::value, "M_ErrorMemory::ErrorEntryType field ErrorMethod differs from the data model");
static_assert(std::is_same<decltype(::M_ErrorMemory::ErrorEntryType::ShortText), std::string>::value, "M_ErrorMemory::ErrorEntryType field ShortText differs from the data model");
static_assert(std::is_same<decltype(::M_ErrorMemory::ErrorEntryType::LongText), std::string>::value, "M_ErrorMemory::ErrorEntryType field LongText differs from the data model");

namespace M_ErrorMemory {
    void obapi_put(::obapi::Writer& w, ErrorEntryType const& v) {
        ::obapi::put(w, v.Timestamp);
        ::obapi::put(w, v.ErrorCode);
        ::obapi::put(w, v.ErrorClass);
        ::obapi::put(w, v.ErrorSource);
        ::obapi::put(w, v.ErrorMethod);
        ::obapi::put(w, v.ShortText);
        ::obapi::put(w, v.LongText);
    }
    void obapi_get(::obapi::Reader& r, ErrorEntryType& v) {
        ::obapi::get(r, v.Timestamp);
        ::obapi::get(r, v.ErrorCode);
        ::obapi::get(r, v.ErrorClass);
        ::obapi::get(r, v.ErrorSource);
        ::obapi::get(r, v.ErrorMethod);
        ::obapi::get(r, v.ShortText);
        ::obapi::get(r, v.LongText);
    }
} // namespace M_ErrorMemory

namespace {
    struct ServiceCallbacks final : ::M_ErrorMemory::IService {
        ::obapi::Dispatcher dispatcher;
        void CmdCreateEntry(::M_ErrorMemory::ErrorEntryType const& Value) override {
            ::obapi::Writer w;
            ::obapi::put(w, Value);
            dispatcher.dispatch(0u, w);
        }
        void CmdDeleteEntry(std::string const& KeyId) override {
            ::obapi::Writer w;
            ::obapi::put(w, KeyId);
            dispatcher.dispatch(1u, w);
        }
        void CmdDeleteAll() override {
            ::obapi::Writer w;
            dispatcher.dispatch(2u, w);
        }
    };

    struct ClientCallbacks final : ::M_ErrorMemory::IClient {
        ::obapi::Dispatcher dispatcher;
        void ReportEntry(std::string const& KeyId, ::M_ErrorMemory::ErrorEntryType const& Value, bool IsRemoved) override {
            ::obapi::Writer w;
            ::obapi::put(w, KeyId);
            ::obapi::put(w, Value);
            ::obapi::put(w, IsRemoved);
            dispatcher.dispatch(0u, w);
        }
    };

    void service_send(::obapi::Holder<::M_ErrorMemory::Service, ServiceCallbacks>& h, uint32_t op, ::obapi::Reader& r) {
        switch (op) {
            case 0u: {
                std::string KeyId{};
                ::obapi::get(r, KeyId);
                ::M_ErrorMemory::ErrorEntryType Value{};
                ::obapi::get(r, Value);
                bool IsRemoved{};
                ::obapi::get(r, IsRemoved);
                r.finish();
                h.endpoint->ReportEntry(KeyId, Value, IsRemoved);
                return;
            }
            default: throw ::obapi::UnknownOp(op);
        }
    }

    void client_send(::obapi::Holder<::M_ErrorMemory::Client, ClientCallbacks>& h, uint32_t op, ::obapi::Reader& r) {
        switch (op) {
            case 0u: {
                ::M_ErrorMemory::ErrorEntryType Value{};
                ::obapi::get(r, Value);
                r.finish();
                h.endpoint->CmdCreateEntry(Value);
                return;
            }
            case 1u: {
                std::string KeyId{};
                ::obapi::get(r, KeyId);
                r.finish();
                h.endpoint->CmdDeleteEntry(KeyId);
                return;
            }
            case 2u: {
                r.finish();
                h.endpoint->CmdDeleteAll();
                return;
            }
            default: throw ::obapi::UnknownOp(op);
        }
    }

} // namespace

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