#include "RunAbstract.h"

RunAbstract::RunAbstract(InteractiveTask *task, QMutex *mutex)
{
    m_pTask = task;
    m_pMutex = mutex;
}

RunAbstract::~RunAbstract()
{
    if (m_pTask && m_pMutex)
    {
        QMutexLocker writeLocker(m_pMutex);
        m_pTask->stat = InteractiveTask::StatCompleted;
    }
}

void RunAbstract::setRespond(const QVariant &respond)
{
    if (m_pTask && m_pMutex)
    {
        QMutexLocker writeLocker(m_pMutex);
        m_pTask->respond = respond;
    }
}


QVariant RunAbstract::getRequest() const
{
    QVariant request;
    if (m_pTask && m_pMutex)
    {
        QMutexLocker writeLocker(m_pMutex);
        request = m_pTask->request;
    }
    return request;
}
