~ubuntu-branches/ubuntu/natty/kdebase-runtime/natty-proposed

« back to all changes in this revision

Viewing changes to nepomuk/services/backupsync/lib/simpleresource.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-11-24 11:07:10 UTC
  • mto: (0.8.7 upstream)
  • mto: This revision was merged to the branch mainline in revision 129.
  • Revision ID: james.westby@ubuntu.com-20101124110710-6dbsyw0yh21qvn82
Tags: upstream-4.5.80
ImportĀ upstreamĀ versionĀ 4.5.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    This file is part of the Nepomuk KDE project.
 
3
    Copyright (C) 2010  Vishesh Handa <handa.vish@gmail.com>
 
4
 
 
5
   This library is free software; you can redistribute it and/or
 
6
   modify it under the terms of the GNU Lesser General Public
 
7
   License as published by the Free Software Foundation; either
 
8
   version 2.1 of the License, or (at your option) version 3, or any
 
9
   later version accepted by the membership of KDE e.V. (or its
 
10
   successor approved by the membership of KDE e.V.), which shall
 
11
   act as a proxy defined in Section 6 of version 3 of the license.
 
12
 
 
13
   This library is distributed in the hope that it will be useful,
 
14
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
   Lesser General Public License for more details.
 
17
 
 
18
   You should have received a copy of the GNU Lesser General Public
 
19
   License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 
20
*/
 
21
 
 
22
 
 
23
#ifndef NEPOMUK_SIMPLERESOURCEH_H
 
24
#define NEPOMUK_SIMPLERESOURCEH_H
 
25
 
 
26
#include <KUrl>
 
27
 
 
28
#include <QtCore/QList>
 
29
#include <QtCore/QHash>
 
30
#include <QtCore/QSharedDataPointer>
 
31
 
 
32
#include "nepomuksync_export.h"
 
33
 
 
34
namespace Soprano {
 
35
    class Node;
 
36
    class Statement;
 
37
    class Graph;
 
38
}
 
39
 
 
40
namespace Nepomuk {
 
41
    namespace Sync {
 
42
 
 
43
        /**
 
44
         * \class SimpleResource simpleresource.h
 
45
         *
 
46
         * A SimpleResource is a convenient way of storing a set of properties and objects for
 
47
         * a common subject. This class does not represent an actual resource present in the
 
48
         * repository. It's just a collection of in-memory statements.
 
49
         *
 
50
         * Interally it uses a multi-hash to store the properties and objects.
 
51
         * 
 
52
         * \author Vishesh Handa <handa.vish@gmail.com>
 
53
         */
 
54
        class NEPOMUKSYNC_EXPORT SimpleResource : public QMultiHash<KUrl, Soprano::Node>
 
55
        {
 
56
        public :
 
57
            SimpleResource();
 
58
            SimpleResource( const SimpleResource & rhs );
 
59
            virtual ~SimpleResource();
 
60
 
 
61
            /**
 
62
             * It uses the the first element's subject as the uri and ignores all further subjects.
 
63
             * Please make sure all the subjects are the same cause no kind of checks are made.
 
64
             */
 
65
            static SimpleResource fromStatementList(const QList<Soprano::Statement> & list);
 
66
            
 
67
            QList<Soprano::Statement> toStatementList() const;
 
68
 
 
69
            bool isFileDataObject() const;
 
70
            bool isFolder() const;
 
71
            KUrl nieUrl() const;
 
72
 
 
73
            KUrl uri() const;
 
74
            void setUri( const KUrl & newUri );
 
75
 
 
76
            
 
77
            QList<Soprano::Node> property( const KUrl & url ) const;
 
78
 
 
79
            /**
 
80
             * Removes all the statements whose object is \p uri
 
81
             */
 
82
            void removeObject( const KUrl & uri );
 
83
 
 
84
            SimpleResource& operator=( const SimpleResource & rhs );
 
85
            bool operator==( const SimpleResource & res );
 
86
        private:
 
87
            class Private;
 
88
            QSharedDataPointer<Private> d;
 
89
        };
 
90
 
 
91
        /**
 
92
         * \class ResourceHash simpleresource.h
 
93
         *
 
94
         * A SimpleResource is a convenient way of representing a list of Soprano::Statements
 
95
         * or a Soprano::Graph.
 
96
         * It provides easy lookup of resources.
 
97
         *
 
98
         * \author Vishesh Handa <handa.vish@gmail.com>
 
99
         */
 
100
        class NEPOMUKSYNC_EXPORT ResourceHash : public QHash<KUrl, SimpleResource> {
 
101
        public :
 
102
            static ResourceHash fromStatementList( const QList<Soprano::Statement> & list );
 
103
            static ResourceHash fromGraph( const Soprano::Graph & graph );
 
104
 
 
105
            QList<Soprano::Statement> toStatementList() const;
 
106
        };
 
107
        
 
108
    }
 
109
}
 
110
#endif // NEPOMUK_SIMPLERESOURCEH_H