Skip to content

Commit

Permalink
Add capabilities cache classes and use QHash for config cache
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed May 11, 2011
1 parent b661049 commit 09c6d6f
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/mapserver/qgscapabilitiescache.cpp
@@ -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() );
}
40 changes: 40 additions & 0 deletions src/mapserver/qgscapabilitiescache.h
@@ -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

0 comments on commit 09c6d6f

Please sign in to comment.