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

#include <tango/client/ApiUtil.h>
#include <tango/client/EventConsumer.h>
#include <tango/common/PointerWithLock.h>

namespace Tango
{

/********************************************************************************
 *                                                                                 *
 *                         DelayedEventSubThread class                                *
 *                                                                                 *
 *******************************************************************************/

// NOLINTNEXTLINE(cppcoreguidelines-virtual-class-destructor)
class DelayedEventSubThread : public omni_thread
{
  public:
    DelayedEventSubThread(EventConsumer *ec,
                          DeviceProxy *_device,
                          const std::string &_attribute,
                          EventType _event,
                          CallBack *_callback,
                          EventQueue *_ev_queue,
                          const std::string &_ev_name,
                          int _id,
                          EventSubMode _event_sub_mode) :

        ev_cons(ApiUtil::instance()->get_locked_event_consumer(ec)),
        device(_device),
        attribute(_attribute),
        et(_event),
        callback(_callback),
        ev_queue(_ev_queue),
        ev_id(_id),
        event_name(_ev_name),
        event_sub_mode(_event_sub_mode)
    {
    }

    void run(void *) override;

  private:
    PointerWithLock<EventConsumer> ev_cons;
    DeviceProxy *device;
    std::string attribute;
    EventType et;
    CallBack *callback;
    EventQueue *ev_queue;
    int ev_id;
    std::string event_name;
    EventSubMode event_sub_mode;

    ~DelayedEventSubThread() override = default;
};

} // namespace Tango

#endif
