Skip to content

Commit

Permalink
Use c++11 '= delete' instead of private copy declarations
Browse files Browse the repository at this point in the history
Switches the use of private copy constructors/copy assignment
operators to instead use public "=delete" declarations.
This results in clearer compile-time errors if these deleted
functions are used, vs obscure link-time errors.
  • Loading branch information
nyalldawson committed Jan 1, 2017
1 parent 8ebc73b commit 6579c4c
Show file tree
Hide file tree
Showing 58 changed files with 181 additions and 179 deletions.
5 changes: 3 additions & 2 deletions src/analysis/openstreetmap/qgsosmdatabase.h
Expand Up @@ -49,6 +49,9 @@ class ANALYSIS_EXPORT QgsOSMDatabase
explicit QgsOSMDatabase( const QString& dbFileName = QString() );
~QgsOSMDatabase();

QgsOSMDatabase( const QgsOSMDatabase& rh ) = delete;
QgsOSMDatabase& operator=( const QgsOSMDatabase& rh ) = delete;

void setFileName( const QString& dbFileName ) { mDbFileName = dbFileName; }
QString filename() const { return mDbFileName; }
bool isOpen() const;
Expand Down Expand Up @@ -120,8 +123,6 @@ class ANALYSIS_EXPORT QgsOSMDatabase
sqlite3_stmt* mStmtWayNodePoints;
sqlite3_stmt* mStmtWayTags;

QgsOSMDatabase( const QgsOSMDatabase& rh );
QgsOSMDatabase& operator=( const QgsOSMDatabase& rh );
};


Expand Down
6 changes: 3 additions & 3 deletions src/analysis/raster/qgsalignraster.h
Expand Up @@ -49,6 +49,9 @@ class ANALYSIS_EXPORT QgsAlignRaster
RasterInfo( const QString& layerpath );
~RasterInfo();

RasterInfo( const RasterInfo& rh ) = delete;
RasterInfo& operator=( const RasterInfo& rh ) = delete;

//! Check whether the given path is a valid raster
bool isValid() const { return nullptr != mDataset; }

Expand Down Expand Up @@ -87,9 +90,6 @@ class ANALYSIS_EXPORT QgsAlignRaster

private:

RasterInfo( const RasterInfo& rh );
RasterInfo& operator=( const RasterInfo& rh );

friend class QgsAlignRaster;
};

Expand Down
5 changes: 3 additions & 2 deletions src/analysis/raster/qgsrastercalcnode.h
Expand Up @@ -76,6 +76,9 @@ class ANALYSIS_EXPORT QgsRasterCalcNode
QgsRasterCalcNode( const QString& rasterName );
~QgsRasterCalcNode();

QgsRasterCalcNode( const QgsRasterCalcNode& rh ) = delete;
QgsRasterCalcNode& operator=( const QgsRasterCalcNode& rh ) = delete;

Type type() const { return mType; }

//set left node
Expand Down Expand Up @@ -103,8 +106,6 @@ class ANALYSIS_EXPORT QgsRasterCalcNode
QgsRasterMatrix* mMatrix;
Operator mOperator;

QgsRasterCalcNode( const QgsRasterCalcNode& rh );
QgsRasterCalcNode& operator=( const QgsRasterCalcNode& rh );
};


Expand Down
5 changes: 3 additions & 2 deletions src/analysis/raster/qgsrelief.h
Expand Up @@ -45,6 +45,9 @@ class ANALYSIS_EXPORT QgsRelief
QgsRelief( const QString& inputFile, const QString& outputFile, const QString& outputFormat );
~QgsRelief();

QgsRelief( const QgsRelief& rh ) = delete;
QgsRelief& operator=( const QgsRelief& rh ) = delete;

/** Starts the calculation, reads from mInputFile and stores the result in mOutputFile
@param p progress dialog that receives update and that is checked for abort. 0 if no progress bar is needed.
@return 0 in case of success*/
Expand Down Expand Up @@ -122,8 +125,6 @@ class ANALYSIS_EXPORT QgsRelief
*/
bool calculateRegression( const QList< QPair < int, double > >& input, double& a, double& b );

QgsRelief( const QgsRelief& rh );
QgsRelief& operator=( const QgsRelief& rh );
};

#endif // QGSRELIEF_H
7 changes: 3 additions & 4 deletions src/app/nodetool/qgsvertexentry.h
Expand Up @@ -43,6 +43,9 @@ class QgsVertexEntry
int penWidth = 2 );
~QgsVertexEntry();

QgsVertexEntry( const QgsVertexEntry& rh ) = delete;
QgsVertexEntry& operator=( const QgsVertexEntry& rh ) = delete;

const QgsPointV2& point() const { return mPoint; }
QgsPoint pointV1() const { return QgsPoint( mPoint.x(), mPoint.y() ); }
QgsVertexId vertexId() const { return mVertexId; }
Expand All @@ -52,10 +55,6 @@ class QgsVertexEntry

void setSelected( bool selected = true );

private:

QgsVertexEntry( const QgsVertexEntry& rh );
QgsVertexEntry& operator=( const QgsVertexEntry& rh );
};

#endif
8 changes: 3 additions & 5 deletions src/app/qgisapp.h
Expand Up @@ -154,6 +154,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow

~QgisApp();

QgisApp( QgisApp const & ) = delete;
QgisApp & operator=( QgisApp const & ) = delete;

/**
* Add a vector layer to the canvas, returns pointer to it
*/
Expand Down Expand Up @@ -1509,11 +1512,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
//! Configure layer tree view according to the user options from QSettings
void setupLayerTreeViewFromSettings();

/// QgisApp aren't copyable
QgisApp( QgisApp const & );
/// QgisApp aren't copyable
QgisApp & operator=( QgisApp const & );

void readSettings();
void writeSettings();
void createActions();
Expand Down
9 changes: 3 additions & 6 deletions src/app/qgisappinterface.h
Expand Up @@ -45,6 +45,9 @@ class APP_EXPORT QgisAppInterface : public QgisInterface
QgisAppInterface( QgisApp *qgisapp );
~QgisAppInterface();

QgisAppInterface( QgisAppInterface const & ) = delete;
QgisAppInterface & operator=( QgisAppInterface const & ) = delete;

QgsPluginManagerInterface* pluginManagerInterface() override;

QgsLayerTreeView* layerTreeView() override;
Expand Down Expand Up @@ -524,12 +527,6 @@ class APP_EXPORT QgisAppInterface : public QgisInterface

private:

/// QgisInterface aren't copied
QgisAppInterface( QgisAppInterface const & );

/// QgisInterface aren't copied
QgisAppInterface & operator=( QgisAppInterface const & );

//! Pointer to the QgisApp object
QgisApp *qgis;

Expand Down
5 changes: 3 additions & 2 deletions src/app/qgsidentifyresultsdialog.h
Expand Up @@ -110,11 +110,12 @@ class APP_EXPORT QgsIdentifyPlotCurve
QwtPlot* plot, const QString &title = QString(), QColor color = QColor() );
~QgsIdentifyPlotCurve();

QgsIdentifyPlotCurve( const QgsIdentifyPlotCurve& rh ) = delete;
QgsIdentifyPlotCurve& operator=( const QgsIdentifyPlotCurve& rh ) = delete;

private:
QwtPlotCurve* mPlotCurve;

QgsIdentifyPlotCurve( const QgsIdentifyPlotCurve& rh );
QgsIdentifyPlotCurve& operator=( const QgsIdentifyPlotCurve& rh );
};

class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdentifyResultsBase
Expand Down
6 changes: 3 additions & 3 deletions src/core/effects/qgspainteffectregistry.h
Expand Up @@ -161,6 +161,9 @@ class CORE_EXPORT QgsPaintEffectRegistry
QgsPaintEffectRegistry();
~QgsPaintEffectRegistry();

QgsPaintEffectRegistry( const QgsPaintEffectRegistry& rh ) = delete;
QgsPaintEffectRegistry& operator=( const QgsPaintEffectRegistry& rh ) = delete;

/** Returns the metadata for a specific effect.
* @param name unique string name for paint effect class
* @returns paint effect metadata if found, otherwise nullptr
Expand Down Expand Up @@ -212,9 +215,6 @@ class CORE_EXPORT QgsPaintEffectRegistry

private:

QgsPaintEffectRegistry( const QgsPaintEffectRegistry& rh );
QgsPaintEffectRegistry& operator=( const QgsPaintEffectRegistry& rh );

QMap<QString, QgsPaintEffectAbstractMetadata*> mMetadata;
};

Expand Down
8 changes: 3 additions & 5 deletions src/core/gps/qgsgpsconnectionregistry.h
Expand Up @@ -34,22 +34,20 @@ class CORE_EXPORT QgsGPSConnectionRegistry
{
public:
QgsGPSConnectionRegistry();

~QgsGPSConnectionRegistry();

QgsGPSConnectionRegistry( const QgsGPSConnectionRegistry& rh ) = delete;
QgsGPSConnectionRegistry& operator=( const QgsGPSConnectionRegistry& rh ) = delete;

//! Inserts a connection into the registry. The connection is owned by the registry class until it is unregistered again
void registerConnection( QgsGPSConnection* c );
//! Unregisters connection. The registry does no longer own the connection
void unregisterConnection( QgsGPSConnection* c );

QList< QgsGPSConnection *> connectionList() const;


private:

QgsGPSConnectionRegistry( const QgsGPSConnectionRegistry& rh );
QgsGPSConnectionRegistry& operator=( const QgsGPSConnectionRegistry& rh );

QSet<QgsGPSConnection*> mConnections;
};

Expand Down
6 changes: 3 additions & 3 deletions src/core/pal/feature.h
Expand Up @@ -66,15 +66,15 @@ namespace pal
}
~LabelInfo() { delete [] char_info; }

LabelInfo( const LabelInfo& rh ) = delete;
LabelInfo& operator=( const LabelInfo& rh ) = delete;

double max_char_angle_inside;
double max_char_angle_outside;
double label_height;
int char_num;
CharacterInfo* char_info;
private:

LabelInfo( const LabelInfo& rh );
LabelInfo& operator=( const LabelInfo& rh );
};

class LabelPosition;
Expand Down
11 changes: 3 additions & 8 deletions src/core/pal/pal.h
Expand Up @@ -94,11 +94,11 @@ namespace pal
*/
Pal();

/**
* \brief delete an instance
*/
~Pal();

Pal( const Pal& other ) = delete;
Pal& operator=( const Pal& other ) = delete;

/**
* \brief add a new layer
*
Expand Down Expand Up @@ -324,11 +324,6 @@ namespace pal
*/
int getMaxIt();

private:

Pal( const Pal& other );
Pal& operator=( const Pal& other );

};

} // end namespace pal
Expand Down
8 changes: 3 additions & 5 deletions src/core/pal/palstat.h
Expand Up @@ -49,11 +49,10 @@ namespace pal

public:

/**
* \brief delete stats
*/
~PalStat();

PalStat( const PalStat& other ) = delete;
PalStat& operator=( const PalStat& other ) = delete;

/**
* \brief the number of object in problem
Expand Down Expand Up @@ -96,8 +95,7 @@ namespace pal
int *layersNbLabelledObjects; // [nbLayers]

PalStat();
PalStat( const PalStat& other );
PalStat& operator=( const PalStat& other );

};

} // end namespace pal
Expand Down
5 changes: 3 additions & 2 deletions src/core/pal/priorityqueue.h
Expand Up @@ -58,6 +58,9 @@ namespace pal
PriorityQueue( int n, int maxId, bool min );
~PriorityQueue();

PriorityQueue( const PriorityQueue & ) = delete;
PriorityQueue &operator=( const PriorityQueue & ) = delete;

void print();

int getSize();
Expand All @@ -81,8 +84,6 @@ namespace pal

int getId( int key );
private:
PriorityQueue( const PriorityQueue & );
PriorityQueue &operator=( const PriorityQueue & );

int size;
int maxsize;
Expand Down
6 changes: 3 additions & 3 deletions src/core/pal/problem.h
Expand Up @@ -112,6 +112,9 @@ namespace pal

~Problem();

Problem( const Problem& other ) = delete;
Problem& operator=( const Problem& other ) = delete;

/** Adds a candidate label position to the problem.
* @param position label candidate position. Ownership is transferred to Problem.
* @note added in QGIS 2.12
Expand Down Expand Up @@ -178,9 +181,6 @@ namespace pal

private:

Problem( const Problem& other );
Problem& operator=( const Problem& other );

/**
* How many layers are labelled ?
*/
Expand Down
8 changes: 3 additions & 5 deletions src/core/qgsconnectionpool.h
Expand Up @@ -78,6 +78,9 @@ class QgsConnectionPoolGroup
}
}

QgsConnectionPoolGroup( const QgsConnectionPoolGroup& other ) = delete;
QgsConnectionPoolGroup& operator=( const QgsConnectionPoolGroup& other ) = delete;

T acquire()
{
// we are going to acquire a resource - if no resource is available, we will block here
Expand Down Expand Up @@ -214,11 +217,6 @@ class QgsConnectionPoolGroup
QSemaphore sem;
QTimer* expirationTimer;

private:

QgsConnectionPoolGroup( const QgsConnectionPoolGroup& other );
QgsConnectionPoolGroup& operator=( const QgsConnectionPoolGroup& other );

};


Expand Down
6 changes: 4 additions & 2 deletions src/core/qgscrscache.h
Expand Up @@ -32,6 +32,9 @@ class CORE_EXPORT QgsCoordinateTransformCache
public:
static QgsCoordinateTransformCache* instance();

QgsCoordinateTransformCache( const QgsCoordinateTransformCache& rh ) = delete;
QgsCoordinateTransformCache& operator=( const QgsCoordinateTransformCache& rh ) = delete;

/** Returns coordinate transformation. Cache keeps ownership
@param srcAuthId auth id string of source crs
@param destAuthId auth id string of dest crs
Expand All @@ -48,8 +51,7 @@ class CORE_EXPORT QgsCoordinateTransformCache
QMultiHash< QPair< QString, QString >, QgsCoordinateTransform > mTransforms; //same auth_id pairs might have different datum transformations

QgsCoordinateTransformCache();
QgsCoordinateTransformCache( const QgsCoordinateTransformCache& rh );
QgsCoordinateTransformCache& operator=( const QgsCoordinateTransformCache& rh );

};

#endif // QGSCRSCACHE_H
5 changes: 3 additions & 2 deletions src/core/qgsdataitemproviderregistry.h
Expand Up @@ -37,6 +37,9 @@ class CORE_EXPORT QgsDataItemProviderRegistry

~QgsDataItemProviderRegistry();

QgsDataItemProviderRegistry( const QgsDataItemProviderRegistry& rh ) = delete;
QgsDataItemProviderRegistry& operator=( const QgsDataItemProviderRegistry& rh ) = delete;

//! Get list of available providers
QList<QgsDataItemProvider*> providers() const { return mProviders; }

Expand All @@ -51,8 +54,6 @@ class CORE_EXPORT QgsDataItemProviderRegistry
//! available providers. this class owns the pointers
QList<QgsDataItemProvider*> mProviders;

QgsDataItemProviderRegistry( const QgsDataItemProviderRegistry& rh );
QgsDataItemProviderRegistry& operator=( const QgsDataItemProviderRegistry& rh );
};

#endif // QGSDATAITEMPROVIDERREGISTRY_H
6 changes: 3 additions & 3 deletions src/core/qgsexpression.h
Expand Up @@ -1187,13 +1187,13 @@ class CORE_EXPORT QgsExpression
{}
~WhenThen() { delete mWhenExp; delete mThenExp; }

WhenThen( const WhenThen& rh ) = delete;
WhenThen& operator=( const WhenThen& rh ) = delete;

// protected:
Node* mWhenExp;
Node* mThenExp;

private:
WhenThen( const WhenThen& rh );
WhenThen& operator=( const WhenThen& rh );
};
typedef QList<WhenThen*> WhenThenList;

Expand Down

0 comments on commit 6579c4c

Please sign in to comment.