KiCad PCB EDA Suite
Loading...
Searching...
No Matches
SYMBOL_LIB Class Reference

Object used to load, save, search, and otherwise manipulate symbol library files. More...

#include <symbol_library.h>

Public Member Functions

 SYMBOL_LIB (SCH_LIB_TYPE aType, const wxString &aFileName, SCH_IO_MGR::SCH_FILE_T aPluginType=SCH_IO_MGR::SCH_LEGACY)
 
 ~SYMBOL_LIB ()
 
int GetModHash () const
 
SCH_IO_MGR::SCH_FILE_T GetPluginType () const
 
void SetPluginType (SCH_IO_MGR::SCH_FILE_T aPluginType)
 
void Create (const wxString &aFileName=wxEmptyString)
 
void SetFileName (const wxString &aFileName)
 
bool IsModified () const
 
bool IsCache () const
 
void SetCache ()
 
bool IsBuffering () const
 
void EnableBuffering (bool aEnable=true)
 
void Save (bool aSaveDocFile=true)
 
bool IsReadOnly () const
 
void GetSymbolNames (wxArrayString &aNames) const
 Load a string array with the names of all the entries in this library.
 
void GetSymbols (std::vector< LIB_SYMBOL * > &aSymbols) const
 Load a vector with all the entries in this library.
 
LIB_SYMBOLFindSymbol (const wxString &aName) const
 Find LIB_SYMBOL by aName.
 
LIB_SYMBOLFindSymbol (const LIB_ID &aLibId) const
 
void AddSymbol (LIB_SYMBOL *aSymbol)
 Add aSymbol entry to library.
 
LIB_SYMBOLRemoveSymbol (LIB_SYMBOL *aEntry)
 Safely remove aEntry from the library and return the next entry.
 
LIB_SYMBOLReplaceSymbol (LIB_SYMBOL *aOldSymbol, LIB_SYMBOL *aNewSymbol)
 Replace an existing symbol entry in the library.
 
const wxString GetName () const
 Return the file name without path or extension.
 
wxString GetFullFileName () const
 Return the full file library name with path and extension.
 
const wxString GetLogicalName () const
 Return the logical name of the library.
 

Static Public Member Functions

static SYMBOL_LIBLoadSymbolLibrary (const wxString &aFileName)
 Allocate and load a symbol library file.
 

Private Attributes

SCH_LIB_TYPE type
 Library type indicator.
 
wxFileName fileName
 Library file name.
 
wxDateTime timeStamp
 Library save time and date.
 
int versionMajor
 Library major version number.
 
int versionMinor
 Library minor version number.
 
wxString header
 first line of loaded library.
 
bool isModified
 Library modification status.
 
int m_mod_hash
 incremented each time library is changed.
 
SCH_IO_MGR::SCH_FILE_T m_pluginType
 
std::unique_ptr< SCH_IOm_plugin
 
std::unique_ptr< std::map< std::string, UTF8 > > m_properties
 Library properties.
 

Detailed Description

Object used to load, save, search, and otherwise manipulate symbol library files.

Warning
This code is obsolete with the exception of the cache library. All other symbol library I/O is managed by the SCH_IO_MGR object.

Definition at line 175 of file symbol_library.h.

Constructor & Destructor Documentation

◆ SYMBOL_LIB()

SYMBOL_LIB::SYMBOL_LIB ( SCH_LIB_TYPE  aType,
const wxString &  aFileName,
SCH_IO_MGR::SCH_FILE_T  aPluginType = SCH_IO_MGR::SCH_LEGACY 
)

◆ ~SYMBOL_LIB()

SYMBOL_LIB::~SYMBOL_LIB ( )

Definition at line 69 of file symbol_library.cpp.

Member Function Documentation

◆ AddSymbol()

void SYMBOL_LIB::AddSymbol ( LIB_SYMBOL aSymbol)

Add aSymbol entry to library.

Note
A LIB_SYMBOL can have an alias list so these alias will be added in library. and the any existing duplicate aliases will be removed from the library.
Parameters
aSymbolis the symbol to add, caller retains ownership, a clone is added.

Definition at line 183 of file symbol_library.cpp.

References fileName, IsBuffering(), isModified, m_mod_hash, m_plugin, m_properties, and LIB_SYMBOL::SharedPtr().

◆ Create()

void SYMBOL_LIB::Create ( const wxString &  aFileName = wxEmptyString)

Definition at line 90 of file symbol_library.cpp.

References fileName, m_plugin, and m_properties.

◆ EnableBuffering()

void SYMBOL_LIB::EnableBuffering ( bool  aEnable = true)

Definition at line 129 of file symbol_library.cpp.

References m_properties, and SCH_IO_KICAD_LEGACY::PropBuffering.

◆ FindSymbol() [1/2]

LIB_SYMBOL * SYMBOL_LIB::FindSymbol ( const LIB_ID aLibId) const

Definition at line 177 of file symbol_library.cpp.

References FindSymbol(), LIB_ID::Format(), and UTF8::wx_str().

◆ FindSymbol() [2/2]

LIB_SYMBOL * SYMBOL_LIB::FindSymbol ( const wxString &  aName) const

Find LIB_SYMBOL by aName.

Parameters
aNameis the name of the symbol, case sensitive.
Returns
LIB_SYMBOL pointer symbol if found, else NULL.

Definition at line 158 of file symbol_library.cpp.

References fileName, LIB_SYMBOL::GetLib(), m_plugin, m_properties, and LIB_SYMBOL::SetLib().

Referenced by SYMBOL_LIBS::FindLibraryNearEntries(), SYMBOL_LIBS::FindLibSymbol(), FindSymbol(), SchGetLibSymbol(), and SCH_SCREEN::UpdateSymbolLinks().

◆ GetFullFileName()

wxString SYMBOL_LIB::GetFullFileName ( ) const
inline

Return the full file library name with path and extension.

Returns
the full library file name with path and extension.

Definition at line 285 of file symbol_library.h.

References fileName.

◆ GetLogicalName()

const wxString SYMBOL_LIB::GetLogicalName ( ) const
inline

Return the logical name of the library.

Returns
The logical name of this library.

Definition at line 292 of file symbol_library.h.

References fileName.

◆ GetModHash()

int SYMBOL_LIB::GetModHash ( ) const
inline
Returns
a magic number that changes if the library has changed

Definition at line 185 of file symbol_library.h.

References m_mod_hash.

◆ GetName()

const wxString SYMBOL_LIB::GetName ( ) const
inline

Return the file name without path or extension.

Returns
the name of library file.

Definition at line 278 of file symbol_library.h.

References fileName.

Referenced by SYMBOL_LIBS::FindLibraryNearEntries(), SYMBOL_LIBS::FindLibSymbol(), LIB_SYMBOL::GetLibraryName(), and SYMBOL_LIBS::GetLibraryNames().

◆ GetPluginType()

SCH_IO_MGR::SCH_FILE_T SYMBOL_LIB::GetPluginType ( ) const
inline

Definition at line 187 of file symbol_library.h.

References m_pluginType.

◆ GetSymbolNames()

void SYMBOL_LIB::GetSymbolNames ( wxArrayString &  aNames) const

Load a string array with the names of all the entries in this library.

Parameters
aNamesis the array to place entry names into.

Definition at line 138 of file symbol_library.cpp.

References fileName, m_plugin, and m_properties.

Referenced by SYMBOL_LIBS::FindLibraryNearEntries().

◆ GetSymbols()

void SYMBOL_LIB::GetSymbols ( std::vector< LIB_SYMBOL * > &  aSymbols) const

Load a vector with all the entries in this library.

Parameters
aSymbolsis a vector to receive the aliases.

Definition at line 146 of file symbol_library.cpp.

References fileName, m_plugin, and m_properties.

Referenced by LEGACY_RESCUER::OpenRescueLibrary().

◆ IsBuffering()

bool SYMBOL_LIB::IsBuffering ( ) const

Definition at line 123 of file symbol_library.cpp.

References m_properties, and SCH_IO_KICAD_LEGACY::PropBuffering.

Referenced by AddSymbol(), RemoveSymbol(), and ReplaceSymbol().

◆ IsCache()

bool SYMBOL_LIB::IsCache ( ) const

◆ IsModified()

bool SYMBOL_LIB::IsModified ( ) const
inline

Definition at line 195 of file symbol_library.h.

References isModified.

◆ IsReadOnly()

bool SYMBOL_LIB::IsReadOnly ( ) const
inline
Returns
true if current user does not have write access to the library file.

Definition at line 213 of file symbol_library.h.

References fileName.

◆ LoadSymbolLibrary()

SYMBOL_LIB * SYMBOL_LIB::LoadSymbolLibrary ( const wxString &  aFileName)
static

Allocate and load a symbol library file.

Parameters
aFileNameis the file name of the symbol library to load.
Returns
SYMBOL_LIB* is the allocated and loaded SYMBOL_LIB, which is owned by the caller.
Exceptions
IO_ERRORif there's any problem loading the library.

Definition at line 236 of file symbol_library.cpp.

References LIB_SYMBOL::SetLib().

Referenced by SYMBOL_LIBS::AddLibrary(), and SYMBOL_LIBS::ReloadLibrary().

◆ RemoveSymbol()

LIB_SYMBOL * SYMBOL_LIB::RemoveSymbol ( LIB_SYMBOL aEntry)

Safely remove aEntry from the library and return the next entry.

The next entry returned depends on the entry being removed. If the entry being remove also removes the symbol, then the next entry from the list is returned. If the entry being used only removes an alias from a symbol, then the next alias of the symbol is returned.

Parameters
aEntryis the entry to remove from library.
Returns
The next entry in the library or NULL if the library is empty.

Definition at line 199 of file symbol_library.cpp.

References fileName, LIB_SYMBOL::GetName(), IsBuffering(), isModified, m_mod_hash, m_plugin, and m_properties.

◆ ReplaceSymbol()

LIB_SYMBOL * SYMBOL_LIB::ReplaceSymbol ( LIB_SYMBOL aOldSymbol,
LIB_SYMBOL aNewSymbol 
)

Replace an existing symbol entry in the library.

Note
A symbol can have an alias list so these aliases will be added in library and previously existing alias removed.
Parameters
aOldSymbolis the symbol to replace.
aNewSymbolis the new symbol.

Definition at line 215 of file symbol_library.cpp.

References fileName, LIB_SYMBOL::GetName(), IsBuffering(), isModified, m_mod_hash, m_plugin, and m_properties.

◆ Save()

void SYMBOL_LIB::Save ( bool  aSaveDocFile = true)

Definition at line 74 of file symbol_library.cpp.

References fileName, isModified, m_plugin, and SCH_IO_KICAD_LEGACY::PropNoDocFile.

◆ SetCache()

void SYMBOL_LIB::SetCache ( )

Definition at line 117 of file symbol_library.cpp.

References SCH_IO_KICAD_LEGACY::PropNoDocFile.

Referenced by SYMBOL_LIBS::LoadAllLibraries().

◆ SetFileName()

void SYMBOL_LIB::SetFileName ( const wxString &  aFileName)
inline

Definition at line 193 of file symbol_library.h.

References fileName.

◆ SetPluginType()

void SYMBOL_LIB::SetPluginType ( SCH_IO_MGR::SCH_FILE_T  aPluginType)

Definition at line 101 of file symbol_library.cpp.

References m_plugin, and m_pluginType.

Member Data Documentation

◆ fileName

wxFileName SYMBOL_LIB::fileName
private

◆ header

wxString SYMBOL_LIB::header
private

first line of loaded library.

Definition at line 320 of file symbol_library.h.

◆ isModified

bool SYMBOL_LIB::isModified
private

Library modification status.

Definition at line 321 of file symbol_library.h.

Referenced by AddSymbol(), IsModified(), RemoveSymbol(), ReplaceSymbol(), Save(), and SYMBOL_LIB().

◆ m_mod_hash

int SYMBOL_LIB::m_mod_hash
private

incremented each time library is changed.

Definition at line 322 of file symbol_library.h.

Referenced by AddSymbol(), GetModHash(), RemoveSymbol(), ReplaceSymbol(), and SYMBOL_LIB().

◆ m_plugin

std::unique_ptr< SCH_IO > SYMBOL_LIB::m_plugin
private

◆ m_pluginType

SCH_IO_MGR::SCH_FILE_T SYMBOL_LIB::m_pluginType
private

Definition at line 324 of file symbol_library.h.

Referenced by GetPluginType(), SetPluginType(), and SYMBOL_LIB().

◆ m_properties

std::unique_ptr<std::map<std::string, UTF8> > SYMBOL_LIB::m_properties
private

◆ timeStamp

wxDateTime SYMBOL_LIB::timeStamp
private

Library save time and date.

Definition at line 317 of file symbol_library.h.

Referenced by SYMBOL_LIB().

◆ type

SCH_LIB_TYPE SYMBOL_LIB::type
private

Library type indicator.

Definition at line 315 of file symbol_library.h.

Referenced by SYMBOL_LIB().

◆ versionMajor

int SYMBOL_LIB::versionMajor
private

Library major version number.

Definition at line 318 of file symbol_library.h.

Referenced by SYMBOL_LIB().

◆ versionMinor

int SYMBOL_LIB::versionMinor
private

Library minor version number.

Definition at line 319 of file symbol_library.h.

Referenced by SYMBOL_LIB().


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