/* ============================================================
 *
 * This file is a part of kipi-plugins project
 * http://www.kipi-plugins.org
 *
 * Date        : 2011-12-28
 * Description : prints debugging messages about the thread activity in action thread class
 *
 * Copyright (C) 2011-2012 by A Janardhan Reddy <annapareddyjanardhanreddy at gmail dot com>
 *
 * This program is free software; you can redistribute it
 * and/or modify it under the terms of the GNU General
 * Public License as published by the Free Software Foundation;
 * either version 2, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * ============================================================ */

#include "weaverobservertest.moc"

// KDE includes

#include <kdebug.h>

using namespace ThreadWeaver;

WeaverObserverTest::WeaverObserverTest(QObject* parent)
    : WeaverObserver(parent)
{
    connect(this, SIGNAL(weaverStateChanged(ThreadWeaver::State*)),
            SLOT(slotWeaverStateChanged(ThreadWeaver::State*)));
    
    connect(this, SIGNAL(threadStarted(ThreadWeaver::Thread*)),
            SLOT(slotThreadStarted(ThreadWeaver::Thread*)));

    connect(this, SIGNAL(threadBusy(ThreadWeaver::Thread*, ThreadWeaver::Job*)),
            SLOT(slotThreadBusy(ThreadWeaver::Thread*, ThreadWeaver::Job*)));

    connect(this, SIGNAL(threadSuspended(ThreadWeaver::Thread*)),
            SLOT(slotThreadSuspended(ThreadWeaver::Thread*)));

    connect(this, SIGNAL(threadExited(ThreadWeaver::Thread*)),
            SLOT(slotThreadExited(ThreadWeaver::Thread*)));
}

void WeaverObserverTest::slotWeaverStateChanged(State* state)
{
    kDebug() << "WeaverObserverTest: thread state changed to " << state->stateName();
}

void WeaverObserverTest::slotThreadStarted(Thread* th)
{
    kDebug() << "WeaverObserverTest: thread " << th->id()  <<" started" << endl;
}

void WeaverObserverTest::slotThreadBusy(Thread* th, Job* /*job*/)
{
    kDebug() << "WeaverObserverTest: thread " << th->id()  << " busy" << endl;
}

void WeaverObserverTest::slotThreadSuspended(Thread* th )
{
    kDebug() << "WeaverObserverTest: thread " << th->id()  << " suspended" << endl;
}

void WeaverObserverTest::slotThreadExited(Thread* th)
{
    kDebug() << "WeaverObserverTest: thread " << th->id()  << " exited" << endl;
}
