/*
 * SmartHome server: Base of the system
 *
 * Copyright (C) 2010 Daniel Pisi <dan.pisi@gmail.com>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of version 2 of the GNU General Public License
 * as published by the Free Software Foundation.
 *
 */

/**
 * @file shobjecthelper.h
 * @brief Implements basic plug-in methods
 * @author Daniel Pisi
 */

#ifndef SHOBJECTHELPER_H
#define SHOBJECTHELPER_H

#include <QObject>
#include "shobject.h"

// -----------------------------------------------------------------------------

/**
 * \class ShObjectHelper
 * \brief Plug-in template class
 *
 * Implements the most frequent used methods making the development of new plug-ins
 * more convenient and faster.
 */
class ShObjectHelper : public QObject, public ShObject
{
    Q_OBJECT
    Q_INTERFACES(ShObject)

public:
    ShObjectHelper(QObject *parent = 0);

    virtual int  objectId()           { return mId; };
    virtual void setObjectId(int id)  { mId = id; }

    virtual bool idApi()              { return mIdApi; };
    virtual void setIdApi(bool idApi) { mIdApi = idApi; };

    void dispatchMessage(ShMessagePtr message);
    void ackMessage(ShMessagePtr message);
    void errorMessage(ShMessagePtr message, QString reason);

    void outputUpdated(QString signal, QVariant value);

signals:
    void newMessage(ShMessagePtr message);

private:
    int  mId;
    bool mIdApi;
};
// -----------------------------------------------------------------------------

#endif // SHOBJECTHELPER_H
