• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

Nepomuk-Core

  • sources
  • kde-4.12
  • kdelibs
  • nepomuk-core
  • libnepomukcore
  • resource
resourcedata.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Nepomuk KDE project.
3  * Copyright (C) 2006-2010 Sebastian Trueg <trueg@kde.org>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #ifndef _NEPOMUK2_RESOURCE_DATA_H_
22 #define _NEPOMUK2_RESOURCE_DATA_H_
23 
24 #include <QtCore/QString>
25 #include <QtCore/QList>
26 #include <QtCore/QHash>
27 #include <QtCore/QMutex>
28 #include <QtCore/QAtomicInt>
29 #include <QtCore/QSet>
30 
31 #include "variant.h"
32 #include <kurl.h>
33 
34 #include <soprano/statement.h>
35 
36 
37 namespace Nepomuk2 {
38 
39  class Resource;
40  class ResourceManagerPrivate;
41 
42  class ResourceData
43  {
44  public:
45  explicit ResourceData( const QUrl& uri, const QUrl& kickOffUri, const QUrl& type_, ResourceManagerPrivate* rm );
46  ~ResourceData();
47 
48  inline bool ref(Nepomuk2::Resource* res) {
49  // Caller must lock ResourceManager mutex
50  m_resources.push_back( res );
51  return m_ref.ref();
52  }
53 
54  inline bool deref(Nepomuk2::Resource* res) {
55  // Caller must lock ResourceManager mutex
56  m_resources.removeAll( res );
57  return m_ref.deref();
58  }
59 
60  QList<Resource*> resources() const {
61  // Caller must lock ResourceManager mutex
62  return m_resources;
63  }
64 
65  inline int cnt() const {
66  return m_ref;
67  }
68 
72  bool isFile();
73 
77  QUrl uri() const;
78 
83  QUrl type();
84 
85  QHash<QUrl, Variant> allProperties();
86 
87  bool hasProperty( const QUrl& uri );
88 
89  bool hasProperty( const QUrl& p, const Variant& v );
90 
91  Variant property( const QUrl& uri );
92 
98  void setProperty( const QUrl& uri, const Variant& value );
99 
100  void addProperty( const QUrl& uri, const Variant& value );
101 
102  void removeProperty( const QUrl& uri );
103 
114  bool store();
115 
116  bool load();
117 
123  void remove( bool recursive = true );
124 
130  bool exists();
131 
132  bool isValid() const;
133 
143  void determineUri();
144 
145  void invalidateCache();
146 
150  bool operator==( const ResourceData& other ) const;
151 
152  QDebug operator<<( QDebug dbg ) const;
153 
154  ResourceManagerPrivate* rm() const { return m_rm; }
155 
157  void updateKickOffLists( const QUrl& uri, const Variant& oldvariant, const Variant& newvariant );
158 
160  void propertyRemoved( const Types::Property &prop, const QVariant &value );
161  void propertyAdded( const Types::Property &prop, const QVariant &value );
162 
163  void setWatchEnabled( bool status );
164  bool watchEnabled();
165 
168  void resetAll();
169  private:
170  ResourceData(const ResourceData&); // = delete
171  ResourceData& operator = (const ResourceData&); // = delete
172  void updateUrlLists( const QUrl& oldUrl, const QUrl& newUrl );
173  void updateIdentifierLists( const QString& oldIdentifier, const QString& newIdentifier );
174 
175  void addToWatcher();
176  void removeFromWatcher();
177 
179  QList<Resource*> m_resources;
180 
182  KUrl m_uri;
183 
186  KUrl m_nieUrl;
187 
190  QString m_naoIdentifier;
191 
193  QUrl m_type;
194 
195  QAtomicInt m_ref;
196 
197  // Protect m_cache, m_cacheDirty but also m_uri, m_nieUrl, m_naoIdentifier, m_addedToWatcher.
198  // Never lock the ResourceManager mutex after locking this one. Always before (or not at all).
199  mutable QMutex m_dataMutex;
200 
201  QHash<QUrl, Variant> m_cache;
202 
203  bool m_cacheDirty;
204  bool m_addedToWatcher;
205  bool m_watchEnabled;
206 
207  ResourceManagerPrivate* m_rm;
208  };
209 }
210 
211 QDebug operator<<( QDebug dbg, const Nepomuk2::ResourceData& );
212 
213 #endif
Nepomuk2::ResourceData::updateKickOffLists
void updateKickOffLists(const QUrl &uri, const Variant &oldvariant, const Variant &newvariant)
Updates ResourceManagerPrivate's list.
Definition: resourcedata.cpp:741
Nepomuk2::ResourceData::cnt
int cnt() const
Definition: resourcedata.h:65
Nepomuk2::ResourceData::deref
bool deref(Nepomuk2::Resource *res)
Definition: resourcedata.h:54
Nepomuk2::ResourceData::isFile
bool isFile()
Tries to determine if this resource represents a file by examining the type and the uri...
Definition: resourcedata.cpp:111
Nepomuk2::ResourceData::removeProperty
void removeProperty(const QUrl &uri)
Definition: resourcedata.cpp:499
Nepomuk2::ResourceData::allProperties
QHash< QUrl, Variant > allProperties()
Definition: resourcedata.cpp:195
Nepomuk2::ResourceData::setWatchEnabled
void setWatchEnabled(bool status)
Definition: resourcedata.cpp:815
Nepomuk2::ResourceData::setProperty
void setProperty(const QUrl &uri, const Variant &value)
Set a property.
Definition: resourcedata.cpp:389
QHash
Nepomuk2::ResourceData::property
Variant property(const QUrl &uri)
Definition: resourcedata.cpp:240
Nepomuk2::ResourceData::exists
bool exists()
This method only works with a proper URI, i.e.
Definition: resourcedata.cpp:560
Nepomuk2::ResourceData::propertyAdded
void propertyAdded(const Types::Property &prop, const QVariant &value)
Definition: resourcedata.cpp:804
Nepomuk2::ResourceData::load
bool load()
Definition: resourcedata.cpp:347
Nepomuk2::Variant
The Nepomuk Variant extends over QVariant by introducing direct support for Resource embedding...
Definition: variant.h:65
Nepomuk2::ResourceData::addProperty
void addProperty(const QUrl &uri, const Variant &value)
Definition: resourcedata.cpp:446
Nepomuk2::ResourceData::store
bool store()
Makes sure the resource is present in the RDF store.
Definition: resourcedata.cpp:259
variant.h
Nepomuk2::ResourceData::hasProperty
bool hasProperty(const QUrl &uri)
Definition: resourcedata.cpp:206
Nepomuk2::ResourceData::resources
QList< Resource * > resources() const
Definition: resourcedata.h:60
Nepomuk2::ResourceData::watchEnabled
bool watchEnabled()
Definition: resourcedata.cpp:827
Nepomuk2::ResourceData::type
QUrl type()
Definition: resourcedata.cpp:128
Nepomuk2::Types::Property
A property is a resource of type rdf:Property which relates a domain with a range.
Definition: libnepomukcore/types/property.h:52
Nepomuk2::ResourceData::invalidateCache
void invalidateCache()
Definition: resourcedata.cpp:680
Nepomuk2::ResourceData::isValid
bool isValid() const
Definition: resourcedata.cpp:574
Nepomuk2::ResourceData::determineUri
void determineUri()
Searches for the resource in the Nepomuk store using m_kickoffId and m_kickoffUri.
Definition: resourcedata.cpp:580
Nepomuk2::ResourceData::~ResourceData
~ResourceData()
Definition: resourcedata.cpp:105
Nepomuk2::ResourceData::resetAll
void resetAll()
Will reset this instance to 0 as if constructed without parameters Used by remove() and deleteData() ...
Definition: resourcedata.cpp:164
Nepomuk2::ResourceData::propertyRemoved
void propertyRemoved(const Types::Property &prop, const QVariant &value)
Called by ResourceManager (with the RM mutex locked)
Definition: resourcedata.cpp:768
operator<<
QDebug operator<<(QDebug dbg, const Nepomuk2::ResourceData &)
Definition: resourcedata.cpp:711
Nepomuk2::ResourceData::ResourceData
ResourceData(const QUrl &uri, const QUrl &kickOffUri, const QUrl &type_, ResourceManagerPrivate *rm)
Definition: resourcedata.cpp:64
Nepomuk2::ResourceData::operator<<
QDebug operator<<(QDebug dbg) const
Definition: resourcedata.cpp:699
Nepomuk2::ResourceData::rm
ResourceManagerPrivate * rm() const
Definition: resourcedata.h:154
Nepomuk2::Resource
Resource is the central object type in Nepomuk.
Definition: resource.h:93
Nepomuk2::ResourceData::ref
bool ref(Nepomuk2::Resource *res)
Definition: resourcedata.h:48
Nepomuk2::ResourceData::uri
QUrl uri() const
The URI of the resource.
Definition: resourcedata.cpp:121
Nepomuk2::ResourceData::operator==
bool operator==(const ResourceData &other) const
Compares the properties of two ResourceData objects taking into account the Deleted flag...
Definition: resourcedata.cpp:687
Nepomuk2::ResourceData
Definition: resourcedata.h:42
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:08 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Nepomuk-Core

Skip menu "Nepomuk-Core"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal