• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

NepomukDaemons

result.cpp

Go to the documentation of this file.
00001 /*
00002    This file is part of the Nepomuk KDE project.
00003    Copyright (C) 2008 Sebastian Trueg <trueg@kde.org>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License version 2 as published by the Free Software Foundation.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017    Boston, MA 02110-1301, USA.
00018  */
00019 
00020 #include "result.h"
00021 #include "qurlhash.h"
00022 
00023 #include <QtCore/QSharedData>
00024 #include <QtCore/QHash>
00025 
00026 
00027 class Nepomuk::Search::Result::Private : public QSharedData
00028 {
00029 public:
00030     QUrl resource;
00031     double score;
00032     QHash<QUrl, Soprano::Node> requestProperties;
00033 };
00034 
00035 
00036 Nepomuk::Search::Result::Result()
00037     : d( new Private() )
00038 {
00039 }
00040 
00041 
00042 Nepomuk::Search::Result::Result( const QUrl& uri, double score )
00043     : d( new Private() )
00044 {
00045     d->resource = uri;
00046     d->score = score;
00047 }
00048 
00049 
00050 Nepomuk::Search::Result::Result( const Result& other )
00051 {
00052     d = other.d;
00053 }
00054 
00055 
00056 Nepomuk::Search::Result::~Result()
00057 {
00058 }
00059 
00060 
00061 Nepomuk::Search::Result& Nepomuk::Search::Result::operator=( const Result& other )
00062 {
00063     d = other.d;
00064     return *this;
00065 }
00066 
00067 
00068 double Nepomuk::Search::Result::score() const
00069 {
00070     return d->score;
00071 }
00072 
00073 
00074 QUrl Nepomuk::Search::Result::resourceUri() const
00075 {
00076     return d->resource;
00077 }
00078 
00079 
00080 void Nepomuk::Search::Result::setScore( double score )
00081 {
00082     d->score = score;
00083 }
00084 
00085 
00086 void Nepomuk::Search::Result::addRequestProperty( const QUrl& property, const Soprano::Node& value )
00087 {
00088     d->requestProperties[property] = value;
00089 }
00090 
00091 
00092 Soprano::Node Nepomuk::Search::Result::operator[]( const QUrl& property ) const
00093 {
00094     return requestProperty( property );
00095 }
00096 
00097 
00098 Soprano::Node Nepomuk::Search::Result::requestProperty( const QUrl& property ) const
00099 {
00100     QHash<QUrl, Soprano::Node>::const_iterator it = d->requestProperties.find( property );
00101     if ( it != d->requestProperties.end() ) {
00102         return *it;
00103     }
00104     else {
00105         return Soprano::Node();
00106     }
00107 }
00108 
00109 
00110 QHash<QUrl, Soprano::Node> Nepomuk::Search::Result::requestProperties() const
00111 {
00112     return d->requestProperties;
00113 }
00114 
00115 
00116 bool Nepomuk::Search::Result::operator==( const Result& other ) const
00117 {
00118     if ( d->resource != other.d->resource ||
00119          d->score != other.d->score ) {
00120         return false;
00121     }
00122     for ( QHash<QUrl, Soprano::Node>::const_iterator it = d->requestProperties.constBegin();
00123           it != d->requestProperties.constEnd(); ++it ) {
00124         QHash<QUrl, Soprano::Node>::const_iterator it2 = other.d->requestProperties.constFind( it.key() );
00125         if ( it2 == other.d->requestProperties.constEnd() ||
00126              it2.value() != it.value() ) {
00127             return false;
00128         }
00129     }
00130     for ( QHash<QUrl, Soprano::Node>::const_iterator it = other.d->requestProperties.constBegin();
00131           it != other.d->requestProperties.constEnd(); ++it ) {
00132         QHash<QUrl, Soprano::Node>::const_iterator it2 = d->requestProperties.constFind( it.key() );
00133         if ( it2 == d->requestProperties.constEnd() ||
00134              it2.value() != it.value() ) {
00135             return false;
00136         }
00137     }
00138     return true;
00139 }

NepomukDaemons

Skip menu "NepomukDaemons"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • KCMShell
  • KNotify
  • KStyles
  • Nepomuk Daemons
Generated for API Reference by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal