~ubuntu-branches/ubuntu/oneiric/lmms/oneiric

« back to all changes in this revision

Viewing changes to include/plugin.h

  • Committer: Bazaar Package Importer
  • Author(s): Alessio Treglia
  • Date: 2010-11-12 13:32:32 UTC
  • mfrom: (1.1.9 upstream) (3.1.8 sid)
  • Revision ID: james.westby@ubuntu.com-20101112133232-vdld83iyji8srqti
Tags: 0.4.7-2ubuntu1
* Re-sync with Debian (LP: #606533):
  - Replace build-dep on libwine-dev with libwine-dev-unstable to build
    against the newer Wine.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * plugin.h - class plugin, the base-class and generic interface for all plugins
3
 
 *
4
 
 * Copyright (c) 2005-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
5
 
 * 
6
 
 * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
7
 
 *
8
 
 * This program is free software; you can redistribute it and/or
9
 
 * modify it under the terms of the GNU General Public
10
 
 * License as published by the Free Software Foundation; either
11
 
 * version 2 of the License, or (at your option) any later version.
12
 
 *
13
 
 * This program is distributed in the hope that it will be useful,
14
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
 
 * General Public License for more details.
17
 
 *
18
 
 * You should have received a copy of the GNU General Public
19
 
 * License along with this program (see COPYING); if not, write to the
20
 
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21
 
 * Boston, MA 02110-1301 USA.
22
 
 *
23
 
 */
24
 
 
25
 
 
26
 
#ifndef _PLUGIN_H
27
 
#define _PLUGIN_H
28
 
 
29
 
 
30
 
#include <QtCore/QString>
31
 
#include <QtCore/QStringList>
32
 
#include <QtCore/QVector>
33
 
#include <QtXml/QDomDocument>
34
 
 
35
 
#include "journalling_object.h"
36
 
#include "mv_base.h"
37
 
#include "base64.h"
38
 
 
39
 
 
40
 
 
41
 
class QWidget;
42
 
 
43
 
class pixmapLoader;
44
 
class pluginView;
45
 
class automatableModel;
46
 
 
47
 
 
48
 
class EXPORT plugin : public journallingObject, public model
49
 
{
50
 
public:
51
 
        enum PluginTypes
52
 
        {
53
 
                Instrument,     // instrument being used in channel-track
54
 
                Effect,         // effect-plugin for effect-board
55
 
                ImportFilter,   // filter for importing a file
56
 
                ExportFilter,   // filter for exporting a file
57
 
                Tool,           // additional tool (level-meter etc)
58
 
                Library,        // simple library holding a code-base for
59
 
                                // several other plugins (e.g. VST-support)
60
 
                Other,
61
 
                Undefined = 255
62
 
        } ;
63
 
 
64
 
        // descriptor holds information about a plugin - every external plugin
65
 
        // has to instantiate such a descriptor in an extern "C"-section so that
66
 
        // the plugin-loader is able to access information about the plugin
67
 
        struct descriptor
68
 
        {
69
 
                const char * name;
70
 
                const char * displayName;
71
 
                const char * description;
72
 
                const char * author;
73
 
                int version;
74
 
                PluginTypes type;
75
 
                const pixmapLoader * logo;
76
 
                const char * supportedFileTypes;
77
 
                inline bool supportsFileType( const QString & _ext ) const
78
 
                {
79
 
                        return QString( supportedFileTypes ).
80
 
                                                split( QChar( ',' ) ).
81
 
                                                        contains( _ext );
82
 
                }
83
 
                class EXPORT subPluginFeatures
84
 
                {
85
 
                public:
86
 
                        struct key
87
 
                        {
88
 
                                typedef QMap<QString, QString> attributeMap;
89
 
 
90
 
                                inline key( plugin::descriptor * _desc = NULL,
91
 
                                        const QString & _name = QString(),
92
 
                                        const attributeMap & _am =
93
 
                                                        attributeMap() )
94
 
                                        :
95
 
                                        desc( _desc ),
96
 
                                        name( _name ),
97
 
                                        attributes( _am )
98
 
                                {
99
 
                                }
100
 
 
101
 
                                key( const QDomElement & _key );
102
 
 
103
 
                                QDomElement saveXML( QDomDocument &
104
 
                                                                _doc ) const;
105
 
 
106
 
                                inline bool isValid( void ) const
107
 
                                {
108
 
                                        return desc != NULL &&
109
 
                                                        name != QString::null;
110
 
                                }
111
 
 
112
 
                                plugin::descriptor * desc;
113
 
                                QString name;
114
 
                                attributeMap attributes;
115
 
                        } ;
116
 
 
117
 
                        typedef QList<key> keyList;
118
 
 
119
 
 
120
 
                        subPluginFeatures( plugin::PluginTypes _type ) :
121
 
                                m_type( _type )
122
 
                        {
123
 
                        }
124
 
 
125
 
                        virtual ~subPluginFeatures()
126
 
                        {
127
 
                        }
128
 
 
129
 
                        virtual void fillDescriptionWidget( QWidget *,
130
 
                                                                const key * )
131
 
                        {
132
 
                        }
133
 
 
134
 
                        virtual void listSubPluginKeys( plugin::descriptor *,
135
 
                                                                keyList & )
136
 
                        {
137
 
                        }
138
 
 
139
 
 
140
 
                protected:
141
 
                        const plugin::PluginTypes m_type;
142
 
                } ;
143
 
 
144
 
                subPluginFeatures * sub_plugin_features;
145
 
 
146
 
        } ;
147
 
 
148
 
        // contructor of a plugin
149
 
        plugin( const descriptor * _descriptor, model * _parent );
150
 
        virtual ~plugin();
151
 
 
152
 
        // returns display-name out of descriptor
153
 
        virtual QString displayName( void ) const
154
 
        {
155
 
                return model::displayName().isEmpty() ?
156
 
                                        m_descriptor->displayName :
157
 
                                                        model::displayName();
158
 
        }
159
 
 
160
 
        // return plugin-type
161
 
        inline PluginTypes type( void ) const
162
 
        {
163
 
                return m_descriptor->type;
164
 
        }
165
 
 
166
 
        // return plugin-descriptor for further information
167
 
        inline const descriptor * getDescriptor( void ) const
168
 
        {
169
 
                return m_descriptor;
170
 
        }
171
 
 
172
 
        // can be called if a file matching supportedFileTypes should be
173
 
        // loaded/processed with the help of this plugin
174
 
        virtual void loadFile( const QString & _file );
175
 
 
176
 
        // Called if external source needs to change something but we cannot
177
 
        // reference the class header.  Should return null if not key not found.
178
 
        virtual automatableModel * getChildModel( const QString & _modelName );
179
 
 
180
 
        // returns an instance of a plugin whose name matches to given one
181
 
        // if specified plugin couldn't be loaded, it creates a dummy-plugin
182
 
        static plugin * instantiate( const QString & _plugin_name,
183
 
                                                        model * _parent,
184
 
                                                        void * _data );
185
 
 
186
 
        // fills given vector with descriptors of all available plugins
187
 
        static void getDescriptorsOfAvailPlugins(
188
 
                                        QVector<descriptor> & _plugin_descs );
189
 
 
190
 
        // create a view for the model 
191
 
        pluginView * createView( QWidget * _parent );
192
 
 
193
 
 
194
 
protected:
195
 
        // create a view for the model 
196
 
        virtual pluginView * instantiateView( QWidget * ) = 0;
197
 
 
198
 
 
199
 
private:
200
 
        const descriptor * m_descriptor;
201
 
 
202
 
        // pointer to instantiation-function in plugin
203
 
        typedef plugin * ( * instantiationHook )( model *, void * );
204
 
 
205
 
} ;
206
 
 
207
 
 
208
 
#endif