← Back to team overview

kicad-developers team mailing list archive

[PATCH] Consts in BOARD

 

Here is a patch for a couple of consts in class BOARD, plus a
suspicious const return-by-value (which does nothing but disable move
operations).

I looked at GetBoardPolygonOutlines too, but that needs the
GetBoardPolygonOutlines function in specctra.cpp to be constified, and
theres (at least) a member, "pcb", that gets conditionally initialised
in that function, so it's impossible without a mutable, which I'm not
sure would be correct or not.

Cheers,

John
From 5d745e925631107ec0bd462907955345cacae2fd Mon Sep 17 00:00:00 2001
From: John Beard <john.j.beard@xxxxxxxxx>
Date: Fri, 27 Jan 2017 23:32:44 +0800
Subject: [PATCH 1/2] Tidy consts in class BOARD

Add some consts to "getters" in this class.

Remove const from return type of static return-by-value getter - this
has no effect on the caller except disabling move operations and forcing
copy operations.
---
 pcbnew/class_board.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h
index 0ad5e9d89..e43fa5aae 100644
--- a/pcbnew/class_board.h
+++ b/pcbnew/class_board.h
@@ -353,7 +353,7 @@ public:
      * Function GetHighLightNetCode
      * @return netcode of net to highlight (-1 when no net selected)
      */
-    int GetHighLightNetCode() { return m_highLight.m_netCode; }
+    int GetHighLightNetCode() const { return m_highLight.m_netCode; }
 
     /**
      * Function SetHighLightNet
@@ -368,7 +368,7 @@ public:
      * Function IsHighLightNetON
      * @return true if a net is currently highlighted
      */
-    bool IsHighLightNetON() { return m_highLight.m_highLightOn; }
+    bool IsHighLightNetON() const { return m_highLight.m_highLightOn; }
 
     /**
      * Function HighLightOFF
@@ -645,7 +645,7 @@ public:
      * @return const wxString - containing the layer name or "BAD INDEX" if aLayerId
      *                      is not legal
      */
-    static const wxString GetStandardLayerName( LAYER_ID aLayerId )
+    static wxString GetStandardLayerName( LAYER_ID aLayerId )
     {
         // a BOARD's standard layer name is the LAYER_ID fixed name
         return LSET::Name( aLayerId );
-- 
2.11.0