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

#include <tango/common/tango_const.h>
#include <tango/server/Attribute.h>

#include <memory>

namespace Tango
{
class DeviceProxy;
class DeviceAttribute;

/********************************************************************************
 *                                                                                 *
 *                         EventData class                                            *
 *                                                                                 *
 *******************************************************************************/

/**
 * Event callback execution data
 *
 * This class is used to pass data to the callback method when an event is sent to the client
 *
 *
 * @headerfile tango.h
 * @ingroup Client
 */

class EventData
{
  public:
    ///@privatesection
    EventData(Tango::DeviceProxy *dev,
              const std::string &nam,
              const std::string &evt,
              Tango::DeviceAttribute *attr_value_in,
              Tango::EventReason event_reason_in,
              const DevErrorList &errors_in);

    virtual ~EventData();
    EventData(const EventData &);
    EventData &operator=(const EventData &);
    /**
     * The date when the event arrived
     */
    Tango::TimeVal reception_date;

    Tango::TimeVal &get_date()
    {
        return reception_date;
    }

    ///@publicsection
    std::unique_ptr<DeviceAttribute>
        get_attr_err_info(); ///< Construct and return a DeviceAttribute containing the error stack

    DeviceProxy *device{nullptr};         ///< The DeviceProxy object on which the call was executed
    std::string attr_name;                ///< The attribute name
    std::string event;                    ///< The event name
    DeviceAttribute *attr_value{nullptr}; ///< The attribute data
    bool err{false};                      ///< A boolean flag set to true if the request failed. False otherwise
    EventReason event_reason{EventReason::Unknown}; ///< Reason for the event, see @ref EventReason
    DevErrorList errors;                            ///< The error stack

  private:
    void set_time();
};

} // namespace Tango

#endif // TANGO_CLIENT_EVENTDATA_H
