[Qgis-developer] Some concerns about QGIS on OS X, part 3

Mac Programmer MacPgmr at fastermac.net
Sat Feb 7 21:51:37 EST 2009


Many programmers, particularly new programmers, prefer to use LWOHF  
(languages without header files). I'm thinking here of the .NET  
languages C#, VB.NET and Delphi Prism (nee Oxygene) or Object Pascal  
as implemented in Delphi and Free Pascal. Currently QGIS only  
provides two extremes for adding value, C++ and Python. If this were  
1999, in the heyday of desktop development, perhaps these traditional  
languages would make sense. But if we're living in 2009, or planning  
for, say, 2011, it would seem as though also having choices somewhere  
in the middle of the language spectrum would help QGIS adoption.

What about proceduralizing the QGIS API similar to the way Den Jean  
has proceduralized much of the Qt API?

http://users.telenet.be/Jan.Van.hijfte/qtforfpc/fpcqt4.html

This would open up QGIS to most languages that can import C libraries.

In my experience, C++ in the hands of even good programmers often  
results in unstable, fragile, difficult-to-maintain code, whereas  
Python is, well, a scripting language. Certainly Python has its uses  
and fTools and the Plugin Installer are excellent examples of how far  
you can take Python. But there are also many cases where Python is  
not appropriate and a compiled language is needed. (cf. the  
performance issues of the Python "Sugar" front-end and Python  
"activities" (apps) on the One Laptop Per Child (OLPC) computers.)

Following Den's lead, an interface library written in C++ that  
flattens the QGIS API might look like this:

#include <qgsapplication.h>
#include "qgsapplication.hb"

QgsApplicationH QgsApplication_create(int* argc, char** argv, int p3)
{
	return (QgsApplicationH) new QgsApplication(*(int*)argc, argv, p3);
}

void QgsApplication_destroy(QgsApplicationH handle)
{
	delete (QgsApplication *)handle;
}

int QgsApplication_exec()
{
	return (int) QgsApplication::exec();
}

In Pascal, this library's functions can be imported like this:

function QgsApplication_create(argc: PInteger; argv: PPAnsiChar; p3:  
Integer = QT_VERSION): QgsApplicationH; overload; cdecl; external  
QgisIntf name 'QgsApplication_create';
procedure QgsApplication_destroy(handle: QgsApplicationH); cdecl;  
external QgisIntf name 'QgsApplication_destroy';
function QgsApplication_exec(): Integer; cdecl; external QgisIntf  
name 'QgsApplication_exec';

I've already tested this and it does work on OS X. I would follow up  
with more of this interface library, but I'm not sure I'm qualified -  
I'm not much of a C++ programmer, I have no GIS background, and I  
have no understanding of QGIS's architecture. Maybe there's somebody  
less error prone in this area who would be interested.

Again, the objective here is to make adding value to QGIS as painless  
as possible.

Thanks.

-Phil

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20090207/9f43120a/attachment.html


More information about the Qgis-developer mailing list