~ubuntu-branches/ubuntu/quantal/qgis/quantal

« back to all changes in this revision

Viewing changes to src/plugins/qgisplugin.h

  • Committer: Bazaar Package Importer
  • Author(s): William Grant
  • Date: 2007-05-06 13:42:32 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070506134232-pyli6t388w5asd8x
Tags: 0.8.0-3ubuntu1
* Merge from Debian unstable. Remaining Ubuntu changes:
  - debian/rules, debian/qgis.install, debian/qgis.dirs debian/qgis.desktop:
    Add and install .desktop.
* debian/qgis.desktop: Remove Applications category; it's not real.
* Modify Maintainer value to match Debian-Maintainer-Field Spec

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*!  \mainpage Quantum GIS - Plugin API
 
2
 *
 
3
 *  \section about  About QGis Plugins
 
4
 * Plugins provide additional functionality to QGis. Plugins must
 
5
 * implement several required methods in order to be registered with
 
6
 * QGis. These methods include:
 
7
 * <ul>name
 
8
 * <li>version
 
9
 * <li>description
 
10
 * </ul>
 
11
 *
 
12
 * All QGis plugins must inherit from the abstract base class QgisPlugin. A
 
13
 * This list will grow as the API is expanded.
 
14
 * 
 
15
 * In addition, a plugin must implement the classFactory and unload
 
16
 * functions. Note that these functions must be declared as extern "C" in
 
17
 * order to be resolved properly and prevent C++ name mangling.
 
18
 */
 
19
 
 
20
#ifndef QGISPLUGIN_H
 
21
#define QGISPLUGIN_H
 
22
 
 
23
 
 
24
#include <QString>
 
25
 
 
26
#include <qgisapp.h>
 
27
 
 
28
//#include "qgisplugingui.h"
 
29
 
 
30
/*! \class QgisPlugin 
 
31
 * \brief Abstract base class from which all plugins must inherit
 
32
 *
 
33
 */
 
34
class QgisPlugin
 
35
{
 
36
  public:
 
37
 
 
38
    //! Interface to gui element collection object
 
39
    //virtual QgisPluginGui *gui()=0;
 
40
    //! Element types that can be added to the interface
 
41
    /* enum ELEMENTS {
 
42
       MENU,
 
43
       MENU_ITEM,
 
44
       TOOLBAR,
 
45
       TOOLBAR_BUTTON,
 
46
       };
 
47
 
 
48
       @todo XXX this may be a hint that there should be subclasses
 
49
       */
 
50
    typedef enum PLUGINTYPE
 
51
    {
 
52
      UI = 1,                     /* user interface plug-in */
 
53
      MAPLAYER,                    /* map layer plug-in */
 
54
      RENDERER                     /*a plugin for a new renderer class*/
 
55
    };
 
56
 
 
57
 
 
58
    QgisPlugin ( QString const & name = "", 
 
59
        QString const & description = "",
 
60
        QString const & version = "",
 
61
        PLUGINTYPE const & type = MAPLAYER )
 
62
      : mName(name), 
 
63
      mDescription(description),
 
64
      mVersion(version),
 
65
      mType(type)
 
66
      {}
 
67
 
 
68
    virtual ~QgisPlugin()
 
69
    {}
 
70
 
 
71
    //! Get the name of the plugin
 
72
    QString const & name() const
 
73
    {
 
74
      return mName;
 
75
    }
 
76
 
 
77
    QString       & name() 
 
78
    {
 
79
      return mName;
 
80
    }
 
81
 
 
82
    //! Version of the plugin
 
83
    QString const & version() const
 
84
    {
 
85
      return mVersion;
 
86
    }
 
87
 
 
88
    //! Version of the plugin
 
89
    QString & version() 
 
90
    {
 
91
      return mVersion;
 
92
    }
 
93
 
 
94
    //! A brief description of the plugin
 
95
    QString const & description() const
 
96
    { 
 
97
      return mDescription;
 
98
    }
 
99
 
 
100
    //! A brief description of the plugin
 
101
    QString       & description()
 
102
    { 
 
103
      return mDescription;
 
104
    }
 
105
 
 
106
    //! Plugin type, either UI or map layer
 
107
    QgisPlugin::PLUGINTYPE const & type() const
 
108
    {
 
109
      return mType;
 
110
    }
 
111
 
 
112
 
 
113
    //! Plugin type, either UI or map layer
 
114
    QgisPlugin::PLUGINTYPE       & type() 
 
115
    {
 
116
      return mType;
 
117
    }
 
118
 
 
119
    /// function to initialize connection to GUI
 
120
    virtual void initGui() = 0;
 
121
 
 
122
    //! Unload the plugin and cleanup the GUI
 
123
    virtual void unload() = 0;
 
124
 
 
125
  private:
 
126
 
 
127
    /// plug-in name
 
128
    QString mName;
 
129
 
 
130
    /// description
 
131
    QString mDescription;
 
132
 
 
133
    /// version
 
134
    QString mVersion;
 
135
 
 
136
    /// UI or MAPLAYER plug-in
 
137
    /**
 
138
      @todo Really, might be indicative that this needs to split into 
 
139
      maplayer vs. ui plug-in vs. other kind of plug-in
 
140
      */
 
141
    PLUGINTYPE mType;
 
142
 
 
143
}; // class QgisPlugin
 
144
 
 
145
 
 
146
// Typedefs used by qgis main app
 
147
 
 
148
//! Typedef for the function that returns a generic pointer to a plugin object
 
149
typedef QgisPlugin *create_t(QgisApp *, QgisInterface *);
 
150
 
 
151
//! Typedef for the function to unload a plugin and free its resources
 
152
typedef void unload_t(QgisPlugin *);
 
153
 
 
154
//! Typedef for getting the name of the plugin without instantiating it
 
155
typedef QString name_t();
 
156
 
 
157
//! Typedef for getting the description without instantiating the plugin
 
158
typedef QString description_t();
 
159
 
 
160
//! Typedef for getting the plugin type without instantiating the plugin
 
161
typedef int type_t();
 
162
 
 
163
//! Typedef for getting the plugin version without instantiating the plugin
 
164
typedef QString version_t();
 
165
 
 
166
 
 
167
#endif //qgisplugin_h