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 b661049 commit 09c6d6f93c1d3659027a5895b4bd5d8f33e378e9
Showing with 84 additions and 0 deletions.
  1. +44 −0 src/mapserver/qgscapabilitiescache.cpp
  2. +40 −0 src/mapserver/qgscapabilitiescache.h
@@ -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() );
}
@@ -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.
You can’t perform that action at this time.