Skip to content

Commit 884de68

Browse files
committedFeb 1, 2012
Registry for raster renderers
1 parent 2c9320a commit 884de68

File tree

3 files changed

+109
-0
lines changed

3 files changed

+109
-0
lines changed
 

‎src/core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ SET(QGIS_CORE_SRCS
164164
raster/qgsrastershader.cpp
165165
raster/qgsrastershaderfunction.cpp
166166

167+
raster/qgsrasterrendererregistry.cpp
167168
raster/qgsrasterrenderer.cpp
168169
raster/qgsbilinearrasterresampler.cpp
169170
raster/qgscubicrasterresampler.cpp
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/***************************************************************************
2+
qgsrasterrendererregistry.cpp
3+
-----------------------------
4+
begin : January 2012
5+
copyright : (C) 2012 by Marco Hugentobler
6+
email : marco 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 "qgsrasterrendererregistry.h"
19+
20+
QgsRasterRendererRegistry* QgsRasterRendererRegistry::mInstance = 0;
21+
22+
QgsRasterRendererRegistry* QgsRasterRendererRegistry::instance()
23+
{
24+
if( !mInstance )
25+
{
26+
mInstance = new QgsRasterRendererRegistry();
27+
}
28+
return mInstance;
29+
}
30+
31+
QgsRasterRendererRegistry::QgsRasterRendererRegistry()
32+
{
33+
}
34+
35+
QgsRasterRendererRegistry::~QgsRasterRendererRegistry()
36+
{
37+
}
38+
39+
void QgsRasterRendererRegistry::insert( QgsRasterRendererRegistryEntry entry )
40+
{
41+
mEntries.insert( entry.name, entry );
42+
}
43+
44+
bool QgsRasterRendererRegistry::rendererData( const QString& rendererName, QgsRasterRendererRegistryEntry& data ) const
45+
{
46+
QHash< QString, QgsRasterRendererRegistryEntry >::const_iterator it = mEntries.find( rendererName );
47+
if( it == mEntries.constEnd() )
48+
{
49+
return false;
50+
}
51+
data = it.value();
52+
return true;
53+
}
54+
55+
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/***************************************************************************
2+
qgsrasterrendererregistry.h
3+
---------------------------
4+
begin : January 2012
5+
copyright : (C) 2012 by Marco Hugentobler
6+
email : marco 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 QGSRASTERRENDERERREGISTRY_H
19+
#define QGSRASTERRENDERERREGISTRY_H
20+
21+
#include <QHash>
22+
#include <QString>
23+
24+
class QgsRasterDataProvider;
25+
class QgsRasterRenderer;
26+
27+
typedef QgsRasterRenderer*(*QgsRasterRendererCreateFunc)(const QDomElement&);
28+
29+
struct QgsRasterRendererRegistryEntry
30+
{
31+
QString name;
32+
QgsRasterRendererCreateFunc rendererCreateFunction; //pointer to create function
33+
//pointer to create function for renderer widget
34+
};
35+
36+
class QgsRasterRendererRegistry
37+
{
38+
public:
39+
static QgsRasterRendererRegistry* instance();
40+
~QgsRasterRendererRegistry();
41+
42+
void insert( QgsRasterRendererRegistryEntry entry );
43+
bool rendererData( const QString& rendererName, QgsRasterRendererRegistryEntry& data ) const;
44+
45+
protected:
46+
QgsRasterRendererRegistry();
47+
48+
private:
49+
static QgsRasterRendererRegistry* mInstance;
50+
QHash< QString, QgsRasterRendererRegistryEntry > mEntries;
51+
};
52+
53+
#endif // QGSRASTERRENDERERREGISTRY_H

0 commit comments

Comments
 (0)
Please sign in to comment.