PageRenderTime 9ms CodeModel.GetById 2ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/src/libtomahawk/playlist/dynamic/GeneratorFactory.h

http://github.com/tomahawk-player/tomahawk
C Header | 75 lines | 31 code | 15 blank | 29 comment | 0 complexity | 0c040444abb10f39011459e6caaf87ae MD5 | raw file
 1/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
 2 *
 3 *   Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
 4 *   Copyright 2010-2011, 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 GENERATOR_FACTORY_H
21#define GENERATOR_FACTORY_H
22
23#include <QHash>
24#include <QString>
25
26#include "playlist/dynamic/GeneratorInterface.h"
27#include "Typedefs.h"
28
29#include "DllMacro.h"
30
31namespace Tomahawk
32{
33
34/**
35  * Generators should subclass this and have it create the custom Generator
36  */
37class DLLEXPORT GeneratorFactoryInterface
38{
39public:
40    GeneratorFactoryInterface() {}
41
42    virtual ~GeneratorFactoryInterface() {}
43
44    virtual GeneratorInterface* create() = 0;
45    /**
46     * Create a control for this generator, not tied to this generator itself. Used when loading dynamic
47     *  playlists from a dbcmd.
48     */
49    virtual dyncontrol_ptr createControl( const QString& controlType = QString() ) = 0;
50
51    virtual QStringList typeSelectors() const = 0;
52};
53
54/**
55 * Simple factory that generates Generators from string type descriptors
56 */
57class DLLEXPORT GeneratorFactory
58{
59public:
60    static geninterface_ptr create( const QString& type );
61    // only used when loading from dbcmd
62    static dyncontrol_ptr createControl( const QString& generatorType, const QString& controlType = QString() );
63
64    static void registerFactory( const QString& type, GeneratorFactoryInterface* iface );
65    static QStringList types();
66    static QStringList typeSelectors( const QString& type );
67
68private:
69    static QHash<QString, GeneratorFactoryInterface*> s_factories;
70
71};
72
73};
74
75#endif