[Marble-devel] [RFC] remove MARBLE_PLUGIN macro

Jens-Michael Hoffmann jensmh at gmx.de
Thu Mar 26 16:44:07 CET 2009


in the Marble::RenderPlugin header we have the MARBLE_PLUGIN macro, it is 
defined as follows:

#define MARBLE_PLUGIN(T) public:\
    virtual RenderPlugin* pluginInstance() { return new T(); };

Then this macro is used in the plugin classes like for example in 

=== cut ===
class PlacemarksPlugin : public RenderPlugin
    Q_INTERFACES( Marble::RenderPluginInterface )
    MARBLE_PLUGIN( PlacemarksPlugin )

    void setBrushStyle( GeoPainter *painter, GeoDataDocument* root,
				QString styleId );
    void setPenStyle( GeoPainter *painter, GeoDataDocument* root,
				 QString styleId );
    bool renderGeoDataGeometry( GeoPainter *painter,
				 GeoDataGeometry *geometry, QString styleUrl );
    bool renderGeoDataFeature( GeoPainter *painter, GeoDataFeature *feature );

    QBrush m_currentBrush;
    QPen m_currentPen;

=== cut ===

There are some issues with this macro:

1. it contains "public:". This means that even if you put the macro invocation 
in the private section of a class everything behind the macro and the 
next "private:" or "protected:" becomes public. As you can see in the example 
given above this is not just a theoretical issue.

2. the name is misleading. This macro only is useful for classes derived from 

3. the macro implements a method inline, which in this case might do not much 

4. coding style. The use of macros is generally discouraged in C++. 

Therefore I suggest to apply the attached patch which removes the macro and 
replaces it with proper C++.

Best Regards


-------------- next part --------------
A non-text attachment was scrubbed...
Name: remove-marble-plugin-macro.patch
Type: text/x-diff
Size: 16622 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/marble-devel/attachments/20090326/5e7de2ef/attachment.bin 

More information about the Marble-devel mailing list