KiCad PCB EDA Suite
SYMBOL_LIB_TABLE_ROW Class Reference

Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_PLUGIN object in the SYMBOL_LIB_TABLE. More...

#include <symbol_lib_table.h>

Inheritance diagram for SYMBOL_LIB_TABLE_ROW:
LIB_TABLE_ROW

Public Types

typedef SCH_IO_MGR::SCH_FILE_T LIB_T
 

Public Member Functions

 SYMBOL_LIB_TABLE_ROW (const wxString &aNick, const wxString &aURI, const wxString &aType, const wxString &aOptions=wxEmptyString, const wxString &aDescr=wxEmptyString)
 
 SYMBOL_LIB_TABLE_ROW ()
 
bool operator== (const SYMBOL_LIB_TABLE_ROW &aRow) const
 
bool operator!= (const SYMBOL_LIB_TABLE_ROW &aRow) const
 
const wxString GetType () const override
 Return the type of symbol library table represented by this row. More...
 
void SetType (const wxString &aType) override
 Change the schematic plugin type represented by this row. More...
 
bool Refresh ()
 Attempt to reload the library. More...
 
bool operator== (const LIB_TABLE_ROW &r) const
 
bool operator!= (const LIB_TABLE_ROW &r) const
 
const wxString & GetNickName () const
 
void SetNickName (const wxString &aNickName)
 Change the logical name of this library, useful for an editor. More...
 
bool GetIsLoaded () const
 
void SetLoaded (bool aLoaded)
 Mark the row as being a loaded library. More...
 
bool GetIsEnabled () const
 
void SetEnabled (bool aEnabled=true)
 Change the enabled status of this library. More...
 
const wxString GetFullURI (bool aSubstituted=false) const
 Return the full location specifying URI for the LIB, either in original UI form or in environment variable expanded form. More...
 
void SetFullURI (const wxString &aFullURI)
 Change the full URI for the library. More...
 
const wxString & GetOptions () const
 Return the options string, which may hold a password or anything else needed to instantiate the underlying library plugin. More...
 
void SetOptions (const wxString &aOptions)
 Change the library options strings. More...
 
const wxString & GetDescr () const
 Return the description of the library referenced by this row. More...
 
void SetDescr (const wxString &aDescr)
 Change the description of the library referenced by this row. More...
 
const PROPERTIESGetProperties () const
 Return the constant PROPERTIES for this library (LIB_TABLE_ROW). More...
 
void Format (OUTPUTFORMATTER *out, int nestLevel) const
 Serialize this object as utf8 text to an OUTPUTFORMATTER, and tries to make it look good using multiple lines and indentation. More...
 
LIB_TABLE_ROWclone () const
 

Protected Member Functions

 SYMBOL_LIB_TABLE_ROW (const SYMBOL_LIB_TABLE_ROW &aRow)
 

Private Member Functions

virtual LIB_TABLE_ROWdo_clone () const override
 
void setPlugin (SCH_PLUGIN *aPlugin)
 

Private Attributes

SCH_PLUGIN::SCH_PLUGIN_RELEASER plugin
 
LIB_T type
 

Friends

class SYMBOL_LIB_TABLE
 

Detailed Description

Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_PLUGIN object in the SYMBOL_LIB_TABLE.

Definition at line 42 of file symbol_lib_table.h.

Member Typedef Documentation

◆ LIB_T

typedef SCH_IO_MGR::SCH_FILE_T SYMBOL_LIB_TABLE_ROW::LIB_T

Definition at line 47 of file symbol_lib_table.h.

Constructor & Destructor Documentation

◆ SYMBOL_LIB_TABLE_ROW() [1/3]

SYMBOL_LIB_TABLE_ROW::SYMBOL_LIB_TABLE_ROW ( const wxString &  aNick,
const wxString &  aURI,
const wxString &  aType,
const wxString &  aOptions = wxEmptyString,
const wxString &  aDescr = wxEmptyString 
)
inline

Definition at line 49 of file symbol_lib_table.h.

51  :
52  LIB_TABLE_ROW( aNick, aURI, aOptions, aDescr )
53  {
54  SetType( aType );
55  SetEnabled( true );
56  }
void SetType(const wxString &aType) override
Change the schematic plugin type represented by this row.
void SetEnabled(bool aEnabled=true)
Change the enabled status of this library.

References LIB_TABLE_ROW::SetEnabled(), and SetType().

◆ SYMBOL_LIB_TABLE_ROW() [2/3]

SYMBOL_LIB_TABLE_ROW::SYMBOL_LIB_TABLE_ROW ( )
inline

Definition at line 58 of file symbol_lib_table.h.

58  :
59  type( SCH_IO_MGR::SCH_KICAD )
60  {
61  SetEnabled( true );
62  }
void SetEnabled(bool aEnabled=true)
Change the enabled status of this library.

References LIB_TABLE_ROW::SetEnabled().

Referenced by do_clone().

◆ SYMBOL_LIB_TABLE_ROW() [3/3]

SYMBOL_LIB_TABLE_ROW::SYMBOL_LIB_TABLE_ROW ( const SYMBOL_LIB_TABLE_ROW aRow)
inlineprotected

Definition at line 86 of file symbol_lib_table.h.

86  :
87  LIB_TABLE_ROW( aRow ),
88  type( aRow.type )
89  {
90  SetEnabled( aRow.GetIsEnabled() );
91  }
void SetEnabled(bool aEnabled=true)
Change the enabled status of this library.
bool GetIsEnabled() const

References LIB_TABLE_ROW::GetIsEnabled(), and LIB_TABLE_ROW::SetEnabled().

Member Function Documentation

◆ clone()

LIB_TABLE_ROW* LIB_TABLE_ROW::clone ( ) const
inlineinherited

Definition at line 185 of file lib_table_base.h.

186  {
187  return do_clone();
188  }
virtual LIB_TABLE_ROW * do_clone() const =0

References LIB_TABLE_ROW::do_clone().

Referenced by new_clone(), SYMBOL_GRID_TRICKS::paste_text(), and FP_GRID_TRICKS::paste_text().

◆ do_clone()

virtual LIB_TABLE_ROW* SYMBOL_LIB_TABLE_ROW::do_clone ( ) const
inlineoverrideprivatevirtual

Implements LIB_TABLE_ROW.

Definition at line 95 of file symbol_lib_table.h.

96  {
97  return new SYMBOL_LIB_TABLE_ROW( *this );
98  }

References SYMBOL_LIB_TABLE_ROW().

◆ Format()

void LIB_TABLE_ROW::Format ( OUTPUTFORMATTER out,
int  nestLevel 
) const
inherited

Serialize this object as utf8 text to an OUTPUTFORMATTER, and tries to make it look good using multiple lines and indentation.

Parameters
outis an OUTPUTFORMATTER
nestLevelis the indentation level to base all lines of the output. Actual indentation will be 2 spaces for each nestLevel.

Definition at line 85 of file lib_table_base.cpp.

86 {
87  // In Kicad, we save path and file names using the Unix notation (separator = '/')
88  // So ensure separator is always '/' is saved URI string
89  wxString uri = GetFullURI();
90  uri.Replace( '\\', '/' );
91 
92  wxString extraOptions;
93 
94  if( !GetIsEnabled() )
95  {
96  extraOptions += "(disabled)";
97  }
98 
99  out->Print( nestLevel, "(lib (name %s)(type %s)(uri %s)(options %s)(descr %s)%s)\n",
100  out->Quotew( GetNickName() ).c_str(),
101  out->Quotew( GetType() ).c_str(),
102  out->Quotew( uri ).c_str(),
103  out->Quotew( GetOptions() ).c_str(),
104  out->Quotew( GetDescr() ).c_str(),
105  extraOptions.ToStdString().c_str()
106  );
107 }
const wxString & GetOptions() const
Return the options string, which may hold a password or anything else needed to instantiate the under...
virtual const wxString GetType() const =0
Return the type of library represented by this row.
const wxString & GetDescr() const
Return the description of the library referenced by this row.
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
const wxString & GetNickName() const
bool GetIsEnabled() const
std::string Quotew(const wxString &aWrapee)
Definition: richio.cpp:472
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404

References OUTPUTFORMATTER::Print(), and OUTPUTFORMATTER::Quotew().

◆ GetDescr()

const wxString& LIB_TABLE_ROW::GetDescr ( ) const
inlineinherited

◆ GetFullURI()

const wxString LIB_TABLE_ROW::GetFullURI ( bool  aSubstituted = false) const
inherited

Return the full location specifying URI for the LIB, either in original UI form or in environment variable expanded form.

Parameters
aSubstitutedTells if caller wanted the substituted form, else not.

Definition at line 69 of file lib_table_base.cpp.

70 {
71  if( aSubstituted )
72  {
73 #if !FP_LATE_ENVVAR // early expansion
74  return uri_expanded;
75 
76 #else // late expansion
77  return ExpandEnvVarSubstitutions( uri_user, nullptr );
78 #endif
79  }
80 
81  return uri_user;
82 }
const wxString ExpandEnvVarSubstitutions(const wxString &aString, PROJECT *aProject)
Replace any environment variable & text variable references with their values.
Definition: common.cpp:581
wxString uri_user
what user entered from UI or loaded from disk

References ExpandEnvVarSubstitutions().

Referenced by SYMBOL_LIB_TABLE::CreateSymbolLib(), FOOTPRINT_EDIT_FRAME::DeleteModuleFromLibrary(), SYMBOL_LIB_TABLE::DeleteSymbol(), SYMBOL_LIB_TABLE::DeleteSymbolLib(), LIB_VIEW_FRAME::DisplayLibInfos(), SYMBOL_LIB_TABLE::EnumerateSymbolLib(), FP_LIB_TABLE::FootprintDelete(), FP_LIB_TABLE::FootprintEnumerate(), FP_LIB_TABLE::FootprintExists(), FP_LIB_TABLE::FootprintLibCreate(), FP_LIB_TABLE::FootprintLibDelete(), FP_LIB_TABLE::FootprintLoad(), FP_LIB_TABLE::FootprintSave(), FP_LIB_TABLE::GenerateTimestamp(), FP_LIB_TABLE::GetEnumeratedFootprint(), LIB_TABLE::GetFullURI(), LIB_TABLE_GRID::GetValue(), FP_LIB_TABLE::IsFootprintLibWritable(), SYMBOL_LIB_TABLE::IsSymbolLibWritable(), SCH_EDIT_FRAME::LoadSheetFromFile(), SYMBOL_LIB_TABLE::LoadSymbol(), SYMBOL_LIB_TABLE::LoadSymbolLib(), FP_LIB_TABLE::PrefetchLib(), FOOTPRINT_EDIT_FRAME::SaveFootprint(), FOOTPRINT_EDIT_FRAME::SaveFootprintAs(), SYMBOL_LIB_TABLE::SaveSymbol(), and FOOTPRINT_VIEWER_FRAME::UpdateTitle().

◆ GetIsEnabled()

bool LIB_TABLE_ROW::GetIsEnabled ( ) const
inlineinherited
Returns
the enabled status of this library row

Definition at line 117 of file lib_table_base.h.

117 { return enabled; }
bool enabled
Whether the LIB_TABLE_ROW is enabled.

References LIB_TABLE_ROW::enabled.

Referenced by LIB_TABLE_GRID::GetValue(), LIB_TABLE_GRID::GetValueAsBool(), LIB_TABLE::HasLibrary(), SYMBOL_LIB_TABLE_ROW(), and PANEL_SYM_LIB_TABLE::verifyTables().

◆ GetIsLoaded()

bool LIB_TABLE_ROW::GetIsLoaded ( ) const
inlineinherited
Returns
true if the library was loaded without error

Definition at line 107 of file lib_table_base.h.

107 { return m_loaded; }
bool m_loaded
Whether the LIB_TABLE_ROW is loaded.

References LIB_TABLE_ROW::m_loaded.

Referenced by SYMBOL_LIB_TABLE::IsSymbolLibLoaded().

◆ GetNickName()

◆ GetOptions()

const wxString& LIB_TABLE_ROW::GetOptions ( ) const
inlineinherited

Return the options string, which may hold a password or anything else needed to instantiate the underlying library plugin.

Definition at line 152 of file lib_table_base.h.

152 { return options; }
wxString options

References LIB_TABLE_ROW::options.

Referenced by SYMBOL_LIB_TABLE::EnumerateSymbolLib(), LIB_TABLE_GRID::GetValue(), SCH_EDIT_FRAME::LoadSheetFromFile(), SYMBOL_LIB_TABLE::LoadSymbolLib(), and FP_GRID_TRICKS::optionsEditor().

◆ GetProperties()

◆ GetType()

const wxString SYMBOL_LIB_TABLE_ROW::GetType ( ) const
inlineoverridevirtual

Return the type of symbol library table represented by this row.

Implements LIB_TABLE_ROW.

Definition at line 71 of file symbol_lib_table.h.

71 { return SCH_IO_MGR::ShowType( type ); }
static const wxString ShowType(SCH_FILE_T aFileType)
Return a brief name for a plugin, given aFileType enum.
Definition: sch_io_mgr.cpp:84

References SCH_IO_MGR::ShowType(), and type.

Referenced by SCH_EDIT_FRAME::LoadSheetFromFile().

◆ operator!=() [1/2]

bool SYMBOL_LIB_TABLE_ROW::operator!= ( const SYMBOL_LIB_TABLE_ROW aRow) const
inline

Definition at line 66 of file symbol_lib_table.h.

66 { return !( *this == aRow ); }

◆ operator!=() [2/2]

bool LIB_TABLE_ROW::operator!= ( const LIB_TABLE_ROW r) const
inlineinherited

Definition at line 92 of file lib_table_base.h.

92 { return !( *this == r ); }

◆ operator==() [1/2]

bool SYMBOL_LIB_TABLE_ROW::operator== ( const SYMBOL_LIB_TABLE_ROW aRow) const

Definition at line 57 of file symbol_lib_table.cpp.

58 {
59  return LIB_TABLE_ROW::operator == ( aRow ) && type == aRow.type;
60 }
bool operator==(const LIB_TABLE_ROW &r) const

References LIB_TABLE_ROW::operator==(), and type.

◆ operator==() [2/2]

bool LIB_TABLE_ROW::operator== ( const LIB_TABLE_ROW r) const
inherited

Definition at line 110 of file lib_table_base.cpp.

111 {
112  return nickName == r.nickName
113  && uri_user == r.uri_user
114  && options == r.options
115  && description == r.description
116  && enabled == r.enabled;
117 }
bool enabled
Whether the LIB_TABLE_ROW is enabled.
wxString description
wxString options
wxString nickName
wxString uri_user
what user entered from UI or loaded from disk

References LIB_TABLE_ROW::description, LIB_TABLE_ROW::enabled, LIB_TABLE_ROW::nickName, LIB_TABLE_ROW::options, and LIB_TABLE_ROW::uri_user.

Referenced by FP_LIB_TABLE_ROW::operator==(), and operator==().

◆ Refresh()

bool SYMBOL_LIB_TABLE_ROW::Refresh ( )

Attempt to reload the library.

Returns
true if a reload was required.
Exceptions
IO_ERRORif the reload was unsuccessful.

Definition at line 74 of file symbol_lib_table.cpp.

75 {
76  if( !plugin )
77  {
78  wxArrayString dummyList;
79 
80  plugin.set( SCH_IO_MGR::FindPlugin( type ) );
81  SetLoaded( false );
82  plugin->EnumerateSymbolLib( dummyList, GetFullURI( true ), GetProperties() );
83  SetLoaded( true );
84  return true;
85  }
86 
87  return false;
88 }
SCH_PLUGIN::SCH_PLUGIN_RELEASER plugin
void set(SCH_PLUGIN *aPlugin)
Definition: sch_io_mgr.h:497
const wxString GetFullURI(bool aSubstituted=false) const
Return the full location specifying URI for the LIB, either in original UI form or in environment var...
void SetLoaded(bool aLoaded)
Mark the row as being a loaded library.
const PROPERTIES * GetProperties() const
Return the constant PROPERTIES for this library (LIB_TABLE_ROW).

Referenced by PANEL_SYM_LIB_TABLE::verifyTables().

◆ SetDescr()

void LIB_TABLE_ROW::SetDescr ( const wxString &  aDescr)
inlineinherited

Change the description of the library referenced by this row.

Definition at line 167 of file lib_table_base.h.

167 { description = aDescr; }
wxString description

References LIB_TABLE_ROW::description.

Referenced by LIB_TABLE_GRID::SetValue().

◆ SetEnabled()

void LIB_TABLE_ROW::SetEnabled ( bool  aEnabled = true)
inlineinherited

Change the enabled status of this library.

Definition at line 122 of file lib_table_base.h.

122 { enabled = aEnabled; }
bool enabled
Whether the LIB_TABLE_ROW is enabled.

References LIB_TABLE_ROW::enabled.

Referenced by LIB_TABLE_GRID::SetValue(), LIB_TABLE_GRID::SetValueAsBool(), and SYMBOL_LIB_TABLE_ROW().

◆ SetFullURI()

void LIB_TABLE_ROW::SetFullURI ( const wxString &  aFullURI)
inherited

Change the full URI for the library.

Definition at line 59 of file lib_table_base.cpp.

60 {
61  uri_user = aFullURI;
62 
63 #if !FP_LATE_ENVVAR
64  uri_expanded = FP_LIB_TABLE::ExpandSubstitutions( aFullURI );
65 #endif
66 }
wxString uri_user
what user entered from UI or loaded from disk

Referenced by LIB_TABLE_ROW::LIB_TABLE_ROW(), and LIB_TABLE_GRID::SetValue().

◆ SetLoaded()

void LIB_TABLE_ROW::SetLoaded ( bool  aLoaded)
inlineinherited

Mark the row as being a loaded library.

Definition at line 112 of file lib_table_base.h.

112 { m_loaded = aLoaded; };
bool m_loaded
Whether the LIB_TABLE_ROW is loaded.

References LIB_TABLE_ROW::m_loaded.

Referenced by SYMBOL_LIB_TABLE::EnumerateSymbolLib(), and SYMBOL_LIB_TABLE::LoadSymbolLib().

◆ SetNickName()

void LIB_TABLE_ROW::SetNickName ( const wxString &  aNickName)
inlineinherited

Change the logical name of this library, useful for an editor.

Definition at line 102 of file lib_table_base.h.

102 { nickName = aNickName; }
wxString nickName

References LIB_TABLE_ROW::nickName.

Referenced by LIB_TABLE_GRID::SetValue().

◆ SetOptions()

void LIB_TABLE_ROW::SetOptions ( const wxString &  aOptions)
inherited

Change the library options strings.

Definition at line 120 of file lib_table_base.cpp.

121 {
122  options = aOptions;
123 
124  // set PROPERTIES* from options
126 }
void setProperties(PROPERTIES *aProperties)
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:100
static PROPERTIES * ParseOptions(const std::string &aOptionsList)
Parses aOptionsList and places the result into a PROPERTIES object which is returned.
wxString options

References LIB_TABLE::ParseOptions(), and TO_UTF8.

Referenced by SYMBOL_LIB_TABLE::EnumerateSymbolLib(), LIB_TABLE_ROW::LIB_TABLE_ROW(), SYMBOL_LIB_TABLE::LoadSymbolLib(), FP_GRID_TRICKS::optionsEditor(), and LIB_TABLE_GRID::SetValue().

◆ setPlugin()

void SYMBOL_LIB_TABLE_ROW::setPlugin ( SCH_PLUGIN aPlugin)
inlineprivate

Definition at line 100 of file symbol_lib_table.h.

101  {
102  plugin.set( aPlugin );
103  }
SCH_PLUGIN::SCH_PLUGIN_RELEASER plugin
void set(SCH_PLUGIN *aPlugin)
Definition: sch_io_mgr.h:497

References plugin, and SCH_PLUGIN::SCH_PLUGIN_RELEASER::set().

Referenced by SYMBOL_LIB_TABLE::FindRow().

◆ SetType()

void SYMBOL_LIB_TABLE_ROW::SetType ( const wxString &  aType)
overridevirtual

Change the schematic plugin type represented by this row.

Implements LIB_TABLE_ROW.

Definition at line 63 of file symbol_lib_table.cpp.

64 {
65  type = SCH_IO_MGR::EnumFromStr( aType );
66 
67  if( SCH_IO_MGR::SCH_FILE_T( -1 ) == type )
68  type = SCH_IO_MGR::SCH_LEGACY;
69 
70  plugin.release();
71 }
SCH_PLUGIN::SCH_PLUGIN_RELEASER plugin
static SCH_FILE_T EnumFromStr(const wxString &aFileType)
Return the #SCH_FILE_T from the corresponding plugin type name: "kicad", "legacy",...
Definition: sch_io_mgr.cpp:110

References SCH_IO_MGR::EnumFromStr().

Referenced by SYMBOL_LIB_TABLE_ROW().

Friends And Related Function Documentation

◆ SYMBOL_LIB_TABLE

friend class SYMBOL_LIB_TABLE
friend

Definition at line 44 of file symbol_lib_table.h.

Member Data Documentation

◆ plugin

◆ type

LIB_T SYMBOL_LIB_TABLE_ROW::type
private

Definition at line 106 of file symbol_lib_table.h.

Referenced by SYMBOL_LIB_TABLE::FindRow(), GetType(), and operator==().


The documentation for this class was generated from the following files: