Quantum GIS API Documentation
1.7.4
|
00001 /*************************************************************************** 00002 qgsmaplayerregistry.h 00003 Singleton class for keeping track of loaded layers 00004 ------------------- 00005 begin : Sun June 04 2004 00006 copyright : (C) 2004 by Tim Sutton 00007 email : tim@linfiniti.com 00008 ***************************************************************************/ 00009 00010 /*************************************************************************** 00011 * * 00012 * This program is free software; you can redistribute it and/or modify * 00013 * it under the terms of the GNU General Public License as published by * 00014 * the Free Software Foundation; either version 2 of the License, or * 00015 * (at your option) any later version. * 00016 * * 00017 ***************************************************************************/ 00018 /* $Id$ */ 00019 00020 #ifndef QGSMAPLAYERREGISTRY_H 00021 #define QGSMAPLAYERREGISTRY_H 00022 00023 #include <QMap> 00024 #include <QObject> 00025 00026 class QString; 00027 class QStringList; 00028 00029 class QgsMapLayer; 00030 00035 class CORE_EXPORT QgsMapLayerRegistry : public QObject 00036 { 00037 Q_OBJECT 00038 00039 public: 00040 00042 static QgsMapLayerRegistry * instance(); 00046 int count(); 00047 00048 ~QgsMapLayerRegistry(); 00049 00051 QgsMapLayer * mapLayer( QString theLayerId ); 00052 00054 QMap<QString, QgsMapLayer*> & mapLayers(); 00055 00066 QgsMapLayer *addMapLayer( QgsMapLayer * theMapLayer, bool theEmitSignal = true ); 00067 00076 void removeMapLayer( QString theLayerId, bool theEmitSignal = true ); 00077 00083 void removeAllMapLayers(); 00084 00085 /* Clears all layer caches, resetting them to zero and 00086 * freeing up any memory they may have been using. Layer 00087 * caches are used to speed up rendering in certain situations 00088 * see ticket #1974 for more details. 00089 * @note this method was added in QGIS 1.4 00090 */ 00091 void clearAllLayerCaches(); 00092 00095 void reloadAllLayers(); 00096 00097 signals: 00098 00102 void layerWillBeRemoved( QString theLayerId ); 00103 00107 void layerWasAdded( QgsMapLayer * theMapLayer ); 00108 00117 void removedAll(); 00118 00119 protected: 00120 00122 QgsMapLayerRegistry( QObject * parent = 0 ); 00123 00124 private: 00125 00126 static QgsMapLayerRegistry* mInstance; 00127 00128 QMap<QString, QgsMapLayer*> mMapLayers; 00129 00133 void connectNotify( const char * signal ); 00134 00135 00136 }; // class QgsMapLayerRegistry 00137 00138 #endif //QgsMapLayerRegistry_H 00139