File: ScanningState.h

package info (click to toggle)
amarok 3.3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 112,344 kB
  • sloc: cpp: 195,053; xml: 4,329; ansic: 2,634; javascript: 673; ruby: 528; python: 507; sh: 252; makefile: 12
file content (69 lines) | stat: -rw-r--r-- 2,849 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/****************************************************************************************
 * Copyright (C) 2003-2010 Mark Kretschmann <kretschmann@kde.org>                       *
 * Copyright (C) 2008 Dan Meltzer <parallelgrapefruit@gmail.com>                        *
 * Copyright (C) 2008-2009 Jeff Mitchell <mitchell@kde.org>                             *
 * Copyright (c) 2012 Matěj Laitl <matej@laitl.cz>                                      *
 *                                                                                      *
 * This program is free software; you can redistribute it and/or modify it under        *
 * the terms of the GNU General Public License as published by the Free Software        *
 * Foundation; either version 2 of the License, or (at your option) any later           *
 * version.                                                                             *
 *                                                                                      *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
 *                                                                                      *
 * You should have received a copy of the GNU General Public License along with         *
 * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
 ****************************************************************************************/

#ifndef COLLECTIONSCANNER_SCANNINGSTATE_H
#define COLLECTIONSCANNER_SCANNINGSTATE_H

#include "amarokshared_export.h"

#include <QSharedMemory>
#include <QString>
#include <QStringList>

namespace CollectionScanner
{

/** A class used to store the current scanning state in a shared memory segment.
    Storing the state of the scanner shouldn't cause a file access.
    We are using a shared memory that the amarok process holds open until the scanning
    is finished to store the state.
 */
class AMAROKSHARED_EXPORT ScanningState
{
    public:
        ScanningState();
        ~ScanningState();

        void setKey( const QString &key );
        bool isValid() const;

        QString lastDirectory() const;
        void setLastDirectory( const QString &dir );

        QStringList badFiles() const;
        void setBadFiles( const QStringList &badFiles );

        QString lastFile() const;
        void setLastFile( const QString &file );

        void readFull();
        void writeFull();

    private:
        QSharedMemory *m_sharedMemory;

        QString m_lastDirectory;
        QStringList m_badFiles;
        QString m_lastFile;
        qint64 m_lastFilePos;
};

}

#endif // COLLECTIONSCANNER_SCANNINGSTATE_H