~ubuntu-branches/ubuntu/quantal/kde-runtime/quantal

« back to all changes in this revision

Viewing changes to nepomuk/services/backupsync/service/changelog.h

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2012-06-03 21:50:00 UTC
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: package-import@ubuntu.com-20120603215000-vn7oarsq0ynrydj5
Tags: upstream-4.8.80
Import upstream version 4.8.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 CHANGELOG_H
24
 
#define CHANGELOG_H
25
 
 
26
 
#include <QtCore/QUrl>
27
 
#include <QtCore/QTextStream>
28
 
 
29
 
namespace Soprano {
30
 
    class Model;
31
 
    class Statement;
32
 
}
33
 
 
34
 
namespace Nepomuk {
35
 
 
36
 
        class ChangeLogRecord;
37
 
 
38
 
        /**
39
 
         * \class ChangeLog changelog.h
40
 
         *
41
 
         * Consists of a set of ChangeLogRecords.
42
 
         *
43
 
         * In order to use the Sync API, a list of changes or a ChangeLog has
44
 
         * to be provided. It is advisable to keep the internal records sorted on
45
 
         * the basis of their time stamp, but that IS NOT enforced.
46
 
         *
47
 
         * \sa ChangeLogRecord
48
 
         *
49
 
         * \author Vishesh Handa <handa.vish@gmail.com>
50
 
         */
51
 
        class ChangeLog
52
 
        {
53
 
        public :
54
 
            ChangeLog();
55
 
            ChangeLog( const ChangeLog & rhs );
56
 
            virtual ~ChangeLog();
57
 
            
58
 
            /**
59
 
             * Converts \p st into a list of ChangeLogRecords. The dateTime is set
60
 
             * to the current time, and all statements are marked as added.
61
 
             */
62
 
            static ChangeLog fromList( const QList<Soprano::Statement> & st );
63
 
 
64
 
            static ChangeLog fromList( const QList<ChangeLogRecord> & records );
65
 
 
66
 
            /**
67
 
             * Load all statements from graph \p graphUri in the \p model into a list of
68
 
             * ChangeLogRecord. The dateTime is set to the current time, and all
69
 
             * statements are marked as added.
70
 
             *
71
 
             * By default the main model is used.
72
 
             */
73
 
            static ChangeLog fromGraphUri( const QUrl& graphUri, Soprano::Model * model = 0 );
74
 
 
75
 
            /**
76
 
             * Load all statements from all contexts in \p graphUrlList into a list of
77
 
             * ChangeLogRecord. The dateTime is set to the current time, and all
78
 
             * statements are marked as added.
79
 
             */
80
 
            static ChangeLog fromGraphUriList( const QList< QUrl >& graphUriList, Soprano::Model* model = 0 );
81
 
 
82
 
            
83
 
            static ChangeLog fromUrl( const QUrl & url );
84
 
            static ChangeLog fromUrl( const QUrl & url, const QDateTime & min );
85
 
 
86
 
            /**
87
 
            * Saves all the internal records in url. The records are saved in plain text form
88
 
            */
89
 
            bool save( const QUrl & url ) const;
90
 
 
91
 
            int size() const;
92
 
            bool empty() const;
93
 
            void clear();
94
 
 
95
 
            virtual void add( const ChangeLogRecord & record );
96
 
 
97
 
            void sort();
98
 
 
99
 
            QList<ChangeLogRecord> toList() const;
100
 
 
101
 
            /**
102
 
            * Changes all the added statements to removed and vice versa
103
 
            */
104
 
            void invert();
105
 
 
106
 
            /**
107
 
            * Removes all the records whose subject is not present in \p nepomukUris
108
 
            */
109
 
            void filter( const QSet<QUrl> & nepomukUris );
110
 
 
111
 
            /**
112
 
             * Concatenates the records held by the two ChangeLogs
113
 
             */
114
 
            ChangeLog & operator +=( const ChangeLog & log );
115
 
            ChangeLog& operator +=( const ChangeLogRecord & record );
116
 
 
117
 
            ChangeLog& operator=( const ChangeLog & rhs );
118
 
            
119
 
            void removeRecordsAfter( const QDateTime& dt );
120
 
            void removeRecordsBefore( const QDateTime & dt );
121
 
 
122
 
            /**
123
 
             * Return uri of all objects and subjects in changelog
124
 
             */
125
 
            QSet<QUrl> resources() const;
126
 
            /**
127
 
             * Return uri of all subjects in changelog
128
 
             */
129
 
            QSet<QUrl> subjects() const;
130
 
 
131
 
            // trueg: do we really only have resource objects here? No literals at all?
132
 
            /**
133
 
             * Return uri of all objects in changelog
134
 
             */
135
 
            QSet<QUrl> objects() const;
136
 
 
137
 
            static QString dateTimeFormat();
138
 
 
139
 
        private:
140
 
            class Private;
141
 
            Private * d;
142
 
        };
143
 
 
144
 
        QTextStream& operator<<( QTextStream & ts, const ChangeLog & log );
145
 
        QDebug operator<<( QDebug debug, const ChangeLog & log );
146
 
}
147
 
 
148
 
#endif // CHANGELOG_H