File indexing completed on 2023-12-03 08:28:33

0001 /*
0002  * Copyright (C) 2013  Daniel Vrátil <dvratil@redhat.com>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Lesser General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2.1 of the License, or (at your option) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  * Lesser General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Lesser General Public
0015  * License along with this library; if not, write to the Free Software
0016  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
0017  *
0018  */
0019 
0020 #include "log-entity.h"
0021 
0022 using namespace KTp;
0023 
0024 class LogEntity::Private: public QSharedData
0025 {
0026   public:
0027     Private(Tp::HandleType entityType_, const QString &id_, const QString &alias_):
0028         QSharedData(),
0029         entityType(entityType_),
0030         id(id_),
0031         alias(alias_)
0032     {
0033     }
0034 
0035     Private():
0036         QSharedData(),
0037         entityType(Tp::HandleTypeNone)
0038     {
0039     }
0040 
0041     Private(const Private &other):
0042         QSharedData(other),
0043         entityType(other.entityType),
0044         id(other.id),
0045         alias(other.alias)
0046     {
0047     }
0048 
0049     ~Private()
0050     {
0051     }
0052 
0053     bool operator==(const Private &other)
0054     {
0055         return entityType == other.entityType
0056                 && id == other.id
0057                 && alias == other.alias;
0058     }
0059 
0060     Tp::HandleType entityType;
0061     QString id;
0062     QString alias;
0063 };
0064 
0065 LogEntity::LogEntity(Tp::HandleType entityType, const QString& id, const QString& alias):
0066     d(new Private(entityType, id, alias))
0067 {
0068 }
0069 
0070 LogEntity::LogEntity():
0071     d(new Private)
0072 {
0073 }
0074 
0075 LogEntity::LogEntity(const LogEntity& other):
0076     d(other.d)
0077 {
0078 }
0079 
0080 LogEntity::~LogEntity()
0081 {
0082 }
0083 
0084 LogEntity& LogEntity::operator=(const LogEntity& other)
0085 {
0086     if (this != &other) {
0087         d = other.d;
0088     }
0089 
0090     return *this;
0091 }
0092 
0093 bool LogEntity::operator==(const LogEntity& other)
0094 {
0095     return *d == *other.d;
0096 }
0097 
0098 bool LogEntity::operator!=(const LogEntity& other)
0099 {
0100     return !(operator==(other));
0101 }
0102 
0103 bool LogEntity::isValid() const
0104 {
0105     return d->entityType != Tp::HandleTypeNone
0106             && !d->id.isEmpty()
0107             && !d->alias.isEmpty();
0108 }
0109 
0110 Tp::HandleType LogEntity::entityType() const
0111 {
0112     return d->entityType;
0113 }
0114 
0115 QString LogEntity::id() const
0116 {
0117     return d->id;
0118 }
0119 
0120 QString LogEntity::alias() const
0121 {
0122     return d->alias;
0123 }