Skip to content

Commit 09c6d6f

Browse files
committedMay 11, 2011
Add capabilities cache classes and use QHash for config cache
1 parent b661049 commit 09c6d6f

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed
 
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/***************************************************************************
2+
qgscapabilitiescache.h
3+
----------------------
4+
begin : May 11th, 2011
5+
copyright : (C) 2011 by Marco Hugentobler
6+
email : marco dot hugentobler at sourcepole dot ch
7+
***************************************************************************/
8+
9+
/***************************************************************************
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
***************************************************************************/
17+
18+
#include "qgscapabilitiescache.h"
19+
20+
QgsCapabilitiesCache::QgsCapabilitiesCache()
21+
{
22+
}
23+
24+
QgsCapabilitiesCache::~QgsCapabilitiesCache()
25+
{
26+
}
27+
28+
const QDomDocument* QgsCapabilitiesCache::searchCapabilitiesDocument( const QString& configFilePath ) const
29+
{
30+
QHash< QString, QDomDocument >::const_iterator it = mCachedCapabilities.find( configFilePath );
31+
if( it == mCachedCapabilities.constEnd() )
32+
{
33+
return 0;
34+
}
35+
else
36+
{
37+
return &(it.value());
38+
}
39+
}
40+
41+
void QgsCapabilitiesCache::insertCapabilitiesDocument( const QString& configFilePath, const QDomDocument* doc )
42+
{
43+
mCachedCapabilities.insert( configFilePath, doc->cloneNode().toDocument() );
44+
}

‎src/mapserver/qgscapabilitiescache.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/***************************************************************************
2+
qgscapabilitiescache.h
3+
----------------------
4+
begin : May 11th, 2011
5+
copyright : (C) 2011 by Marco Hugentobler
6+
email : marco dot hugentobler at sourcepole dot ch
7+
***************************************************************************/
8+
9+
/***************************************************************************
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
***************************************************************************/
17+
18+
#ifndef QGSCAPABILITIESCACHE_H
19+
#define QGSCAPABILITIESCACHE_H
20+
21+
#include <QDomDocument>
22+
#include <QHash>
23+
24+
/**A cache for capabilities xml documents (by configuration file path)*/
25+
class QgsCapabilitiesCache
26+
{
27+
public:
28+
QgsCapabilitiesCache();
29+
~QgsCapabilitiesCache();
30+
31+
/**Returns cached capabilities document (or 0 if document for configuration file not in cache)*/
32+
const QDomDocument* searchCapabilitiesDocument( const QString& configFilePath ) const;
33+
/**Inserts new capabilities document (creates a copy of the document, does not take ownership)*/
34+
void insertCapabilitiesDocument( const QString& configFilePath, const QDomDocument* doc );
35+
36+
private:
37+
QHash< QString, QDomDocument > mCachedCapabilities;
38+
};
39+
40+
#endif // QGSCAPABILITIESCACHE_H

0 commit comments

Comments
 (0)
Please sign in to comment.