#include "cspeaker.h"
#include <QString>

cSpeaker::cSpeaker()
{

}

cSpeaker::cSpeaker(std::string name, unsigned short imp, unsigned short rmsPower, unsigned short peakPower, unsigned short hpf)
{
    m_name=name;
    m_imp=imp;
    m_rmsPower=rmsPower;
    m_peakPower=peakPower;
    m_hpf=hpf;
}

std::string cSpeaker::getName()
{
    return m_name;
}

unsigned short cSpeaker::getImpedance()
{
    return m_imp;
}

unsigned short cSpeaker::getRMSPower()
{
    return m_rmsPower;
}

unsigned short cSpeaker::getPeakPower()
{
    return m_peakPower;
}

unsigned short cSpeaker::getHPF()
{
    return m_hpf;
}

void cSpeaker::setName(std::string name)
{
    m_name=name;
}

void cSpeaker::setImpedance(unsigned short imp)
{
    m_imp=imp;
}

void cSpeaker::setRMSPower(unsigned short rmsPower)
{
    m_rmsPower=rmsPower;
}

void cSpeaker::setPeakPower(unsigned short peakPower)
{
    m_peakPower=peakPower;
}

void cSpeaker::setHPF(unsigned short hpf)
{
    m_hpf=hpf;
}

QDataStream& operator<<(QDataStream& out, cSpeaker& speaker){
    out << QString::fromStdString(speaker.getName());
    out << (quint16)speaker.getImpedance();
    out << (quint16)speaker.getRMSPower();
    out << (quint16)speaker.getPeakPower();
    out << (quint16)speaker.getHPF();
    return out;
}

QDataStream& operator>>(QDataStream& in, cSpeaker& speaker){
    QString name;
    in >> name;
    speaker.m_name=name.toStdString();

    quint16 imp,rmsPower,peakPower,hpf;

    in >> imp;
    in >> rmsPower;
    in >> peakPower;
    in >> hpf;

    speaker.m_imp=(unsigned short)imp;
    speaker.m_rmsPower=(unsigned short)rmsPower;
    speaker.m_peakPower=(unsigned short)peakPower;
    speaker.m_hpf=(unsigned short)hpf;


    return in;
}
