#include "globalsize.h"

QMap<QString, int> GlobalSize::m_static_devconnectcount;


int GlobalSize::refBlueDevActive(QString key)
{
    if(m_static_devconnectcount.contains(key))
    {
        m_static_devconnectcount[key] = m_static_devconnectcount[key] + 1;
    }
    else
    {
       m_static_devconnectcount[key] = 1;
    }
    return m_static_devconnectcount[key];
}

int GlobalSize::unrefBlueDevActive(QString key)
{
    if(m_static_devconnectcount.contains(key))
    {
        m_static_devconnectcount[key] = m_static_devconnectcount[key] -1;
        if(0 == m_static_devconnectcount[key])
        {
            m_static_devconnectcount.remove(key);
            return 0;
        }
        return m_static_devconnectcount[key];
    }
    return 0;
}

bool GlobalSize::IsBlueDevActive(QString key)
{
    return m_static_devconnectcount.contains(key);
}

int GlobalSize::BlueDevActiveSize(void)
{
    return m_static_devconnectcount.size();
}
