/****************************************************************************
**
** Copyright (C) 2012 Róbert Márki
**
** This file is part of Web Feeds.
**
** Web Feeds 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 3 of the License, or
** (at your option) any later version.
**
** Web Feeds 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.
**
** You should have received a copy of the GNU General Public License
** along with Web Feeds.  If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/

#include "feedclassifiers.h"

namespace NewsBlur
{
/*!
  \class FeedClassifiers
  \brief The FeedClassifiers class represents the various classifiers
  of a NewsBlur feed.
*/

/*!
  Constructs a FeedClassifiers object with the given \a parent.
*/
FeedClassifiers::FeedClassifiers(QObject *parent) :
    QObject(parent),
    m_feedClassifier(NewsBlurEnum::CvUndefinedClassifierValue)
{
}

/*!
  Constructs a copy of \a other.
*/
FeedClassifiers::FeedClassifiers(const FeedClassifiers &other) :
    QObject(other.parent())
{
    *this = other;
}

/*!
  Returns true if the object hasn't been initialized yet,
  otherwise returns false.
*/
bool FeedClassifiers::isNull() const
{
    return (m_titleClassifiers.isEmpty() && m_authorClassifiers.isEmpty()
            && m_tagClassifiers.isEmpty() && (m_feedClassifier == NewsBlurEnum::CvUndefinedClassifierValue));
}

/*!
  Returns the story title classifiers.
*/
ClassifierHash FeedClassifiers::titleClassifiers() const
{
    return m_titleClassifiers;
}

/*!
  \sa FeedClassifiers::titleClassifiers
*/
void FeedClassifiers::setTitleClassifiers(const ClassifierHash &titleClassifiers)
{
    m_titleClassifiers = titleClassifiers;
}

/*!
  Returns the classifiers of authors.
*/
ClassifierHash FeedClassifiers::authorClassifiers() const
{
    return m_authorClassifiers;
}

/*!
  \sa FeedClassifiers::authorClassifiers
*/
void FeedClassifiers::setAuthorClassifiers(const ClassifierHash &authorClassifiers)
{
    m_authorClassifiers = authorClassifiers;
}

/*!
  Returns the tag classifiers.
*/
ClassifierHash FeedClassifiers::tagClassifiers() const
{
    return m_tagClassifiers;
}

/*!
  \sa FeedClassifiers::tagClassifiers
*/
void FeedClassifiers::setTagClassifiers(const ClassifierHash &tagClassifiers)
{
    m_tagClassifiers = tagClassifiers;
}

/*!
  Returns the classification of the related feed.
*/
NewsBlurEnum::ClassifierValue FeedClassifiers::feedClassifier() const
{
    return m_feedClassifier;
}

/*!
  \sa FeedClassifiers::feedClassifier
*/
void FeedClassifiers::setFeedClassifier(NewsBlurEnum::ClassifierValue feedClassifier)
{
    m_feedClassifier = feedClassifier;
}

/*!
  Assigns \a other to this and returns a reference to this object.
*/
FeedClassifiers &FeedClassifiers::operator =(const FeedClassifiers &other)
{
    if(this != &other)
    {
        m_titleClassifiers = other.m_titleClassifiers;
        m_authorClassifiers = other.m_authorClassifiers;
        m_tagClassifiers = other.m_tagClassifiers;
        m_feedClassifier = other.m_feedClassifier;
    }
    return *this;
}

/*!
  Returns true if \a other is equal to this object,
  otherwise returns false.
*/
bool FeedClassifiers::operator ==(const FeedClassifiers &other) const
{
    return ((m_titleClassifiers == other.m_titleClassifiers)
            && (m_authorClassifiers == other.m_authorClassifiers)
            && (m_tagClassifiers == other.m_tagClassifiers)
            && (m_feedClassifier == other.m_feedClassifier));
}
} // namespace NewsBlur
