~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to plasma/generic/dataengines/nowplaying/playerinterface/playerfactory.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2008  Alex Merry <alex.merry@kdemail.net>
 
3
 *
 
4
 * This library is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU Lesser General Public
 
6
 * License as published by the Free Software Foundation; either
 
7
 * version 2.1 of the License, or (at your option) any later version.
 
8
 *
 
9
 * This library is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
 * Lesser General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU Lesser General Public
 
15
 * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
16
 */
 
17
 
 
18
#ifndef PLAYERFACTORY_H
 
19
#define PLAYERFACTORY_H
 
20
 
 
21
#include <QObject>
 
22
#include <QVariantList>
 
23
 
 
24
#include "player.h"
 
25
 
 
26
/**
 
27
 * A player factory that creates players.
 
28
 */
 
29
class PlayerFactory : public QObject
 
30
{
 
31
    Q_OBJECT
 
32
public:
 
33
    PlayerFactory(QObject* parent = 0);
 
34
    /**
 
35
     * Create a player.
 
36
     *
 
37
     * Returns 0 if a valid player could not be created.
 
38
     */
 
39
    virtual Player::Ptr create(const QVariantList& args = QVariantList()) = 0;
 
40
};
 
41
 
 
42
/**
 
43
 * A player factory that is polled.
 
44
 */
 
45
class PollingPlayerFactory : public PlayerFactory
 
46
{
 
47
    Q_OBJECT
 
48
public:
 
49
    PollingPlayerFactory(QObject* parent = 0);
 
50
    /**
 
51
     * Whether create(args) will return a player
 
52
     *
 
53
     * Note that just because this returns true, it
 
54
     * should not be assumed that create(args) will not
 
55
     * return 0.  However, if this returns false,
 
56
     * it can be assumed that create(args) will always
 
57
     * return 0.
 
58
     */
 
59
    virtual bool exists(const QVariantList& args = QVariantList()) = 0;
 
60
};
 
61
 
 
62
/**
 
63
 * A player factory that creates players based on a
 
64
 * DBus service.
 
65
 */
 
66
class DBusPlayerFactory : public PlayerFactory
 
67
{
 
68
    Q_OBJECT
 
69
public:
 
70
    DBusPlayerFactory(QObject* parent = 0);
 
71
    /**
 
72
     * Whether the given dbus service name is a service
 
73
     * for this player
 
74
     */
 
75
    virtual bool matches(const QString& serviceName) = 0;
 
76
    // don't let the QString overload hide this
 
77
    virtual Player::Ptr create(const QVariantList& args = QVariantList()) = 0;
 
78
    Player::Ptr create(const QString& serviceName);
 
79
};
 
80
 
 
81
#endif // PLAYERFACTORY_H