Skip to content

Commit

Permalink
Registry for raster renderers
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Feb 1, 2012
1 parent 2c9320a commit 884de68
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/core/CMakeLists.txt
Expand Up @@ -164,6 +164,7 @@ SET(QGIS_CORE_SRCS
raster/qgsrastershader.cpp
raster/qgsrastershaderfunction.cpp

raster/qgsrasterrendererregistry.cpp
raster/qgsrasterrenderer.cpp
raster/qgsbilinearrasterresampler.cpp
raster/qgscubicrasterresampler.cpp
Expand Down
55 changes: 55 additions & 0 deletions src/core/raster/qgsrasterrendererregistry.cpp
@@ -0,0 +1,55 @@
/***************************************************************************
qgsrasterrendererregistry.cpp
-----------------------------
begin : January 2012
copyright : (C) 2012 by Marco Hugentobler
email : marco 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 "qgsrasterrendererregistry.h"

QgsRasterRendererRegistry* QgsRasterRendererRegistry::mInstance = 0;

QgsRasterRendererRegistry* QgsRasterRendererRegistry::instance()
{
if( !mInstance )
{
mInstance = new QgsRasterRendererRegistry();
}
return mInstance;
}

QgsRasterRendererRegistry::QgsRasterRendererRegistry()
{
}

QgsRasterRendererRegistry::~QgsRasterRendererRegistry()
{
}

void QgsRasterRendererRegistry::insert( QgsRasterRendererRegistryEntry entry )
{
mEntries.insert( entry.name, entry );
}

bool QgsRasterRendererRegistry::rendererData( const QString& rendererName, QgsRasterRendererRegistryEntry& data ) const
{
QHash< QString, QgsRasterRendererRegistryEntry >::const_iterator it = mEntries.find( rendererName );
if( it == mEntries.constEnd() )
{
return false;
}
data = it.value();
return true;
}


53 changes: 53 additions & 0 deletions src/core/raster/qgsrasterrendererregistry.h
@@ -0,0 +1,53 @@
/***************************************************************************
qgsrasterrendererregistry.h
---------------------------
begin : January 2012
copyright : (C) 2012 by Marco Hugentobler
email : marco 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 QGSRASTERRENDERERREGISTRY_H
#define QGSRASTERRENDERERREGISTRY_H

#include <QHash>
#include <QString>

class QgsRasterDataProvider;
class QgsRasterRenderer;

typedef QgsRasterRenderer*(*QgsRasterRendererCreateFunc)(const QDomElement&);

struct QgsRasterRendererRegistryEntry
{
QString name;
QgsRasterRendererCreateFunc rendererCreateFunction; //pointer to create function
//pointer to create function for renderer widget
};

class QgsRasterRendererRegistry
{
public:
static QgsRasterRendererRegistry* instance();
~QgsRasterRendererRegistry();

void insert( QgsRasterRendererRegistryEntry entry );
bool rendererData( const QString& rendererName, QgsRasterRendererRegistryEntry& data ) const;

protected:
QgsRasterRendererRegistry();

private:
static QgsRasterRendererRegistry* mInstance;
QHash< QString, QgsRasterRendererRegistryEntry > mEntries;
};

#endif // QGSRASTERRENDERERREGISTRY_H

0 comments on commit 884de68

Please sign in to comment.