• 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
  • services
  • storage
resourcewatchermanager.h
Go to the documentation of this file.
1 /*
2  This file is part of the Nepomuk KDE project.
3  Copyright (C) 2011 Vishesh Handa <handa.vish@gmail.com>
4  Copyright (C) 2011-2012 Sebastian Trueg <trueg@kde.org>
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License along
17  with this program; if not, write to the Free Software Foundation, Inc.,
18  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20 
21 
22 #ifndef RESOURCEWATCHMANAGER_H
23 #define RESOURCEWATCHMANAGER_H
24 
25 #include <QtCore/QMultiHash>
26 #include <QtCore/QSet>
27 #include <QtCore/QMutex>
28 
29 #include <Soprano/FilterModel>
30 #include <QtDBus/QDBusObjectPath>
31 #include <QtDBus/QDBusContext>
32 
33 namespace Nepomuk2 {
34 
35  class ResourceWatcherConnection;
36  class DataManagementModel;
37 
38  class ResourceWatcherManager : public QObject, protected QDBusContext
39  {
40  Q_OBJECT
41  Q_CLASSINFO( "D-Bus Interface", "org.kde.nepomuk.ResourceWatcher" )
42 
43  public:
44  ResourceWatcherManager( DataManagementModel* parent = 0 );
45  ~ResourceWatcherManager();
46 
47  // IDEA: would it be more efficient to have three lists/sets: keptValues, newValues, removedValues?
48  void changeProperty(const QUrl& res,
49  const QUrl& property,
50  const QList<Soprano::Node>& addedValues,
51  const QList<Soprano::Node>& removedValues);
52  void changeProperty(const QMultiHash<QUrl, Soprano::Node>& oldValues, const QUrl& property,
53  const QList<Soprano::Node>& nodes);
54  void createResource(const QUrl& uri, const QSet<QUrl>& types);
55  void removeResource(const QUrl& uri, const QList<QUrl>& types);
56 
58  void changeSomething();
59 
60  signals:
68  Q_SCRIPTABLE void somethingChanged();
69 
70  public slots:
74  ResourceWatcherConnection* createConnection(const QList<QUrl>& resources,
75  const QList<QUrl>& properties,
76  const QList<QUrl>& types );
77 
81  Q_SCRIPTABLE QDBusObjectPath watch( const QStringList& resources,
82  const QStringList& properties,
83  const QStringList& types );
84 
85  private:
87  void removeConnection(ResourceWatcherConnection*);
88 
90  void setResources(ResourceWatcherConnection* conn, const QStringList& resources);
91  void addResource(ResourceWatcherConnection* conn, const QString& resource);
92  void removeResource(ResourceWatcherConnection* conn, const QString& resource);
93  void setProperties(ResourceWatcherConnection* conn, const QStringList& propertys);
94  void addProperty(ResourceWatcherConnection* conn, const QString& property);
95  void removeProperty(ResourceWatcherConnection* conn, const QString& property);
96  void setTypes(ResourceWatcherConnection* conn, const QStringList& types);
97  void addType(ResourceWatcherConnection* conn, const QString& type);
98  void removeType(ResourceWatcherConnection* conn, const QString& type);
99 
101  void changeTypes(const QUrl& res, const QSet<QUrl> &resTypes, const QSet<QUrl> &addedTypes, const QSet<QUrl> &removedTypes);
102 
104  bool connectionWatchesOneType(ResourceWatcherConnection* con, const QSet<QUrl> &types) const;
105 
106  DataManagementModel* m_model;
107 
108  QMultiHash<QUrl, ResourceWatcherConnection*> m_resHash;
109  QMultiHash<QUrl, ResourceWatcherConnection*> m_propHash;
110  QMultiHash<QUrl, ResourceWatcherConnection*> m_typeHash;
111  QSet<ResourceWatcherConnection*> m_watchAllConnections;
112 
113  mutable QMutex m_mutex;
114  // only used to generate unique dbus paths
115  int m_connectionCount;
116 
117  friend class ResourceWatcherConnection;
118  };
119 
120 }
121 
122 #endif // RESOURCEWATCHMANAGER_H
QMultiHash
Nepomuk2::ResourceWatcherConnection
Definition: resourcewatcherconnection.h:34
Nepomuk2::ResourceWatcherManager::createConnection
ResourceWatcherConnection * createConnection(const QList< QUrl > &resources, const QList< QUrl > &properties, const QList< QUrl > &types)
Used internally by watch() and by the unit tests to create watcher connections.
Definition: resourcewatchermanager.cpp:286
Nepomuk2::ResourceWatcherManager::somethingChanged
Q_SCRIPTABLE void somethingChanged()
A special signal which is emitted whenever something changes in the store.
QDBusContext
Nepomuk2::ResourceWatcherManager::~ResourceWatcherManager
~ResourceWatcherManager()
Definition: resourcewatchermanager.cpp:111
Nepomuk2::ResourceWatcherManager::changeSomething
void changeSomething()
to be called whenever something changes (preferably after calling any of the above) ...
Definition: resourcewatchermanager.cpp:279
QObject
Nepomuk2::ResourceWatcherManager::watch
Q_SCRIPTABLE QDBusObjectPath watch(const QStringList &resources, const QStringList &properties, const QStringList &types)
The main DBus methods exposed by the ResourceWatcher.
Definition: resourcewatchermanager.cpp:313
Nepomuk2::ResourceWatcherManager::createResource
void createResource(const QUrl &uri, const QSet< QUrl > &types)
Definition: resourcewatchermanager.cpp:233
Nepomuk2::ResourceWatcherManager::removeResource
void removeResource(const QUrl &uri, const QList< QUrl > &types)
Definition: resourcewatchermanager.cpp:252
Nepomuk2::ResourceWatcherManager::ResourceWatcherManager
ResourceWatcherManager(DataManagementModel *parent=0)
Definition: resourcewatchermanager.cpp:101
Nepomuk2::ResourceWatcherManager
Definition: resourcewatchermanager.h:38
Nepomuk2::ResourceWatcherManager::changeProperty
void changeProperty(const QUrl &res, const QUrl &property, const QList< Soprano::Node > &addedValues, const QList< Soprano::Node > &removedValues)
Definition: resourcewatchermanager.cpp:125
Nepomuk2::DataManagementModel
Definition: datamanagementmodel.h:39
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:09 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