From 42220579df8082e20f2fe57e3a9281bb157045e8 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Sat, 28 Oct 2017 12:07:40 +0200 Subject: [PATCH] Const modifiers --- eeschema/class_library.cpp | 14 +++++++------- eeschema/class_library.h | 16 ++++++++-------- eeschema/cmp_tree_model_adapter.cpp | 4 ++-- eeschema/cmp_tree_model_adapter.h | 4 ++-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/eeschema/class_library.cpp b/eeschema/class_library.cpp index 355dcf8a3a..8bf99133a4 100644 --- a/eeschema/class_library.cpp +++ b/eeschema/class_library.cpp @@ -146,7 +146,7 @@ void PART_LIB::EnableBuffering( bool aEnable ) } -void PART_LIB::GetAliasNames( wxArrayString& aNames ) +void PART_LIB::GetAliasNames( wxArrayString& aNames ) const { m_plugin->EnumerateSymbolLib( aNames, fileName.GetFullPath(), m_properties.get() ); @@ -154,7 +154,7 @@ void PART_LIB::GetAliasNames( wxArrayString& aNames ) } -void PART_LIB::GetAliases( std::vector& aAliases ) +void PART_LIB::GetAliases( std::vector& aAliases ) const { m_plugin->EnumerateSymbolLib( aAliases, fileName.GetFullPath(), m_properties.get() ); @@ -164,7 +164,7 @@ void PART_LIB::GetAliases( std::vector& aAliases ) } -void PART_LIB::GetEntryTypePowerNames( wxArrayString& aNames ) +void PART_LIB::GetEntryTypePowerNames( wxArrayString& aNames ) const { std::vector aliases; @@ -186,7 +186,7 @@ void PART_LIB::GetEntryTypePowerNames( wxArrayString& aNames ) } -LIB_ALIAS* PART_LIB::FindAlias( const wxString& aName ) +LIB_ALIAS* PART_LIB::FindAlias( const wxString& aName ) const { LIB_ALIAS* alias = m_plugin->LoadSymbol( fileName.GetFullPath(), aName, m_properties.get() ); @@ -194,13 +194,13 @@ LIB_ALIAS* PART_LIB::FindAlias( const wxString& aName ) // symbols. This allows the symbol library table conversion tool to determine the // correct library where the symbol was found. if( alias && alias->GetPart() && !alias->GetPart()->GetLib() ) - alias->GetPart()->SetLib( this ); + alias->GetPart()->SetLib( const_cast( this ) ); return alias; } -LIB_PART* PART_LIB::FindPart( const wxString& aName ) +LIB_PART* PART_LIB::FindPart( const wxString& aName ) const { LIB_ALIAS* alias = FindAlias( aName ); @@ -211,7 +211,7 @@ LIB_PART* PART_LIB::FindPart( const wxString& aName ) } -bool PART_LIB::HasPowerParts() +bool PART_LIB::HasPowerParts() const { // return true if at least one power part is found in lib std::vector aliases; diff --git a/eeschema/class_library.h b/eeschema/class_library.h index a4096950cc..3e13695e2d 100644 --- a/eeschema/class_library.h +++ b/eeschema/class_library.h @@ -401,21 +401,21 @@ public: * * @param aNames - String array to place entry names into. */ - void GetAliasNames( wxArrayString& aNames ); + void GetAliasNames( wxArrayString& aNames ) const; /** * Load a vector with all the entries in this library. * * @param aAliases - vector to receive the aliases. */ - void GetAliases( std::vector& aAliases ); + void GetAliases( std::vector& aAliases ) const; /** * Load a string array with the names of entries of type POWER in this library. * * @param aNames - String array to place entry names into. */ - void GetEntryTypePowerNames( wxArrayString& aNames ); + void GetEntryTypePowerNames( wxArrayString& aNames ) const; /** * Find #LIB_ALIAS by \a aName. @@ -423,7 +423,7 @@ public: * @param aName - Name of entry, case sensitive. * @return #LIB_ALIAS* if found. NULL if not found. */ - LIB_ALIAS* FindAlias( const wxString& aName ); + LIB_ALIAS* FindAlias( const wxString& aName ) const; /** * Find part by \a aName. @@ -434,7 +434,7 @@ public: * @param aName - Name of part, case sensitive. * @return LIB_PART* - part if found, else NULL. */ - LIB_PART* FindPart( const wxString& aName ); + LIB_PART* FindPart( const wxString& aName ) const; /** * Add \a aPart entry to library. @@ -481,14 +481,14 @@ public: * * @return wxString - Full library file name with path and extension. */ - wxString GetFullFileName() { return fileName.GetFullPath(); } + wxString GetFullFileName() const { return fileName.GetFullPath(); } /** * Function GetLogicalName * returns the logical name of the library. * @return wxString - The logical name of this library. */ - const wxString GetLogicalName() + const wxString GetLogicalName() const { /* for now is the filename without path or extension. @@ -518,7 +518,7 @@ public: * @return true if at least one power part is found in lib * Useful to select or list only libs containing power parts */ - bool HasPowerParts(); + bool HasPowerParts() const; }; diff --git a/eeschema/cmp_tree_model_adapter.cpp b/eeschema/cmp_tree_model_adapter.cpp index d9b8cd6add..ac9cd5e6a7 100644 --- a/eeschema/cmp_tree_model_adapter.cpp +++ b/eeschema/cmp_tree_model_adapter.cpp @@ -241,7 +241,7 @@ void CMP_TREE_MODEL_ADAPTER::AttachTo( wxDataViewCtrl* aDataViewCtrl ) } -LIB_ID CMP_TREE_MODEL_ADAPTER::GetAliasFor( wxDataViewItem aSelection ) const +LIB_ID CMP_TREE_MODEL_ADAPTER::GetAliasFor( const wxDataViewItem& aSelection ) const { auto node = ToNode( aSelection ); @@ -254,7 +254,7 @@ LIB_ID CMP_TREE_MODEL_ADAPTER::GetAliasFor( wxDataViewItem aSelection ) const } -int CMP_TREE_MODEL_ADAPTER::GetUnitFor( wxDataViewItem aSelection ) const +int CMP_TREE_MODEL_ADAPTER::GetUnitFor( const wxDataViewItem& aSelection ) const { auto node = ToNode( aSelection ); return node ? node->Unit : 0; diff --git a/eeschema/cmp_tree_model_adapter.h b/eeschema/cmp_tree_model_adapter.h index 06f6c68e11..9cd67ae9bb 100644 --- a/eeschema/cmp_tree_model_adapter.h +++ b/eeschema/cmp_tree_model_adapter.h @@ -212,7 +212,7 @@ public: * * @return alias, or nullptr if none is selected */ - LIB_ID GetAliasFor( wxDataViewItem aSelection ) const; + LIB_ID GetAliasFor( const wxDataViewItem& aSelection ) const; /** * Return the unit for the given item. @@ -223,7 +223,7 @@ public: * @return Unit, or zero if the alias itself is selected. Return valid is * invalid if GetAliasFor() returns nullptr. */ - int GetUnitFor( wxDataViewItem aSelection ) const; + int GetUnitFor( const wxDataViewItem& aSelection ) const; /** * Return the number of components loaded in the tree.