-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |