/*
 * 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 shpin.cpp
 * @brief Stores plug-ins' pin details
 * @author Daniel Pisi
 */

#include "shpin.h"

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

/**
 * \brief Constructor of ShMessage, an initialization of the object
 */
ShPin::ShPin()
{
    mObjectId = 0;
    mSignal   = "";
    mInput    = mOutput = false;
    mType     = ptUnknown;
}
// -----------------------------------------------------------------------------

/**
 * \brief Sets the pin id
 * \param id Pin id
 */
void ShPin::setObjectId(int id)
{
    mObjectId = id;
}
// -----------------------------------------------------------------------------

/**
 * \brief Sets a name of the signal
 * \param signal Name of the signal
 */
void ShPin::setSignal(QString signal)
{
    mSignal = signal;
}
// -----------------------------------------------------------------------------

/**
 * \brief Sets the pin direction
 * \param direction Pin direction, "i" denotes input, "o" output and "io" bi-directional pin
 */
void ShPin::setDirection(QString direction)
{
    mInput  = direction.contains('i');
    mOutput = direction.contains('o');
}
// -----------------------------------------------------------------------------

/**
 * \brief Sets the pin type
 * \param type Pin type
 */
void ShPin::setType(QString type)
{
         if (type == "bool")    mType = ptBool;
    else if (type == "int")     mType = ptInt;
    else if (type == "real")    mType = ptReal;
    else if (type == "string")  mType = ptString;
    else if (type == "variant") mType = ptVariant;
}
// -----------------------------------------------------------------------------
