-
Notifications
You must be signed in to change notification settings - Fork 369
/
Copy pathPipeline.h
122 lines (93 loc) · 3.79 KB
/
Pipeline.h
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2011, Christian Muehlhaeuser <[email protected]>
* Copyright 2013, Uwe L. Korn <[email protected]>
*
* Tomahawk 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 3 of the License, or
* (at your option) any later version.
*
* Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#ifndef PIPELINE_H
#define PIPELINE_H
#include "DllMacro.h"
#include "Typedefs.h"
#include "Query.h"
#include <QObject>
#include <QList>
#include <QStringList>
#include <functional>
namespace Tomahawk
{
class PipelinePrivate;
class Resolver;
class ExternalResolver;
typedef std::function<Tomahawk::ExternalResolver*( QString, QString, QStringList )> ResolverFactoryFunc;
class DLLEXPORT Pipeline : public QObject
{
Q_OBJECT
public:
static Pipeline* instance();
explicit Pipeline( QObject* parent = nullptr );
virtual ~Pipeline();
bool isRunning() const;
unsigned int pendingQueryCount() const;
unsigned int activeQueryCount() const;
void reportResults( QID qid, const QList< result_ptr >& results );
void reportAlbums( QID qid, const QList< album_ptr >& albums );
void reportArtists( QID qid, const QList< artist_ptr >& artists );
void addExternalResolverFactory( ResolverFactoryFunc resolverFactory );
Tomahawk::ExternalResolver* addScriptResolver( const QString& accountId, const QString& scriptPath, const QStringList& additionalScriptPaths = QStringList() );
void stopScriptResolver( const QString& scriptPath );
void removeScriptResolver( const QString& scriptPath );
QList< QPointer< ExternalResolver > > scriptResolvers() const;
Tomahawk::ExternalResolver* resolverForPath( const QString& scriptPath );
void addResolver( Resolver* r );
void removeResolver( Resolver* r );
query_ptr query( const QID& qid ) const;
result_ptr result( const RID& rid ) const;
bool isResolving( const query_ptr& q ) const;
public slots:
void resolve( const query_ptr& q, bool prioritized = true, bool temporaryQuery = false );
void resolve( const QList<query_ptr>& qlist, bool prioritized = true, bool temporaryQuery = false );
void resolve( QID qid, bool prioritized = true, bool temporaryQuery = false );
/**
* Initiate syncing of a playlist with a reslover.
*/
void startPlaylistSync( ExternalResolver* r, playlist_ptr playlist );
void start();
void stop();
void databaseReady();
signals:
void running();
void idle();
void resolving( const Tomahawk::query_ptr& query );
void resolverAdded( Tomahawk::Resolver* );
void resolverRemoved( Tomahawk::Resolver* );
protected:
QScopedPointer<PipelinePrivate> d_ptr;
private slots:
void timeoutShunt( const query_ptr& q );
void shunt( const query_ptr& q );
void shuntNext();
void onTemporaryQueryTimer();
void onResultUrlCheckerDone();
private:
Q_DECLARE_PRIVATE( Pipeline )
void addResultsToQuery( const query_ptr& query, const QList< result_ptr >& results );
Tomahawk::Resolver* nextResolver( const Tomahawk::query_ptr& query ) const;
void setQIDState( const Tomahawk::query_ptr& query, int state );
int incQIDState( const Tomahawk::query_ptr& query );
int decQIDState( const Tomahawk::query_ptr& query );
};
} // Tomahawk
#endif // PIPELINE_H