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

#include <tango/server/NoSyncModelTangoMonitor.h>

#include <tango/server/DeviceImpl.h>
#include <tango/server/Util.h>

namespace Tango
{

//---------------------------------------------------------------------------------------------------------------
//
// class :
//        NoSyncModelTangoMonitor
//
// description :
//        This class is only a helper class used to get a TangoMonitor object during its construction and to
//        it during its destruction only if the device server process is in NO_SYNC synchronisation model
//
//---------------------------------------------------------------------------------------------------------------
NoSyncModelTangoMonitor::NoSyncModelTangoMonitor(Tango::DeviceImpl *dev)
{
    SerialModel ser = Util::instance()->get_serial_model();
    if(ser == NO_SYNC)
    {
        mon = &(dev->only_one);
        mon->get_monitor();
    }
    else
    {
        mon = nullptr;
    }
}

NoSyncModelTangoMonitor::~NoSyncModelTangoMonitor()
{
    if(mon != nullptr)
    {
        mon->rel_monitor();
    }
}

} // namespace Tango
