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

#ifndef TANGO_SERVER_AUTOTANGOMONITOR_H
#define TANGO_SERVER_AUTOTANGOMONITOR_H

#include <tango/common/omnithread_wrapper.h>

#include <memory>

namespace Tango
{
class DeviceImpl;
class DeviceClass;
class TangoMonitor;

//-------------------------------------------------------------------------------------------------------------------
//
// class :
//        AutoTangoMonitor
//
// description :
//        This class is only a helper class used to get a TangoMonitor object during its construction and to
//        it during its destruction. It makes developer life easier.
//
//-------------------------------------------------------------------------------------------------------------------

class AutoTangoMonitor
{
  public:
    AutoTangoMonitor(Tango::DeviceImpl *dev, bool force = false);

    AutoTangoMonitor(Tango::DeviceClass *dev_cl);

    AutoTangoMonitor(Tango::TangoMonitor *m);
    AutoTangoMonitor(const std::shared_ptr<Tango::TangoMonitor> &m);

    ~AutoTangoMonitor();

  private:
    TangoMonitor *mon;
    omni_thread::ensure_self auto_self;
};

} // namespace Tango

#endif /* AUTO_TANGO_MONITOR */
