/*
 * SPDX-FileCopyrightText: 2025 Copyright contributors to the cppTango project
 *
 * SPDX-License-Identifier: LGPL-3.0-or-later
 */

#ifndef TANGO_SERVER_EVENTDATAKIND_H
#define TANGO_SERVER_EVENTDATAKIND_H

#include <string>
#include <vector>

namespace Tango
{

// Each enumerant corresponds to a slot on the
// EventSupplier::SuppliedEventData struct used to send events. This
// only includes slots which are sent to clients.
//
// For the notifd event system, the client can be at most IDLv4, so ATTR_VAL_5
// and ATTR_CONF_5 are not used. For the notifd event system, the exact version
// of the data is determined by the IDL version of the Tango device.  In this
// sense, ATTR_VAL_3 corresponds to one of ATTR_VAL_3/ATTR_VAL_2/ATTR_VAL, based
// on the Tango device IDL version. If an old IDLv3 (cppTango 6) client
// subscribes to the notifd event system, then all clients will receive an
// ATTR_VAL_3 event.  There is likely a bug since cppTango 9 in this, as an
// ATTR_VAL_4 event will also be sent if both an cppTango 6 and cppTango 7
// client subscribe to the same attribute on the cppTango 9 server.  For
// previous versions (e.g. cppTango 8) of the server, this would have only
// resulted in a ATTR_VAL_3 event being sent.
//
// For the ZMQ event system, devices and clients must both be using IDLv4
// so ATTR_VAL_3 is never sent. (Although, the ZMQ event system does contain
// code to support sending e.g. ATTR_VAL_3 over the event system based on the
// IDL version of the Tango device this has not been possible since cppTango
// 8.1 when a check to disallow devices using IDLv3 or older).
//
// For ATTR_VAL_5/ATTR_CONF_5 events, a separate IDLv5 topic is used to send the
// events, e.g. "idl5_change" to maintain compatibility.  Old clients will then
// still receive events with ATTR_VAL_4/ATTR_CONF_3 data via the original topic
// e.g. "change".
//
// As the same data structures are used by the notifd and ZMQ event systems,
// there is a likely a bug if a cppTango 8 and cppTango 6 client both susbscribe
// to the same attribute on a cppTango 9 device.  This will result in ATTR_VAL_3
// data being sent over the original ZMQ topic, whereas the cppTango 8 client
// will be expecting ATTR_VAL_4 as the device IDL version > 4.
enum class EventDataKind
{
    ATTR_VAL_3,
    ATTR_VAL_4,
    ATTR_VAL_5,
    ATTR_CONF_3,
    ATTR_CONF_5,
    ATTR_DATA_READY,
    DEV_INTR_CHANGE,
    PIPE_VAL,
    INVALID,
};

std::string to_string(EventDataKind kind);

using EventDataKinds = std::vector<EventDataKind>;

} // namespace Tango

#endif
