// Copyright (c) ZeroC, Inc.

// slice2cpp version 3.8.1
// <auto-generated>Generated from Slice file 'Metrics.ice'.</auto-generated>

#ifndef ICE_API_EXPORTS
#   define ICE_API_EXPORTS
#endif
#define ICE_BUILDING_GENERATED_CODE

#include "Ice/Metrics.h"
#include <Ice/AsyncResponseHandler.h>
#include <Ice/DefaultSliceLoader.h>
#include <Ice/OutgoingAsync.h>
#include <algorithm>
#include <array>

#if defined(_MSC_VER)
#   pragma warning(disable : 4458) // declaration of ... hides class member
#   pragma warning(disable : 4996) // ... was declared deprecated
#elif defined(__clang__)
#   pragma clang diagnostic ignored "-Wshadow"
#   pragma clang diagnostic ignored "-Wdeprecated-declarations"
#elif defined(__GNUC__)
#   pragma GCC diagnostic ignored "-Wshadow"
#   pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif

#ifndef ICE_DISABLE_VERSION
#   if ICE_INT_VERSION / 100 != 308
#       error Ice version mismatch!
#   endif
#   if ICE_INT_VERSION % 100 >= 50
#       error Beta header file detected
#   endif
#   if ICE_INT_VERSION % 100 < 1
#       error Ice patch level mismatch!
#   endif
#endif

namespace
{
    const IceInternal::ClassInit<::IceMX::Metrics> iceC_IceMX_Metrics_init;
    const IceInternal::ExceptionInit<::IceMX::UnknownMetricsView> iceC_IceMX_UnknownMetricsView_init;
    const IceInternal::ClassInit<::IceMX::ThreadMetrics> iceC_IceMX_ThreadMetrics_init;
    const IceInternal::ClassInit<::IceMX::DispatchMetrics> iceC_IceMX_DispatchMetrics_init;
    const IceInternal::ClassInit<::IceMX::ChildInvocationMetrics> iceC_IceMX_ChildInvocationMetrics_init;
    const IceInternal::ClassInit<::IceMX::CollocatedMetrics> iceC_IceMX_CollocatedMetrics_init;
    const IceInternal::ClassInit<::IceMX::RemoteMetrics> iceC_IceMX_RemoteMetrics_init;
    const IceInternal::ClassInit<::IceMX::InvocationMetrics> iceC_IceMX_InvocationMetrics_init;
    const IceInternal::ClassInit<::IceMX::ConnectionMetrics> iceC_IceMX_ConnectionMetrics_init;
}

IceMX::MetricsAdminPrx::~MetricsAdminPrx() = default;

::Ice::StringSeq
IceMX::MetricsAdminPrx::getMetricsViewNames(::Ice::StringSeq& iceP_disabledViews, const Ice::Context& context) const
{
    auto result = IceInternal::makePromiseOutgoing<std::tuple<::Ice::StringSeq, ::Ice::StringSeq>>(true, this, &MetricsAdminPrx::_iceI_getMetricsViewNames, context).get();
    iceP_disabledViews = std::move(std::get<1>(result));
    return std::move(std::get<0>(result));
}

std::future<std::tuple<::Ice::StringSeq, ::Ice::StringSeq>>
IceMX::MetricsAdminPrx::getMetricsViewNamesAsync(const Ice::Context& context) const
{
    return IceInternal::makePromiseOutgoing<std::tuple<::Ice::StringSeq, ::Ice::StringSeq>>(false, this, &MetricsAdminPrx::_iceI_getMetricsViewNames, context);
}

std::function<void()>
IceMX::MetricsAdminPrx::getMetricsViewNamesAsync(std::function<void(::Ice::StringSeq, ::Ice::StringSeq)> response, std::function<void(std::exception_ptr)> exception, std::function<void(bool)> sent, const Ice::Context& context) const
{
    auto responseCb = [response = std::move(response)](std::tuple<::Ice::StringSeq, ::Ice::StringSeq>&& result) mutable
    {
        std::apply(std::move(response), std::move(result));
    };
    return IceInternal::makeLambdaOutgoing<std::tuple<::Ice::StringSeq, ::Ice::StringSeq>>(std::move(responseCb), std::move(exception), std::move(sent), this, &IceMX::MetricsAdminPrx::_iceI_getMetricsViewNames, context);
}

void
IceMX::MetricsAdminPrx::_iceI_getMetricsViewNames(const std::shared_ptr<IceInternal::OutgoingAsyncT<std::tuple<::Ice::StringSeq, ::Ice::StringSeq>>>& outAsync, const Ice::Context& context) const
{
    static constexpr std::string_view operationName = "getMetricsViewNames";

    _checkTwowayOnly(operationName);
    outAsync->invoke(
        operationName,
        Ice::OperationMode::Normal,
        std::nullopt,
        context,
        nullptr,
        nullptr,
        [](Ice::InputStream* istr)
        {
            std::tuple<::Ice::StringSeq, ::Ice::StringSeq> v;
            istr->readAll(std::get<1>(v), std::get<0>(v));
            return v;
        });
}

void
IceMX::MetricsAdminPrx::enableMetricsView(std::string_view iceP_name, const Ice::Context& context) const
{
    IceInternal::makePromiseOutgoing<void>(true, this, &MetricsAdminPrx::_iceI_enableMetricsView, iceP_name, context).get();
}

std::future<void>
IceMX::MetricsAdminPrx::enableMetricsViewAsync(std::string_view iceP_name, const Ice::Context& context) const
{
    return IceInternal::makePromiseOutgoing<void>(false, this, &MetricsAdminPrx::_iceI_enableMetricsView, iceP_name, context);
}

std::function<void()>
IceMX::MetricsAdminPrx::enableMetricsViewAsync(std::string_view iceP_name, std::function<void()> response, std::function<void(std::exception_ptr)> exception, std::function<void(bool)> sent, const Ice::Context& context) const
{
    return IceInternal::makeLambdaOutgoing<void>(std::move(response), std::move(exception), std::move(sent), this, &IceMX::MetricsAdminPrx::_iceI_enableMetricsView, iceP_name, context);
}

void
IceMX::MetricsAdminPrx::_iceI_enableMetricsView(const std::shared_ptr<IceInternal::OutgoingAsyncT<void>>& outAsync, std::string_view iceP_name, const Ice::Context& context) const
{
    static constexpr std::string_view operationName = "enableMetricsView";

    _checkTwowayOnly(operationName);
    outAsync->invoke(
        operationName,
        Ice::OperationMode::Normal,
        std::nullopt,
        context,
        [&](Ice::OutputStream* ostr)
        {
            ostr->writeAll(iceP_name);
        },
        [](const Ice::UserException& ex)
        {
            try
            {
                ex.ice_throw();
            }
            catch (const UnknownMetricsView&)
            {
                throw;
            }
            catch (const Ice::UserException&)
            {
            }
        });
}

void
IceMX::MetricsAdminPrx::disableMetricsView(std::string_view iceP_name, const Ice::Context& context) const
{
    IceInternal::makePromiseOutgoing<void>(true, this, &MetricsAdminPrx::_iceI_disableMetricsView, iceP_name, context).get();
}

std::future<void>
IceMX::MetricsAdminPrx::disableMetricsViewAsync(std::string_view iceP_name, const Ice::Context& context) const
{
    return IceInternal::makePromiseOutgoing<void>(false, this, &MetricsAdminPrx::_iceI_disableMetricsView, iceP_name, context);
}

std::function<void()>
IceMX::MetricsAdminPrx::disableMetricsViewAsync(std::string_view iceP_name, std::function<void()> response, std::function<void(std::exception_ptr)> exception, std::function<void(bool)> sent, const Ice::Context& context) const
{
    return IceInternal::makeLambdaOutgoing<void>(std::move(response), std::move(exception), std::move(sent), this, &IceMX::MetricsAdminPrx::_iceI_disableMetricsView, iceP_name, context);
}

void
IceMX::MetricsAdminPrx::_iceI_disableMetricsView(const std::shared_ptr<IceInternal::OutgoingAsyncT<void>>& outAsync, std::string_view iceP_name, const Ice::Context& context) const
{
    static constexpr std::string_view operationName = "disableMetricsView";

    _checkTwowayOnly(operationName);
    outAsync->invoke(
        operationName,
        Ice::OperationMode::Normal,
        std::nullopt,
        context,
        [&](Ice::OutputStream* ostr)
        {
            ostr->writeAll(iceP_name);
        },
        [](const Ice::UserException& ex)
        {
            try
            {
                ex.ice_throw();
            }
            catch (const UnknownMetricsView&)
            {
                throw;
            }
            catch (const Ice::UserException&)
            {
            }
        });
}

::IceMX::MetricsView
IceMX::MetricsAdminPrx::getMetricsView(std::string_view iceP_view, std::int64_t& iceP_timestamp, const Ice::Context& context) const
{
    auto result = IceInternal::makePromiseOutgoing<std::tuple<MetricsView, std::int64_t>>(true, this, &MetricsAdminPrx::_iceI_getMetricsView, iceP_view, context).get();
    iceP_timestamp = std::get<1>(result);
    return std::move(std::get<0>(result));
}

std::future<std::tuple<::IceMX::MetricsView, std::int64_t>>
IceMX::MetricsAdminPrx::getMetricsViewAsync(std::string_view iceP_view, const Ice::Context& context) const
{
    return IceInternal::makePromiseOutgoing<std::tuple<MetricsView, std::int64_t>>(false, this, &MetricsAdminPrx::_iceI_getMetricsView, iceP_view, context);
}

std::function<void()>
IceMX::MetricsAdminPrx::getMetricsViewAsync(std::string_view iceP_view, std::function<void(::IceMX::MetricsView, std::int64_t)> response, std::function<void(std::exception_ptr)> exception, std::function<void(bool)> sent, const Ice::Context& context) const
{
    auto responseCb = [response = std::move(response)](std::tuple<MetricsView, std::int64_t>&& result) mutable
    {
        std::apply(std::move(response), std::move(result));
    };
    return IceInternal::makeLambdaOutgoing<std::tuple<MetricsView, std::int64_t>>(std::move(responseCb), std::move(exception), std::move(sent), this, &IceMX::MetricsAdminPrx::_iceI_getMetricsView, iceP_view, context);
}

void
IceMX::MetricsAdminPrx::_iceI_getMetricsView(const std::shared_ptr<IceInternal::OutgoingAsyncT<std::tuple<MetricsView, std::int64_t>>>& outAsync, std::string_view iceP_view, const Ice::Context& context) const
{
    static constexpr std::string_view operationName = "getMetricsView";

    _checkTwowayOnly(operationName);
    outAsync->invoke(
        operationName,
        Ice::OperationMode::Normal,
        Ice::FormatType::SlicedFormat,
        context,
        [&](Ice::OutputStream* ostr)
        {
            ostr->writeAll(iceP_view);
        },
        [](const Ice::UserException& ex)
        {
            try
            {
                ex.ice_throw();
            }
            catch (const UnknownMetricsView&)
            {
                throw;
            }
            catch (const Ice::UserException&)
            {
            }
        },
        [](Ice::InputStream* istr)
        {
            std::tuple<MetricsView, std::int64_t> v;
            istr->readAll(std::get<1>(v), std::get<0>(v));
            istr->readPendingValues();
            return v;
        });
}

::IceMX::MetricsFailuresSeq
IceMX::MetricsAdminPrx::getMapMetricsFailures(std::string_view iceP_view, std::string_view iceP_map, const Ice::Context& context) const
{
    return IceInternal::makePromiseOutgoing<MetricsFailuresSeq>(true, this, &MetricsAdminPrx::_iceI_getMapMetricsFailures, iceP_view, iceP_map, context).get();
}

std::future<::IceMX::MetricsFailuresSeq>
IceMX::MetricsAdminPrx::getMapMetricsFailuresAsync(std::string_view iceP_view, std::string_view iceP_map, const Ice::Context& context) const
{
    return IceInternal::makePromiseOutgoing<MetricsFailuresSeq>(false, this, &MetricsAdminPrx::_iceI_getMapMetricsFailures, iceP_view, iceP_map, context);
}

std::function<void()>
IceMX::MetricsAdminPrx::getMapMetricsFailuresAsync(std::string_view iceP_view, std::string_view iceP_map, std::function<void(::IceMX::MetricsFailuresSeq)> response, std::function<void(std::exception_ptr)> exception, std::function<void(bool)> sent, const Ice::Context& context) const
{
    return IceInternal::makeLambdaOutgoing<MetricsFailuresSeq>(std::move(response), std::move(exception), std::move(sent), this, &IceMX::MetricsAdminPrx::_iceI_getMapMetricsFailures, iceP_view, iceP_map, context);
}

void
IceMX::MetricsAdminPrx::_iceI_getMapMetricsFailures(const std::shared_ptr<IceInternal::OutgoingAsyncT<MetricsFailuresSeq>>& outAsync, std::string_view iceP_view, std::string_view iceP_map, const Ice::Context& context) const
{
    static constexpr std::string_view operationName = "getMapMetricsFailures";

    _checkTwowayOnly(operationName);
    outAsync->invoke(
        operationName,
        Ice::OperationMode::Normal,
        std::nullopt,
        context,
        [&](Ice::OutputStream* ostr)
        {
            ostr->writeAll(iceP_view, iceP_map);
        },
        [](const Ice::UserException& ex)
        {
            try
            {
                ex.ice_throw();
            }
            catch (const UnknownMetricsView&)
            {
                throw;
            }
            catch (const Ice::UserException&)
            {
            }
        });
}

::IceMX::MetricsFailures
IceMX::MetricsAdminPrx::getMetricsFailures(std::string_view iceP_view, std::string_view iceP_map, std::string_view iceP_id, const Ice::Context& context) const
{
    return IceInternal::makePromiseOutgoing<MetricsFailures>(true, this, &MetricsAdminPrx::_iceI_getMetricsFailures, iceP_view, iceP_map, iceP_id, context).get();
}

std::future<::IceMX::MetricsFailures>
IceMX::MetricsAdminPrx::getMetricsFailuresAsync(std::string_view iceP_view, std::string_view iceP_map, std::string_view iceP_id, const Ice::Context& context) const
{
    return IceInternal::makePromiseOutgoing<MetricsFailures>(false, this, &MetricsAdminPrx::_iceI_getMetricsFailures, iceP_view, iceP_map, iceP_id, context);
}

std::function<void()>
IceMX::MetricsAdminPrx::getMetricsFailuresAsync(std::string_view iceP_view, std::string_view iceP_map, std::string_view iceP_id, std::function<void(::IceMX::MetricsFailures)> response, std::function<void(std::exception_ptr)> exception, std::function<void(bool)> sent, const Ice::Context& context) const
{
    return IceInternal::makeLambdaOutgoing<MetricsFailures>(std::move(response), std::move(exception), std::move(sent), this, &IceMX::MetricsAdminPrx::_iceI_getMetricsFailures, iceP_view, iceP_map, iceP_id, context);
}

void
IceMX::MetricsAdminPrx::_iceI_getMetricsFailures(const std::shared_ptr<IceInternal::OutgoingAsyncT<MetricsFailures>>& outAsync, std::string_view iceP_view, std::string_view iceP_map, std::string_view iceP_id, const Ice::Context& context) const
{
    static constexpr std::string_view operationName = "getMetricsFailures";

    _checkTwowayOnly(operationName);
    outAsync->invoke(
        operationName,
        Ice::OperationMode::Normal,
        std::nullopt,
        context,
        [&](Ice::OutputStream* ostr)
        {
            ostr->writeAll(iceP_view, iceP_map, iceP_id);
        },
        [](const Ice::UserException& ex)
        {
            try
            {
                ex.ice_throw();
            }
            catch (const UnknownMetricsView&)
            {
                throw;
            }
            catch (const Ice::UserException&)
            {
            }
        });
}

const char*
IceMX::MetricsAdminPrx::ice_staticId() noexcept
{
    return "::IceMX::MetricsAdmin";
}

const char*
IceMX::Metrics::ice_staticId() noexcept
{
    return "::IceMX::Metrics";
}

const char*
IceMX::Metrics::ice_id() const noexcept
{
    return ice_staticId();
}

void
IceMX::Metrics::ice_printFields(std::ostream& os) const
{
    Ice::print(os << "id = ", this->id);
    Ice::print(os << ", total = ", this->total);
    Ice::print(os << ", current = ", this->current);
    Ice::print(os << ", totalLifetime = ", this->totalLifetime);
    Ice::print(os << ", failures = ", this->failures);
}

Ice::ValuePtr
IceMX::Metrics::_iceCloneImpl() const
{
    return CloneEnabler<Metrics>::clone(*this);
}

void
IceMX::Metrics::_iceWriteImpl(Ice::OutputStream* ostr) const
{
    ostr->startSlice(ice_staticId(), -1, true);
    ostr->writeAll(this->id, this->total, this->current, this->totalLifetime, this->failures);
    ostr->endSlice();
}

void
IceMX::Metrics::_iceReadImpl(Ice::InputStream* istr)
{
    istr->startSlice();
    istr->readAll(this->id, this->total, this->current, this->totalLifetime, this->failures);
    istr->endSlice();
}

void
IceMX::MetricsFailures::ice_printFields(std::ostream& os) const
{
    Ice::print(os << "id = ", this->id);
    Ice::print(os << ", failures = ", this->failures);
}

std::ostream&
IceMX::operator<<(std::ostream& os, const ::IceMX::MetricsFailures& value)
{
    os << "IceMX::MetricsFailures{";
    value.ice_printFields(os);
    os << '}';
    return os;
}

const char*
IceMX::UnknownMetricsView::ice_staticId() noexcept
{
    return "::IceMX::UnknownMetricsView";
}

const char*
IceMX::UnknownMetricsView::ice_id() const noexcept
{
    return ice_staticId();
}

void
IceMX::UnknownMetricsView::ice_throw() const
{
    throw *this;
}

void
IceMX::UnknownMetricsView::_writeImpl(Ice::OutputStream* ostr) const
{
    ostr->startSlice(ice_staticId(), -1, true);
    ostr->endSlice();
}

void
IceMX::UnknownMetricsView::_readImpl(Ice::InputStream* istr)
{
    istr->startSlice();
    istr->endSlice();
}

const char*
IceMX::ThreadMetrics::ice_staticId() noexcept
{
    return "::IceMX::ThreadMetrics";
}

const char*
IceMX::ThreadMetrics::ice_id() const noexcept
{
    return ice_staticId();
}

void
IceMX::ThreadMetrics::ice_printFields(std::ostream& os) const
{
    Metrics::ice_printFields(os);
    Ice::print(os << ", inUseForIO = ", this->inUseForIO);
    Ice::print(os << ", inUseForUser = ", this->inUseForUser);
    Ice::print(os << ", inUseForOther = ", this->inUseForOther);
}

Ice::ValuePtr
IceMX::ThreadMetrics::_iceCloneImpl() const
{
    return CloneEnabler<ThreadMetrics>::clone(*this);
}

void
IceMX::ThreadMetrics::_iceWriteImpl(Ice::OutputStream* ostr) const
{
    ostr->startSlice(ice_staticId(), -1, false);
    ostr->writeAll(this->inUseForIO, this->inUseForUser, this->inUseForOther);
    ostr->endSlice();
    Metrics::_iceWriteImpl(ostr);
}

void
IceMX::ThreadMetrics::_iceReadImpl(Ice::InputStream* istr)
{
    istr->startSlice();
    istr->readAll(this->inUseForIO, this->inUseForUser, this->inUseForOther);
    istr->endSlice();
    Metrics::_iceReadImpl(istr);
}

const char*
IceMX::DispatchMetrics::ice_staticId() noexcept
{
    return "::IceMX::DispatchMetrics";
}

const char*
IceMX::DispatchMetrics::ice_id() const noexcept
{
    return ice_staticId();
}

void
IceMX::DispatchMetrics::ice_printFields(std::ostream& os) const
{
    Metrics::ice_printFields(os);
    Ice::print(os << ", userException = ", this->userException);
    Ice::print(os << ", size = ", this->size);
    Ice::print(os << ", replySize = ", this->replySize);
}

Ice::ValuePtr
IceMX::DispatchMetrics::_iceCloneImpl() const
{
    return CloneEnabler<DispatchMetrics>::clone(*this);
}

void
IceMX::DispatchMetrics::_iceWriteImpl(Ice::OutputStream* ostr) const
{
    ostr->startSlice(ice_staticId(), -1, false);
    ostr->writeAll(this->userException, this->size, this->replySize);
    ostr->endSlice();
    Metrics::_iceWriteImpl(ostr);
}

void
IceMX::DispatchMetrics::_iceReadImpl(Ice::InputStream* istr)
{
    istr->startSlice();
    istr->readAll(this->userException, this->size, this->replySize);
    istr->endSlice();
    Metrics::_iceReadImpl(istr);
}

const char*
IceMX::ChildInvocationMetrics::ice_staticId() noexcept
{
    return "::IceMX::ChildInvocationMetrics";
}

const char*
IceMX::ChildInvocationMetrics::ice_id() const noexcept
{
    return ice_staticId();
}

void
IceMX::ChildInvocationMetrics::ice_printFields(std::ostream& os) const
{
    Metrics::ice_printFields(os);
    Ice::print(os << ", size = ", this->size);
    Ice::print(os << ", replySize = ", this->replySize);
}

Ice::ValuePtr
IceMX::ChildInvocationMetrics::_iceCloneImpl() const
{
    return CloneEnabler<ChildInvocationMetrics>::clone(*this);
}

void
IceMX::ChildInvocationMetrics::_iceWriteImpl(Ice::OutputStream* ostr) const
{
    ostr->startSlice(ice_staticId(), -1, false);
    ostr->writeAll(this->size, this->replySize);
    ostr->endSlice();
    Metrics::_iceWriteImpl(ostr);
}

void
IceMX::ChildInvocationMetrics::_iceReadImpl(Ice::InputStream* istr)
{
    istr->startSlice();
    istr->readAll(this->size, this->replySize);
    istr->endSlice();
    Metrics::_iceReadImpl(istr);
}

const char*
IceMX::CollocatedMetrics::ice_staticId() noexcept
{
    return "::IceMX::CollocatedMetrics";
}

const char*
IceMX::CollocatedMetrics::ice_id() const noexcept
{
    return ice_staticId();
}

Ice::ValuePtr
IceMX::CollocatedMetrics::_iceCloneImpl() const
{
    return CloneEnabler<CollocatedMetrics>::clone(*this);
}

void
IceMX::CollocatedMetrics::_iceWriteImpl(Ice::OutputStream* ostr) const
{
    ostr->startSlice(ice_staticId(), -1, false);
    ostr->endSlice();
    ChildInvocationMetrics::_iceWriteImpl(ostr);
}

void
IceMX::CollocatedMetrics::_iceReadImpl(Ice::InputStream* istr)
{
    istr->startSlice();
    istr->endSlice();
    ChildInvocationMetrics::_iceReadImpl(istr);
}

const char*
IceMX::RemoteMetrics::ice_staticId() noexcept
{
    return "::IceMX::RemoteMetrics";
}

const char*
IceMX::RemoteMetrics::ice_id() const noexcept
{
    return ice_staticId();
}

Ice::ValuePtr
IceMX::RemoteMetrics::_iceCloneImpl() const
{
    return CloneEnabler<RemoteMetrics>::clone(*this);
}

void
IceMX::RemoteMetrics::_iceWriteImpl(Ice::OutputStream* ostr) const
{
    ostr->startSlice(ice_staticId(), -1, false);
    ostr->endSlice();
    ChildInvocationMetrics::_iceWriteImpl(ostr);
}

void
IceMX::RemoteMetrics::_iceReadImpl(Ice::InputStream* istr)
{
    istr->startSlice();
    istr->endSlice();
    ChildInvocationMetrics::_iceReadImpl(istr);
}

const char*
IceMX::InvocationMetrics::ice_staticId() noexcept
{
    return "::IceMX::InvocationMetrics";
}

const char*
IceMX::InvocationMetrics::ice_id() const noexcept
{
    return ice_staticId();
}

void
IceMX::InvocationMetrics::ice_printFields(std::ostream& os) const
{
    Metrics::ice_printFields(os);
    Ice::print(os << ", retry = ", this->retry);
    Ice::print(os << ", userException = ", this->userException);
    Ice::print(os << ", remotes = ", this->remotes);
    Ice::print(os << ", collocated = ", this->collocated);
}

Ice::ValuePtr
IceMX::InvocationMetrics::_iceCloneImpl() const
{
    return CloneEnabler<InvocationMetrics>::clone(*this);
}

void
IceMX::InvocationMetrics::_iceWriteImpl(Ice::OutputStream* ostr) const
{
    ostr->startSlice(ice_staticId(), -1, false);
    ostr->writeAll(this->retry, this->userException, this->remotes, this->collocated);
    ostr->endSlice();
    Metrics::_iceWriteImpl(ostr);
}

void
IceMX::InvocationMetrics::_iceReadImpl(Ice::InputStream* istr)
{
    istr->startSlice();
    istr->readAll(this->retry, this->userException, this->remotes, this->collocated);
    istr->endSlice();
    Metrics::_iceReadImpl(istr);
}

const char*
IceMX::ConnectionMetrics::ice_staticId() noexcept
{
    return "::IceMX::ConnectionMetrics";
}

const char*
IceMX::ConnectionMetrics::ice_id() const noexcept
{
    return ice_staticId();
}

void
IceMX::ConnectionMetrics::ice_printFields(std::ostream& os) const
{
    Metrics::ice_printFields(os);
    Ice::print(os << ", receivedBytes = ", this->receivedBytes);
    Ice::print(os << ", sentBytes = ", this->sentBytes);
}

Ice::ValuePtr
IceMX::ConnectionMetrics::_iceCloneImpl() const
{
    return CloneEnabler<ConnectionMetrics>::clone(*this);
}

void
IceMX::ConnectionMetrics::_iceWriteImpl(Ice::OutputStream* ostr) const
{
    ostr->startSlice(ice_staticId(), -1, false);
    ostr->writeAll(this->receivedBytes, this->sentBytes);
    ostr->endSlice();
    Metrics::_iceWriteImpl(ostr);
}

void
IceMX::ConnectionMetrics::_iceReadImpl(Ice::InputStream* istr)
{
    istr->startSlice();
    istr->readAll(this->receivedBytes, this->sentBytes);
    istr->endSlice();
    Metrics::_iceReadImpl(istr);
}

void
IceMX::MetricsAdmin::dispatch(Ice::IncomingRequest& request, std::function<void(Ice::OutgoingResponse)> sendResponse)
{
    static constexpr std::array<std::string_view, 10> allOperations{"disableMetricsView", "enableMetricsView", "getMapMetricsFailures", "getMetricsFailures", "getMetricsView", "getMetricsViewNames", "ice_id", "ice_ids", "ice_isA", "ice_ping"};

    const Ice::Current& current = request.current();
    auto r = std::equal_range(allOperations.begin(), allOperations.end(), current.operation); // NOLINT(modernize-use-ranges)
    if (r.first == r.second)
    {
        sendResponse(Ice::makeOutgoingResponse(std::make_exception_ptr(Ice::OperationNotExistException{__FILE__, __LINE__}), current));
        return;
    }

    switch (r.first - allOperations.begin())
    {
        case 0:
        {
            _iceD_disableMetricsView(request, std::move(sendResponse));
            break;
        }
        case 1:
        {
            _iceD_enableMetricsView(request, std::move(sendResponse));
            break;
        }
        case 2:
        {
            _iceD_getMapMetricsFailures(request, std::move(sendResponse));
            break;
        }
        case 3:
        {
            _iceD_getMetricsFailures(request, std::move(sendResponse));
            break;
        }
        case 4:
        {
            _iceD_getMetricsView(request, std::move(sendResponse));
            break;
        }
        case 5:
        {
            _iceD_getMetricsViewNames(request, std::move(sendResponse));
            break;
        }
        case 6:
        {
            _iceD_ice_id(request, std::move(sendResponse));
            break;
        }
        case 7:
        {
            _iceD_ice_ids(request, std::move(sendResponse));
            break;
        }
        case 8:
        {
            _iceD_ice_isA(request, std::move(sendResponse));
            break;
        }
        case 9:
        {
            _iceD_ice_ping(request, std::move(sendResponse));
            break;
        }
        default:
        {
            assert(false);
            sendResponse(Ice::makeOutgoingResponse(std::make_exception_ptr(Ice::OperationNotExistException{__FILE__, __LINE__}), current));
        }
    }
}

std::vector<std::string>
IceMX::MetricsAdmin::ice_ids(const Ice::Current&) const
{
    static const std::vector<std::string> allTypeIds = {"::Ice::Object", "::IceMX::MetricsAdmin"};
    return allTypeIds;
}

std::string
IceMX::MetricsAdmin::ice_id(const Ice::Current&) const
{
    return std::string{ice_staticId()};
}

void
IceMX::MetricsAdmin::_iceD_getMetricsViewNames(
    Ice::IncomingRequest& request,
    std::function<void(Ice::OutgoingResponse)> sendResponse) // NOLINT(performance-unnecessary-value-param)
{
    checkNonIdempotent(request.current());
    request.inputStream().skipEmptyEncapsulation();
    ::Ice::StringSeq iceP_disabledViews;
    const ::Ice::StringSeq ret = this->getMetricsViewNames(iceP_disabledViews, request.current());
    sendResponse(Ice::makeOutgoingResponse([&](Ice::OutputStream* ostr)
        {
            ostr->writeAll(iceP_disabledViews, ret);
        },
        request.current()));
}

void
IceMX::MetricsAdmin::_iceD_enableMetricsView(
    Ice::IncomingRequest& request,
    std::function<void(Ice::OutgoingResponse)> sendResponse) // NOLINT(performance-unnecessary-value-param)
{
    checkNonIdempotent(request.current());
    auto istr = &request.inputStream();
    istr->startEncapsulation();
    std::string iceP_name;
    istr->readAll(iceP_name);
    istr->endEncapsulation();
    this->enableMetricsView(std::move(iceP_name), request.current());
    sendResponse(Ice::makeEmptyOutgoingResponse(request.current()));
}

void
IceMX::MetricsAdmin::_iceD_disableMetricsView(
    Ice::IncomingRequest& request,
    std::function<void(Ice::OutgoingResponse)> sendResponse) // NOLINT(performance-unnecessary-value-param)
{
    checkNonIdempotent(request.current());
    auto istr = &request.inputStream();
    istr->startEncapsulation();
    std::string iceP_name;
    istr->readAll(iceP_name);
    istr->endEncapsulation();
    this->disableMetricsView(std::move(iceP_name), request.current());
    sendResponse(Ice::makeEmptyOutgoingResponse(request.current()));
}

void
IceMX::MetricsAdmin::_iceD_getMetricsView(
    Ice::IncomingRequest& request,
    std::function<void(Ice::OutgoingResponse)> sendResponse) // NOLINT(performance-unnecessary-value-param)
{
    checkNonIdempotent(request.current());
    auto istr = &request.inputStream();
    istr->startEncapsulation();
    std::string iceP_view;
    istr->readAll(iceP_view);
    istr->endEncapsulation();
    std::int64_t iceP_timestamp;
    const MetricsView ret = this->getMetricsView(std::move(iceP_view), iceP_timestamp, request.current());
    sendResponse(Ice::makeOutgoingResponse([&](Ice::OutputStream* ostr)
        {
            ostr->writeAll(iceP_timestamp, ret);
            ostr->writePendingValues();
        },
        request.current(),
        Ice::FormatType::SlicedFormat));
}

void
IceMX::MetricsAdmin::_iceD_getMapMetricsFailures(
    Ice::IncomingRequest& request,
    std::function<void(Ice::OutgoingResponse)> sendResponse) // NOLINT(performance-unnecessary-value-param)
{
    checkNonIdempotent(request.current());
    auto istr = &request.inputStream();
    istr->startEncapsulation();
    std::string iceP_view;
    std::string iceP_map;
    istr->readAll(iceP_view, iceP_map);
    istr->endEncapsulation();
    const MetricsFailuresSeq ret = this->getMapMetricsFailures(std::move(iceP_view), std::move(iceP_map), request.current());
    sendResponse(Ice::makeOutgoingResponse([&](Ice::OutputStream* ostr)
        {
            ostr->writeAll(ret);
        },
        request.current()));
}

void
IceMX::MetricsAdmin::_iceD_getMetricsFailures(
    Ice::IncomingRequest& request,
    std::function<void(Ice::OutgoingResponse)> sendResponse) // NOLINT(performance-unnecessary-value-param)
{
    checkNonIdempotent(request.current());
    auto istr = &request.inputStream();
    istr->startEncapsulation();
    std::string iceP_view;
    std::string iceP_map;
    std::string iceP_id;
    istr->readAll(iceP_view, iceP_map, iceP_id);
    istr->endEncapsulation();
    const MetricsFailures ret = this->getMetricsFailures(std::move(iceP_view), std::move(iceP_map), std::move(iceP_id), request.current());
    sendResponse(Ice::makeOutgoingResponse([&](Ice::OutputStream* ostr)
        {
            ostr->writeAll(ret);
        },
        request.current()));
}

const char*
IceMX::MetricsAdmin::ice_staticId() noexcept
{
    return "::IceMX::MetricsAdmin";
}

void
IceMX::AsyncMetricsAdmin::dispatch(Ice::IncomingRequest& request, std::function<void(Ice::OutgoingResponse)> sendResponse)
{
    static constexpr std::array<std::string_view, 10> allOperations{"disableMetricsView", "enableMetricsView", "getMapMetricsFailures", "getMetricsFailures", "getMetricsView", "getMetricsViewNames", "ice_id", "ice_ids", "ice_isA", "ice_ping"};

    const Ice::Current& current = request.current();
    auto r = std::equal_range(allOperations.begin(), allOperations.end(), current.operation); // NOLINT(modernize-use-ranges)
    if (r.first == r.second)
    {
        sendResponse(Ice::makeOutgoingResponse(std::make_exception_ptr(Ice::OperationNotExistException{__FILE__, __LINE__}), current));
        return;
    }

    switch (r.first - allOperations.begin())
    {
        case 0:
        {
            _iceD_disableMetricsView(request, std::move(sendResponse));
            break;
        }
        case 1:
        {
            _iceD_enableMetricsView(request, std::move(sendResponse));
            break;
        }
        case 2:
        {
            _iceD_getMapMetricsFailures(request, std::move(sendResponse));
            break;
        }
        case 3:
        {
            _iceD_getMetricsFailures(request, std::move(sendResponse));
            break;
        }
        case 4:
        {
            _iceD_getMetricsView(request, std::move(sendResponse));
            break;
        }
        case 5:
        {
            _iceD_getMetricsViewNames(request, std::move(sendResponse));
            break;
        }
        case 6:
        {
            _iceD_ice_id(request, std::move(sendResponse));
            break;
        }
        case 7:
        {
            _iceD_ice_ids(request, std::move(sendResponse));
            break;
        }
        case 8:
        {
            _iceD_ice_isA(request, std::move(sendResponse));
            break;
        }
        case 9:
        {
            _iceD_ice_ping(request, std::move(sendResponse));
            break;
        }
        default:
        {
            assert(false);
            sendResponse(Ice::makeOutgoingResponse(std::make_exception_ptr(Ice::OperationNotExistException{__FILE__, __LINE__}), current));
        }
    }
}

std::vector<std::string>
IceMX::AsyncMetricsAdmin::ice_ids(const Ice::Current&) const
{
    static const std::vector<std::string> allTypeIds = {"::Ice::Object", "::IceMX::MetricsAdmin"};
    return allTypeIds;
}

std::string
IceMX::AsyncMetricsAdmin::ice_id(const Ice::Current&) const
{
    return std::string{ice_staticId()};
}

void
IceMX::AsyncMetricsAdmin::_iceD_getMetricsViewNames(
    Ice::IncomingRequest& request,
    std::function<void(Ice::OutgoingResponse)> sendResponse)
{
    checkNonIdempotent(request.current());
    request.inputStream().skipEmptyEncapsulation();
    auto responseHandler = std::make_shared<IceInternal::AsyncResponseHandler>(std::move(sendResponse), request.current());
    auto responseCb = [responseHandler](const ::Ice::StringSeq& ret, const ::Ice::StringSeq& iceP_disabledViews)
    {
        responseHandler->sendResponse(
            [&](Ice::OutputStream* ostr)
            {
                ostr->writeAll(iceP_disabledViews, ret);
            });
    };
    try
    {
        this->getMetricsViewNamesAsync(std::move(responseCb), [responseHandler](std::exception_ptr ex) { responseHandler->sendException(ex); }, responseHandler->current());
    }
    catch (...)
    {
        responseHandler->sendException(std::current_exception());
    }
}

void
IceMX::AsyncMetricsAdmin::_iceD_enableMetricsView(
    Ice::IncomingRequest& request,
    std::function<void(Ice::OutgoingResponse)> sendResponse)
{
    checkNonIdempotent(request.current());
    auto istr = &request.inputStream();
    istr->startEncapsulation();
    std::string iceP_name;
    istr->readAll(iceP_name);
    istr->endEncapsulation();
    auto responseHandler = std::make_shared<IceInternal::AsyncResponseHandler>(std::move(sendResponse), request.current());
    try
    {
        this->enableMetricsViewAsync(std::move(iceP_name), [responseHandler] { responseHandler->sendEmptyResponse(); }, [responseHandler](std::exception_ptr ex) { responseHandler->sendException(ex); }, responseHandler->current());
    }
    catch (...)
    {
        responseHandler->sendException(std::current_exception());
    }
}

void
IceMX::AsyncMetricsAdmin::_iceD_disableMetricsView(
    Ice::IncomingRequest& request,
    std::function<void(Ice::OutgoingResponse)> sendResponse)
{
    checkNonIdempotent(request.current());
    auto istr = &request.inputStream();
    istr->startEncapsulation();
    std::string iceP_name;
    istr->readAll(iceP_name);
    istr->endEncapsulation();
    auto responseHandler = std::make_shared<IceInternal::AsyncResponseHandler>(std::move(sendResponse), request.current());
    try
    {
        this->disableMetricsViewAsync(std::move(iceP_name), [responseHandler] { responseHandler->sendEmptyResponse(); }, [responseHandler](std::exception_ptr ex) { responseHandler->sendException(ex); }, responseHandler->current());
    }
    catch (...)
    {
        responseHandler->sendException(std::current_exception());
    }
}

void
IceMX::AsyncMetricsAdmin::_iceD_getMetricsView(
    Ice::IncomingRequest& request,
    std::function<void(Ice::OutgoingResponse)> sendResponse)
{
    checkNonIdempotent(request.current());
    auto istr = &request.inputStream();
    istr->startEncapsulation();
    std::string iceP_view;
    istr->readAll(iceP_view);
    istr->endEncapsulation();
    auto responseHandler = std::make_shared<IceInternal::AsyncResponseHandler>(std::move(sendResponse), request.current());
    auto responseCb = [responseHandler](const MetricsView& ret, std::int64_t iceP_timestamp)
    {
        responseHandler->sendResponse(
            [&](Ice::OutputStream* ostr)
            {
                ostr->writeAll(iceP_timestamp, ret);
                ostr->writePendingValues();
            },
            Ice::FormatType::SlicedFormat);
    };
    try
    {
        this->getMetricsViewAsync(std::move(iceP_view), std::move(responseCb), [responseHandler](std::exception_ptr ex) { responseHandler->sendException(ex); }, responseHandler->current());
    }
    catch (...)
    {
        responseHandler->sendException(std::current_exception());
    }
}

void
IceMX::AsyncMetricsAdmin::_iceD_getMapMetricsFailures(
    Ice::IncomingRequest& request,
    std::function<void(Ice::OutgoingResponse)> sendResponse)
{
    checkNonIdempotent(request.current());
    auto istr = &request.inputStream();
    istr->startEncapsulation();
    std::string iceP_view;
    std::string iceP_map;
    istr->readAll(iceP_view, iceP_map);
    istr->endEncapsulation();
    auto responseHandler = std::make_shared<IceInternal::AsyncResponseHandler>(std::move(sendResponse), request.current());
    auto responseCb = [responseHandler](const MetricsFailuresSeq& ret)
    {
        responseHandler->sendResponse(
            [&](Ice::OutputStream* ostr)
            {
                ostr->writeAll(ret);
            });
    };
    try
    {
        this->getMapMetricsFailuresAsync(std::move(iceP_view), std::move(iceP_map), std::move(responseCb), [responseHandler](std::exception_ptr ex) { responseHandler->sendException(ex); }, responseHandler->current());
    }
    catch (...)
    {
        responseHandler->sendException(std::current_exception());
    }
}

void
IceMX::AsyncMetricsAdmin::_iceD_getMetricsFailures(
    Ice::IncomingRequest& request,
    std::function<void(Ice::OutgoingResponse)> sendResponse)
{
    checkNonIdempotent(request.current());
    auto istr = &request.inputStream();
    istr->startEncapsulation();
    std::string iceP_view;
    std::string iceP_map;
    std::string iceP_id;
    istr->readAll(iceP_view, iceP_map, iceP_id);
    istr->endEncapsulation();
    auto responseHandler = std::make_shared<IceInternal::AsyncResponseHandler>(std::move(sendResponse), request.current());
    auto responseCb = [responseHandler](const MetricsFailures& ret)
    {
        responseHandler->sendResponse(
            [&](Ice::OutputStream* ostr)
            {
                ostr->writeAll(ret);
            });
    };
    try
    {
        this->getMetricsFailuresAsync(std::move(iceP_view), std::move(iceP_map), std::move(iceP_id), std::move(responseCb), [responseHandler](std::exception_ptr ex) { responseHandler->sendException(ex); }, responseHandler->current());
    }
    catch (...)
    {
        responseHandler->sendException(std::current_exception());
    }
}

const char*
IceMX::AsyncMetricsAdmin::ice_staticId() noexcept
{
    return "::IceMX::MetricsAdmin";
}
