Skip to content
Permalink
Browse files

Registry for raster renderers

  • Loading branch information
mhugent committed Feb 1, 2012
1 parent 2c9320a commit 884de68e3bd6ecd55a843aa94db79072a2de3f4f
@@ -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
@@ -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;
}


@@ -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.
You can’t perform that action at this time.