/*
 * Copyright (C) 2014-2022 CZ.NIC
 *
 * This program 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.
 *
 * This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * In addition, as a special exception, the copyright holders give
 * permission to link the code of portions of this program with the
 * OpenSSL library under certain conditions as described in each
 * individual source file, and distribute linked combinations including
 * the two.
 */

#pragma once

#include <QMetaType>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
#  include <memory> /* ::std::unique_ptr */
#else /* < Qt-5.12 */
#  include <QScopedPointer>
#endif /* >= Qt-5.12 */

class TagEntry; /* Forward declaration. */
class QString; /* Forward declaration. */

class TagAssignmentPrivate;
/*!
 * @brief Encapsulates database tag assignment data.
 */
class TagAssignment {
	Q_DECLARE_PRIVATE(TagAssignment)
public:
	TagAssignment(void);
	TagAssignment(const TagAssignment &other);
#ifdef Q_COMPILER_RVALUE_REFS
	TagAssignment(TagAssignment &&other) Q_DECL_NOEXCEPT;
#endif /* Q_COMPILER_RVALUE_REFS */
	~TagAssignment(void);

	TagAssignment(const QString &username, bool testing, qint64 dmId,
	    const QList<TagEntry> &entries);
#ifdef Q_COMPILER_RVALUE_REFS
	TagAssignment(QString &&username, bool testing, qint64 dmId,
	    QList<TagEntry> &&entries);
#endif /* Q_COMPILER_RVALUE_REFS */

	TagAssignment &operator=(const TagAssignment &other) Q_DECL_NOTHROW;
#ifdef Q_COMPILER_RVALUE_REFS
	TagAssignment &operator=(TagAssignment &&other) Q_DECL_NOTHROW;
#endif /* Q_COMPILER_RVALUE_REFS */

	bool operator==(const TagAssignment &other) const;
	bool operator!=(const TagAssignment &other) const;

	friend void swap(TagAssignment &first, TagAssignment &second) Q_DECL_NOTHROW;

	bool isNull(void) const;

	const QString &username(void) const;
	void setUsername(const QString &n);
#ifdef Q_COMPILER_RVALUE_REFS
	void setUsername(QString &&n);
#endif /* Q_COMPILER_RVALUE_REFS */

	bool testing(void) const;
	void setTesting(bool t);

	qint64 dmId(void) const;
	void setDmId(qint64 di);

	const QList<TagEntry> &entries(void) const;
	void setEntries(const QList<TagEntry> &e);
#ifdef Q_COMPILER_RVALUE_REFS
	void setEntries(QList<TagEntry> &&e);
#endif /* Q_COMPILER_RVALUE_REFS */

private:
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
	::std::unique_ptr<TagAssignmentPrivate> d_ptr;
#else /* < Qt-5.12 */
	QScopedPointer<TagAssignmentPrivate> d_ptr;
#endif /* >= Qt-5.12 */
};

void swap(TagAssignment &first, TagAssignment &second) Q_DECL_NOTHROW;

Q_DECLARE_METATYPE(TagAssignment)
