From a932ca74a234c05d8137d9ce3c23063a8d80f322 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sun, 11 Feb 2018 17:28:55 -0500 Subject: [PATCH] Object lifecycle cleanup in glbarcode. --- glbarcode/Barcode.h | 5 +++++ glbarcode/DrawingPrimitives.h | 6 ++++++ glbarcode/Matrix.h | 9 +++++++++ glbarcode/QtRenderer.cpp | 16 ---------------- glbarcode/QtRenderer.h | 13 ------------- glbarcode/Renderer.h | 11 +++++++++++ 6 files changed, 31 insertions(+), 29 deletions(-) diff --git a/glbarcode/Barcode.h b/glbarcode/Barcode.h index ebfa3f5..78ded8a 100644 --- a/glbarcode/Barcode.h +++ b/glbarcode/Barcode.h @@ -57,6 +57,11 @@ namespace glbarcode */ virtual ~Barcode(); + /* + * Non-copyable + */ + Barcode( const Barcode & ) = delete; + void operator=( const Barcode & ) = delete; /** * Set accessor for "showText" property. diff --git a/glbarcode/DrawingPrimitives.h b/glbarcode/DrawingPrimitives.h index fc1632d..466f1ce 100644 --- a/glbarcode/DrawingPrimitives.h +++ b/glbarcode/DrawingPrimitives.h @@ -50,6 +50,12 @@ namespace glbarcode */ virtual ~DrawingPrimitive() = default; + /* + * Non-copyable + */ + DrawingPrimitive( const DrawingPrimitive & ) = delete; + void operator=( const DrawingPrimitive & ) = delete; + /** * Get X coordinate of primitive's origin (points). */ diff --git a/glbarcode/Matrix.h b/glbarcode/Matrix.h index cf8ced6..d4cff2f 100644 --- a/glbarcode/Matrix.h +++ b/glbarcode/Matrix.h @@ -104,6 +104,15 @@ namespace glbarcode } + /** + * Copy assignment "=" operator + */ + inline Matrix & operator=( const Matrix & src ) + { + return Matrix( src ); + } + + /** * Indirection "[]" operator */ diff --git a/glbarcode/QtRenderer.cpp b/glbarcode/QtRenderer.cpp index 85ad0c7..0279bc9 100644 --- a/glbarcode/QtRenderer.cpp +++ b/glbarcode/QtRenderer.cpp @@ -59,28 +59,12 @@ namespace glbarcode } - QtRenderer::QtRenderer( const QtRenderer& from ) - { - d = new QtRenderer::PrivateData; - - *d = *from.d; - } - - QtRenderer::~QtRenderer() { delete d; } - QtRenderer& QtRenderer::operator=( const QtRenderer& from ) - { - *d = *from.d; - - return *this; - } - - QPainter* QtRenderer::painter( ) const { return d->painter; diff --git a/glbarcode/QtRenderer.h b/glbarcode/QtRenderer.h index 4872ccb..3b858ca 100644 --- a/glbarcode/QtRenderer.h +++ b/glbarcode/QtRenderer.h @@ -48,24 +48,11 @@ namespace glbarcode */ QtRenderer( QPainter* painter ); - /** - * Copy Constructor - */ - QtRenderer( const QtRenderer& from ); - /** * Destructor */ ~QtRenderer() override; - /** Assignment operator. - * - * @param[in] from The value to assign to this object. - * - * @return A reference to this object. - */ - QtRenderer& operator=( const QtRenderer& from ); - /** Get "painter" parameter * * @returns painter parameter diff --git a/glbarcode/Renderer.h b/glbarcode/Renderer.h index 1aeb9fa..35874c9 100644 --- a/glbarcode/Renderer.h +++ b/glbarcode/Renderer.h @@ -40,12 +40,23 @@ namespace glbarcode */ class Renderer { + protected: + /** + * Default constructor. + */ + Renderer() = default; + public: /** * Destructor. */ virtual ~Renderer() = default; + /* + * Non-copyable + */ + Renderer( const Renderer & ) = delete; + void operator=( const Renderer & ) = delete; /** * Render list of primitives.