Nepomuk
term.h
Go to the documentation of this file.
00001 /* 00002 This file is part of the Nepomuk KDE project. 00003 Copyright (C) 2007-2010 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 #ifndef _NEPOMUK_SEARCH_TERM_H_ 00021 #define _NEPOMUK_SEARCH_TERM_H_ 00022 00023 #include <QtCore/QList> 00024 #include <QtCore/QUrl> 00025 #include <QtCore/QSharedDataPointer> 00026 00027 #include <Soprano/LiteralValue> 00028 00029 #include "nepomukquery_export.h" 00030 00031 namespace Nepomuk { 00032 00033 class Variant; 00034 00035 namespace Types { 00036 class Property; 00037 } 00038 00039 namespace Query { 00040 00041 class LiteralTerm; 00042 class ResourceTerm; 00043 class NegationTerm; 00044 class AndTerm; 00045 class OrTerm; 00046 class ComparisonTerm; 00047 class ResourceTypeTerm; 00048 class OptionalTerm; 00049 00050 class TermPrivate; 00051 00064 class NEPOMUKQUERY_EXPORT Term 00065 { 00066 public: 00072 enum Type { 00076 Invalid, 00077 00084 Literal, 00085 00091 Resource, 00092 00098 And, 00099 00105 Or, 00106 00113 Comparison, 00114 00120 ResourceType, 00121 00127 Negation, 00128 00136 Optional 00137 }; 00138 00142 Term(); 00143 00147 Term( const Term& other ); 00148 00152 ~Term(); 00153 00157 Term& operator=( const Term& other ); 00158 00163 bool isValid() const; 00164 00168 Type type() const; 00169 00181 Term optimized() const; 00182 00186 bool isLiteralTerm() const; 00187 00191 bool isResourceTerm() const; 00192 00196 bool isNegationTerm() const; 00197 00203 bool isOptionalTerm() const; 00204 00208 bool isAndTerm() const; 00209 00213 bool isOrTerm() const; 00214 00218 bool isComparisonTerm() const; 00219 00223 bool isResourceTypeTerm() const; 00224 00231 LiteralTerm toLiteralTerm() const; 00232 00239 ResourceTerm toResourceTerm() const; 00240 00247 NegationTerm toNegationTerm() const; 00248 00257 OptionalTerm toOptionalTerm() const; 00258 00265 AndTerm toAndTerm() const; 00266 00273 OrTerm toOrTerm() const; 00274 00281 ComparisonTerm toComparisonTerm() const; 00282 00289 ResourceTypeTerm toResourceTypeTerm() const; 00290 00298 LiteralTerm& toLiteralTerm(); 00299 00307 ResourceTerm& toResourceTerm(); 00308 00316 NegationTerm& toNegationTerm(); 00317 00327 OptionalTerm& toOptionalTerm(); 00328 00336 AndTerm& toAndTerm(); 00337 00345 OrTerm& toOrTerm(); 00346 00354 ComparisonTerm& toComparisonTerm(); 00355 00363 ResourceTypeTerm& toResourceTypeTerm(); 00364 00374 QString toString() const; 00375 00385 static Term fromString( const QString& s ); 00386 00398 static Term fromVariant( const Variant& variant ); 00399 00412 static Term fromProperty( const Types::Property& property, const Variant& variant ); 00413 00419 bool operator==( const Term& term ) const; 00420 00428 bool operator!=( const Term& term ) const; 00429 00430 // FIXME: the compiler does not find this operator! 00431 QDebug operator<<( QDebug ) const; 00432 00434 protected: 00435 Term( TermPrivate* ); 00436 00437 QSharedDataPointer<TermPrivate> d_ptr; 00438 00439 friend class TermPrivate; 00440 friend class GroupTermPrivate; 00441 friend class AndTermPrivate; 00442 friend class OrTermPrivate; 00443 friend class ComparisonTermPrivate; 00444 friend class NegationTermPrivate; 00445 friend class OptionalTermPrivate; 00446 friend class Query; 00448 }; 00449 00458 NEPOMUKQUERY_EXPORT Term operator&&( const Term& term1, const Term& term2 ); 00459 00468 NEPOMUKQUERY_EXPORT Term operator||( const Term& term1, const Term& term2 ); 00469 00479 NEPOMUKQUERY_EXPORT Term operator!( const Term& term ); 00480 00495 NEPOMUKQUERY_EXPORT ComparisonTerm operator<( const Types::Property& property, const Term& term ); 00496 00511 NEPOMUKQUERY_EXPORT ComparisonTerm operator>( const Types::Property& property, const Term& term ); 00512 00527 NEPOMUKQUERY_EXPORT ComparisonTerm operator<=( const Types::Property& property, const Term& term ); 00528 00543 NEPOMUKQUERY_EXPORT ComparisonTerm operator>=( const Types::Property& property, const Term& term ); 00544 00559 NEPOMUKQUERY_EXPORT ComparisonTerm operator==( const Types::Property& property, const Term& term ); 00560 00577 NEPOMUKQUERY_EXPORT Term operator!=( const Types::Property& property, const Term& term ); 00578 00579 NEPOMUKQUERY_EXPORT uint qHash( const Nepomuk::Query::Term& ); 00580 } 00581 00582 } 00583 00585 // there is a hand written instantiation of clone() 00586 template<> Nepomuk::Query::TermPrivate* QSharedDataPointer<Nepomuk::Query::TermPrivate>::clone(); 00589 // FIXME: the compiler does not find the operator in the class 00590 NEPOMUKQUERY_EXPORT QDebug operator<<( QDebug, const Nepomuk::Query::Term& ); 00591 00592 #endif
KDE 4.6 API Reference