PageRenderTime 122ms CodeModel.GetById 40ms app.highlight 4ms RepoModel.GetById 77ms app.codeStats 0ms

/src/libtomahawk/LatchManager.h

http://github.com/tomahawk-player/tomahawk
C Header | 68 lines | 37 code | 13 blank | 18 comment | 0 complexity | 189397c8c5439f16338a39d67f334702 MD5 | raw file
 1/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
 2 *
 3 *   Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
 4 *   Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
 5 *
 6 *   Tomahawk 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 3 of the License, or
 9 *   (at your option) any later version.
10 *
11 *   Tomahawk 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
17 *   along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef LATCHMANAGER_H
21#define LATCHMANAGER_H
22
23#include "DllMacro.h"
24#include "Source.h"
25
26#include <QtCore/QObject>
27
28class QState;
29class QStateMachine;
30
31namespace Tomahawk
32{
33
34class DLLEXPORT LatchManager : public QObject
35{
36    Q_OBJECT
37public:
38    explicit LatchManager( QObject* parent = 0 );
39    virtual ~LatchManager();
40
41    bool isLatched( const source_ptr& src );
42
43public slots:
44    void latchRequest( const Tomahawk::source_ptr& source );
45    void unlatchRequest( const Tomahawk::source_ptr& source );
46    void catchUpRequest();
47    void latchModeChangeRequest( const Tomahawk::source_ptr& source, bool realtime );
48
49private slots:
50    void playlistChanged( Tomahawk::playlistinterface_ptr );
51    void audioPaused();
52
53private:
54    enum State {
55        NotLatched =  0,
56        Latching,
57        Latched
58    };
59
60    State m_state;
61    source_ptr m_latchedOnTo;
62    source_ptr m_waitingForLatch;
63    playlistinterface_ptr m_latchedInterface;
64};
65
66}
67
68#endif // LATCHMANAGER_H