// Copyright 2023 Proyectos y Sistemas de Mantenimiento SL (eProsima).
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
 * @file include/fastdds/statistics/monitorservice_types.idl
 */

#include "types.idl"

module eprosima {
module fastdds {
module statistics {

    enum ConnectionMode
    {
        DATA_SHARING,
        INTRAPROCESS,
        TRANSPORT
    };

    struct Connection
    {
        ConnectionMode mode;
        detail::GUID_s guid;
        sequence<detail::Locator_s> announced_locators;
        sequence<detail::Locator_s> used_locators;
    };

    struct QosPolicyCount_s
    {
        unsigned long policy_id;
        unsigned long count;
    };

    struct BaseStatus_s
    {
        unsigned long total_count;
    };

    typedef sequence<QosPolicyCount_s> QosPolicyCountSeq_s;

    struct IncompatibleQoSStatus_s
    {
        unsigned long total_count;
        unsigned long last_policy_id;
        QosPolicyCountSeq_s policies;
    };

    struct LivelinessChangedStatus_s
    {
        unsigned long alive_count;
        unsigned long not_alive_count;
        octet last_publication_handle[16];
    };

    struct DeadlineMissedStatus_s
    {
        unsigned long total_count;
        octet last_instance_handle[16];
    };

    typedef BaseStatus_s LivelinessLostStatus_s;
    typedef BaseStatus_s InconsistentTopicStatus_s;
    typedef BaseStatus_s SampleLostStatus_s;

    struct ExtendedIncompatibleQoSStatus_s
    {
        detail::GUID_s remote_guid;
        sequence<unsigned long> current_incompatible_policies;
    };

    typedef sequence<ExtendedIncompatibleQoSStatus_s> ExtendedIncompatibleQoSStatusSeq_s;

    module StatusKind
    {
        typedef unsigned long StatusKind;

        const StatusKind PROXY                     = 0;
        const StatusKind CONNECTION_LIST           = 1;
        const StatusKind INCOMPATIBLE_QOS          = 2;
        const StatusKind INCONSISTENT_TOPIC        = 3;
        const StatusKind LIVELINESS_LOST           = 4;
        const StatusKind LIVELINESS_CHANGED        = 5;
        const StatusKind DEADLINE_MISSED           = 6;
        const StatusKind SAMPLE_LOST               = 7;
        const StatusKind EXTENDED_INCOMPATIBLE_QOS = 8;
        const StatusKind STATUSES_SIZE             = 9;
    }; // module StatusKind

    union MonitorServiceData switch(StatusKind::StatusKind)
    {
        case StatusKind::PROXY:
            sequence<octet> entity_proxy;
        case StatusKind::CONNECTION_LIST:
            sequence<Connection> connection_list;
        case StatusKind::INCOMPATIBLE_QOS:
            IncompatibleQoSStatus_s incompatible_qos_status;
        case StatusKind::INCONSISTENT_TOPIC:
            InconsistentTopicStatus_s inconsistent_topic_status;
        case StatusKind::LIVELINESS_LOST:
            LivelinessLostStatus_s liveliness_lost_status;
        case StatusKind::LIVELINESS_CHANGED:
            LivelinessChangedStatus_s liveliness_changed_status;
        case StatusKind::DEADLINE_MISSED:
            DeadlineMissedStatus_s deadline_missed_status;
        case StatusKind::SAMPLE_LOST:
            SampleLostStatus_s sample_lost_status;
        case StatusKind::EXTENDED_INCOMPATIBLE_QOS:
            ExtendedIncompatibleQoSStatusSeq_s extended_incompatible_qos_status;
        case StatusKind::STATUSES_SIZE:
            octet statuses_size;
    };

    struct MonitorServiceStatusData
    {
        @Key detail::GUID_s local_entity;
        @Key StatusKind::StatusKind status_kind;
        MonitorServiceData value;
    };

}; // namespace statisitcs
}; // namespace fastdds
}; // namespace eprosima
