Skip to content
Permalink
Browse files

Add capabilities cache classes and use QHash for config cache

  • Loading branch information
mhugent committed May 11, 2011
1 parent 09c6d6f commit bf07028cb837848b7e8d9a6dfc175c8c65724da9
Showing with 6 additions and 5 deletions.
  1. +1 −0 src/mapserver/CMakeLists.txt
  2. +3 −3 src/mapserver/qgsconfigcache.cpp
  3. +2 −2 src/mapserver/qgsconfigcache.h
@@ -17,6 +17,7 @@ ENDIF (CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo

SET ( qgis_mapserv_SRCS
qgis_map_serv.cpp
qgscapabilitiescache.cpp
qgsconfigcache.cpp
qgsconfigparser.cpp
qgsepsgcache.cpp
@@ -27,7 +27,7 @@ QgsConfigCache::QgsConfigCache()

QgsConfigCache::~QgsConfigCache()
{
QMap<QString, QgsConfigParser*>::iterator configIt = mCachedConfigurations.begin();
QHash<QString, QgsConfigParser*>::iterator configIt = mCachedConfigurations.begin();
for ( ; configIt != mCachedConfigurations.end(); ++configIt )
{
delete configIt.value();
@@ -37,7 +37,7 @@ QgsConfigCache::~QgsConfigCache()
QgsConfigParser* QgsConfigCache::searchConfiguration( const QString& filePath )
{
QgsConfigParser* p = 0;
QMap<QString, QgsConfigParser*>::const_iterator configIt = mCachedConfigurations.find( filePath );
QHash<QString, QgsConfigParser*>::const_iterator configIt = mCachedConfigurations.find( filePath );
if ( configIt == mCachedConfigurations.constEnd() )
{
QgsMSDebugMsg( "Create new configuration" );
@@ -62,7 +62,7 @@ QgsConfigParser* QgsConfigCache::insertConfiguration( const QString& filePath )
if ( mCachedConfigurations.size() > 40 )
{
//remove 10 elements to avoid memory problems
QMap<QString, QgsConfigParser*>::iterator configIt = mCachedConfigurations.begin();
QHash<QString, QgsConfigParser*>::iterator configIt = mCachedConfigurations.begin();
for ( int i = 0; i < 10; ++i )
{
configIt = mCachedConfigurations.erase( configIt );
@@ -18,7 +18,7 @@
#ifndef QGSCONFIGCACHE_H
#define QGSCONFIGCACHE_H

#include <QMap>
#include <QHash>
#include <QString>

class QgsConfigParser;
@@ -39,7 +39,7 @@ class QgsConfigCache
@return the inserted config parser or 0 in case of error*/
QgsConfigParser* insertConfiguration( const QString& filePath );
/**Cached XML configuration documents. Key: file path, value: config parser. Default configuration has key '$default$'*/
QMap<QString, QgsConfigParser*> mCachedConfigurations;
QHash<QString, QgsConfigParser*> mCachedConfigurations;
};

#endif // QGSCONFIGCACHE_H

0 comments on commit bf07028

Please sign in to comment.
You can’t perform that action at this time.