-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add capabilities cache classes and use QHash for config cache
- Loading branch information
Showing
2 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/*************************************************************************** | ||
qgscapabilitiescache.h | ||
---------------------- | ||
begin : May 11th, 2011 | ||
copyright : (C) 2011 by Marco Hugentobler | ||
email : marco dot hugentobler at sourcepole dot ch | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgscapabilitiescache.h" | ||
|
||
QgsCapabilitiesCache::QgsCapabilitiesCache() | ||
{ | ||
} | ||
|
||
QgsCapabilitiesCache::~QgsCapabilitiesCache() | ||
{ | ||
} | ||
|
||
const QDomDocument* QgsCapabilitiesCache::searchCapabilitiesDocument( const QString& configFilePath ) const | ||
{ | ||
QHash< QString, QDomDocument >::const_iterator it = mCachedCapabilities.find( configFilePath ); | ||
if( it == mCachedCapabilities.constEnd() ) | ||
{ | ||
return 0; | ||
} | ||
else | ||
{ | ||
return &(it.value()); | ||
} | ||
} | ||
|
||
void QgsCapabilitiesCache::insertCapabilitiesDocument( const QString& configFilePath, const QDomDocument* doc ) | ||
{ | ||
mCachedCapabilities.insert( configFilePath, doc->cloneNode().toDocument() ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/*************************************************************************** | ||
qgscapabilitiescache.h | ||
---------------------- | ||
begin : May 11th, 2011 | ||
copyright : (C) 2011 by Marco Hugentobler | ||
email : marco dot hugentobler at sourcepole dot ch | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSCAPABILITIESCACHE_H | ||
#define QGSCAPABILITIESCACHE_H | ||
|
||
#include <QDomDocument> | ||
#include <QHash> | ||
|
||
/**A cache for capabilities xml documents (by configuration file path)*/ | ||
class QgsCapabilitiesCache | ||
{ | ||
public: | ||
QgsCapabilitiesCache(); | ||
~QgsCapabilitiesCache(); | ||
|
||
/**Returns cached capabilities document (or 0 if document for configuration file not in cache)*/ | ||
const QDomDocument* searchCapabilitiesDocument( const QString& configFilePath ) const; | ||
/**Inserts new capabilities document (creates a copy of the document, does not take ownership)*/ | ||
void insertCapabilitiesDocument( const QString& configFilePath, const QDomDocument* doc ); | ||
|
||
private: | ||
QHash< QString, QDomDocument > mCachedCapabilities; | ||
}; | ||
|
||
#endif // QGSCAPABILITIESCACHE_H |