QGIS API Documentation  2.6.0-Brighton
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgspluginlayerregistry.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgspluginlayerregistry.cpp - class for
3  registering plugin layer creators
4  -------------------
5  begin : Mon Nov 30 2009
6  copyright : (C) 2009 by Mathias Walker, Sourcepole
7  email : mwa at sourcepole.ch
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
19 #ifndef QGSPLUGINLAYERREGSITRY_H
20 #define QGSPLUGINLAYERREGSITRY_H
21 
22 #include <QMap>
23 #include <QDomNode>
24 
25 class QgsPluginLayer;
26 
30 class CORE_EXPORT QgsPluginLayerType
31 {
32  public:
33 
34  QgsPluginLayerType( QString name );
35  virtual ~QgsPluginLayerType();
36 
37  QString name();
38 
40  virtual QgsPluginLayer* createLayer();
41 
43  virtual bool showLayerProperties( QgsPluginLayer* layer );
44 
45  protected:
46  QString mName;
47 };
48 
49 //=============================================================================
50 
54 class CORE_EXPORT QgsPluginLayerRegistry
55 {
56  public:
57 
59  static QgsPluginLayerRegistry* instance();
60 
62 
65  QStringList pluginLayerTypes();
66 
68  bool addPluginLayerType( QgsPluginLayerType* pluginLayerType );
69 
71  bool removePluginLayerType( QString typeName );
72 
74  QgsPluginLayerType* pluginLayerType( QString typeName );
75 
77  QgsPluginLayer* createLayer( QString typeName );
78 
79  private:
80 
81  typedef QMap<QString, QgsPluginLayerType*> PluginLayerTypes;
82 
85 
87  static QgsPluginLayerRegistry* _instance;
88 
89  PluginLayerTypes mPluginLayerTypes;
90 };
91 
92 #endif // QGSPLUGINLAYERREGSITRY_H