70 while( !loader.
Done() )
87 msg.Replace(
"\n",
"<BR>" );
99 if( buffer.IsModified() )
112 hash += buffer.GetHash();
120 const auto libBufIt =
m_libs.find( aLibrary );
122 if( libBufIt !=
m_libs.end() )
123 return libBufIt->second.GetHash();
128 return row ? std::hash<std::string>{}( aLibrary.ToStdString() +
137 for(
const wxString& libName :
symTable()->GetLogicalLibs() )
142 if( !row || row->
SchLibType() == SCH_IO_MGR::SCH_DATABASE )
164 msg.Printf(
_(
"Library '%s' not found in the Symbol Library Table." ), aLibrary );
173 SCH_IO_MGR::SCH_FILE_T aFileType )
175 wxCHECK( aFileType != SCH_IO_MGR::SCH_FILE_T::SCH_LEGACY,
false );
177 wxString::Format(
"Library missing: %s", aLibrary ) );
179 wxFileName fn( aFileName );
180 wxCHECK( !fn.FileExists() || fn.IsFileWritable(),
false );
184 std::map<std::string, UTF8> properties;
188 auto it =
m_libs.find( aLibrary );
195 const auto& symbolBuffers = libBuf.
GetBuffers();
197 for(
const std::shared_ptr<SYMBOL_BUFFER>& symbolBuf : symbolBuffers )
199 wxCHECK2( symbolBuf,
continue );
200 if( !libBuf.
SaveBuffer( *symbolBuf, aFileName, &*pi,
true ) )
208 wxFileName original, destination( aFileName );
219 if(
res && original == destination )
231 if( symbol->IsDerived() )
233 std::shared_ptr< LIB_SYMBOL > oldParent = symbol->
GetParent().lock();
235 wxCHECK_MSG( oldParent,
false,
236 wxString::Format( wxT(
"Derived symbol '%s' found with "
237 "undefined parent." ),
238 symbol->GetName() ) );
240 LIB_SYMBOL* libParent = pi->LoadSymbol( aLibrary, oldParent->GetName(),
245 libParent =
new LIB_SYMBOL( *oldParent.get() );
246 pi->SaveSymbol( aLibrary, libParent, &properties );
251 pi->SaveSymbol( aLibrary, newSymbol, &properties );
253 else if( !pi->LoadSymbol( aLibrary, symbol->GetName(), &properties ) )
255 pi->SaveSymbol( aLibrary,
new LIB_SYMBOL( *symbol ), &properties );
268 pi->SaveLibrary( aFileName );
283 auto it =
m_libs.find( aLibrary );
284 return it !=
m_libs.end() ? it->second.IsModified() :
false;
289 const wxString& aLibrary )
const
291 auto libIt =
m_libs.find( aLibrary );
293 if( libIt ==
m_libs.end() )
297 const std::shared_ptr<SYMBOL_BUFFER> symbolBuf = buf.
GetBuffer( aSymbolName );
299 return symbolBuf ? symbolBuf->IsModified() :
false;
304 const wxString& aLibrary )
306 auto libIt =
m_libs.find( aLibrary );
308 if( libIt ==
m_libs.end() )
312 std::shared_ptr<SYMBOL_BUFFER> symbolBuf = buf.
GetBuffer( aSymbolName );
314 wxCHECK( symbolBuf, );
316 symbolBuf->GetScreen()->SetContentModified();
322 auto libIt =
m_libs.find( aLibrary );
324 if( libIt ==
m_libs.end() )
327 for(
auto& symbolBuf : libIt->second.GetBuffers() )
340 const wxString& aLibrary )
const
342 auto libIt =
m_libs.find( aLibrary );
344 if( libIt ==
m_libs.end() )
347 auto symbolBuf = libIt->second.GetBuffer( aSymbolName );
348 wxCHECK( symbolBuf,
false );
350 symbolBuf->GetScreen()->SetContentModified(
false );
358 wxString::Format(
"Library missing: %s", aLibrary ) );
367 wxString::Format(
"Library missing: %s", aLibrary ) );
375 std::list<LIB_SYMBOL*> ret;
377 wxString::Format(
"Library missing: %s", aLibrary ) );
379 auto libIt =
m_libs.find( aLibrary );
381 if( libIt !=
m_libs.end() )
383 for(
const std::shared_ptr<SYMBOL_BUFFER>& symbolBuf : libIt->second.GetBuffers() )
384 ret.push_back( &symbolBuf->GetSymbol() );
388 std::vector<LIB_SYMBOL*> symbols;
399 std::copy( symbols.begin(), symbols.end(), std::back_inserter( ret ) );
407 const wxString& aLibrary )
410 wxString::Format(
"Library missing: %s, for symbol %s", aLibrary, aSymbolName ) );
416 if( !bufferedSymbol )
423 if( symbol ==
nullptr )
431 std::shared_ptr<LIB_SYMBOL> parent = symbol->
GetParent().lock();
432 wxCHECK_MSG( parent,
nullptr,
433 wxString::Format(
"Derived symbol '%s' found with undefined parent.",
437 bufferedParent = libBuf.
GetSymbol( parent->GetName() );
439 if( !bufferedParent )
441 auto newParent = std::make_unique<LIB_SYMBOL>( *parent.get() );
442 bufferedParent = newParent.get();
443 libBuf.
CreateBuffer( std::move( newParent ), std::make_unique<SCH_SCREEN>() );
447 auto newSymbol = std::make_unique<LIB_SYMBOL>( *symbol );
448 bufferedSymbol = newSymbol.get();
453 libBuf.
CreateBuffer( std::move( newSymbol ), std::make_unique<SCH_SCREEN>() );
459 msg.Printf(
_(
"Error loading symbol %s from library '%s'." ),
463 bufferedSymbol =
nullptr;
467 return bufferedSymbol;
472 const wxString& aLibrary )
475 wxString::Format(
"Library missing: %s, for symbol %s", aLibrary, aSymbolName ) );
476 wxCHECK_MSG( !aSymbolName.IsEmpty(),
nullptr,
477 wxString::Format(
"Symbol missing in library: %s", aLibrary ) );
478 auto it =
m_libs.find( aLibrary );
479 wxCHECK( it !=
m_libs.end(),
nullptr );
482 std::shared_ptr<SYMBOL_BUFFER> symbolBuf = buf.
GetBuffer( aSymbolName );
484 return symbolBuf ? symbolBuf->GetScreen() :
nullptr;
490 wxCHECK_MSG( aSymbol,
false, wxString::Format(
"Null symbol in library: %s", aLibrary ) );
492 wxString::Format(
"Library missing: %s, for symbol %s", aLibrary,
496 std::shared_ptr<SYMBOL_BUFFER> symbolBuf = libBuf.
GetBuffer( aSymbol->
GetName() );
500 LIB_SYMBOL& bufferedSymbol = symbolBuf->GetSymbol();
504 bufferedSymbol = *aSymbol;
507 symbolBuf->GetScreen()->SetContentModified();
511 auto symbolCopy = std::make_unique<LIB_SYMBOL>( *aSymbol,
nullptr );
515 auto newScreen = std::make_unique<SCH_SCREEN>();
517 libBuf.
CreateBuffer( std::move( symbolCopy ), std::move( newScreen ) );
526 const wxString& aLibrary )
529 std::shared_ptr<SYMBOL_BUFFER> symbolBuf = libBuf.
GetBuffer( aOldName );
531 wxCHECK( symbolBuf && aSymbol,
false );
542 auto it =
m_libs.find( aLibrary );
545 return LIB_ID( aLibrary, aSymbolName );
547 std::shared_ptr<SYMBOL_BUFFER> symbolBuf = it->second.GetBuffer( aSymbolName );
548 wxCHECK( symbolBuf,
LIB_ID( aLibrary, aSymbolName ) );
549 LIB_SYMBOL original( symbolBuf->GetOriginal() );
551 if( original.
GetName() != aSymbolName )
558 symbolBuf->GetSymbol() = original;
568 auto it =
m_libs.find( aLibrary );
588 for(
const auto& lib :
m_libs )
590 if( !lib.second.IsModified() )
593 for(
const std::shared_ptr<SYMBOL_BUFFER>& buffer : lib.second.GetBuffers() )
595 if( !buffer->IsModified() )
598 RevertSymbol( lib.first, buffer->GetOriginal().GetName() );
609 std::shared_ptr<SYMBOL_BUFFER> symbolBuf = libBuf.
GetBuffer( aSymbolName );
610 wxCHECK( symbolBuf,
false );
622 const wxString& aLibrary )
const
625 auto libIt =
m_libs.find( aLibrary );
627 if( libIt !=
m_libs.end() )
629 LIB_SYMBOL* symbol = libIt->second.GetSymbol( aSymbolName );
646 msg.Printf(
_(
"Cannot load symbol '%s' from library '%s'." ),
657 const wxString& aLibrary )
const
659 auto libBufIt =
m_libs.find( aLibrary );
662 if( libBufIt !=
m_libs.end() )
663 return libBufIt->second.GetBuffer( aSymbolName ) !=
nullptr;
674 return symbol !=
nullptr;
680 wxArrayString existing;
684 for( wxString& candidate : existing )
686 if( candidate.CmpNoCase( aName ) == 0 )
696 if( aLibrary.IsEmpty() )
699 if(
m_libs.count( aLibrary ) > 0 )
708 wxString
name =
"New_Library";
715 for(
unsigned int i = 0; i < std::numeric_limits<unsigned int>::max(); ++i )
718 return name + wxString::Format(
"%u", i );
722 return wxEmptyString;
727 wxArrayString& aSymbolNames,
737 const wxString& aLibraryName )
753 wxFileName fn( aFilePath );
770 if( schFileType == SCH_IO_MGR::SCH_FILE_UNKNOWN )
771 schFileType = SCH_IO_MGR::SCH_LEGACY;
779 wxCHECK( schFileType != SCH_IO_MGR::SCH_FILE_T::SCH_LEGACY,
false );
806 std::set<LIB_SYMBOL*> symbols;
811 wxArrayString symbolNames;
814 for(
const auto& symbolName : symbolNames )
817 symbols.insert( symbol );
824 msg.Printf(
_(
"Cannot enumerate library '%s'." ), aLibrary );
834 auto it =
m_libs.find( aLibrary );
845 if( symbol->IsDerived() )
847 std::shared_ptr<LIB_SYMBOL> oldParent = symbol->GetParent().lock();
849 wxCHECK_MSG( oldParent, buf,
850 wxString::Format(
"Derived symbol '%s' found with undefined parent.",
851 symbol->GetName() ) );
857 auto newParent = std::make_unique<LIB_SYMBOL>( *oldParent.get() );
858 libParent = newParent.get();
859 buf.
CreateBuffer( std::move( newParent ), std::make_unique<SCH_SCREEN>() );
862 auto newSymbol = std::make_unique<LIB_SYMBOL>( *symbol );
863 newSymbol->SetParent( libParent );
864 buf.
CreateBuffer( std::move( newSymbol ), std::make_unique<SCH_SCREEN>() );
866 else if( !buf.
GetSymbol( symbol->GetName() ) )
868 buf.
CreateBuffer( std::make_unique<LIB_SYMBOL>( *symbol ),
869 std::make_unique<SCH_SCREEN>() );
884 catch(
const std::exception& e)
886 wxLogError(
_(
"Error updating library buffer: %s" ), e.what() );
891 wxLogError(
_(
"Error updating library buffer: %s" ), e.What() );
896 wxLogError(
_(
"Error updating library buffer." ) );
907 std::unique_ptr<SCH_SCREEN> aScreen ) :
908 m_screen(
std::
move( aScreen ) ), m_symbol(
std::
move( aSymbol ) )
928 if(
m_original->GetLibId().GetLibNickname() !=
m_symbol->GetLibId().GetLibNickname() )
943 if(
m_original->GetLibId().GetLibNickname() !=
m_symbol->GetLibId().GetLibNickname() )
970 std::unique_ptr<SCH_SCREEN> aScreen )
973 wxASSERT( aCopy->GetLib() ==
nullptr );
977 LIB_ID libId = aCopy->GetLibId();
979 aCopy->SetLibId( libId );
981 auto symbolBuf = std::make_shared<SYMBOL_BUFFER>( std::move( aCopy ), std::move( aScreen ) );
994 bufferedSymbol = aCopy;
1003 const auto sameBufferPredicate = [&](
const std::shared_ptr<SYMBOL_BUFFER>& aBuf )
1005 return aBuf.get() == &aSymbolBuf;
1008 auto symbolBufIt = std::find_if(
m_symbols.begin(),
m_symbols.end(), sameBufferPredicate );
1009 wxCHECK( symbolBufIt !=
m_symbols.end(),
false );
1031 wxCHECK( !aFileName.IsEmpty(),
false );
1033 wxString errorMsg =
_(
"Error saving symbol %s to library '%s'." ) + wxS(
"\n%s" );
1036 std::map<std::string, UTF8> properties;
1043 const wxString originalName = originalSymbol.
GetName();
1050 if( aPlugin->
LoadSymbol( aFileName, originalName ) )
1051 aPlugin->
DeleteSymbol( aFileName, originalName, &properties );
1066 std::shared_ptr<LIB_SYMBOL> bufferedParent = libSymbol.
GetParent().lock();
1067 parentSymbol = newCachedSymbol;
1069 wxCHECK( bufferedParent,
false );
1075 cachedParent = aPlugin->
LoadSymbol( aFileName, bufferedParent->GetName() );
1084 cachedParent =
new LIB_SYMBOL( *bufferedParent.get() );
1085 newCachedSymbol->
SetParent( cachedParent );
1089 aPlugin->
SaveSymbol( aFileName, cachedParent, aBuffer ? &properties :
nullptr );
1100 aPlugin->
SaveSymbol( aFileName, newCachedSymbol, aBuffer ? &properties :
nullptr );
1109 auto originalParent = std::make_unique<LIB_SYMBOL>( *bufferedParent.get() );
1111 aSymbolBuf.
SetOriginal( std::move( originalParent ) );
1113 auto newSymbol = std::make_unique<LIB_SYMBOL>( libSymbol );
1114 newSymbol->SetParent( &parentRef );
1119 newCachedSymbol->
SetParent( cachedParent );
1123 aPlugin->
SaveSymbol( aFileName, newCachedSymbol, aBuffer ? &properties :
nullptr );
1132 auto originalBufferedParent =
GetBuffer( bufferedParent->GetName() );
1133 wxCHECK( originalBufferedParent,
false );
1135 auto newSymbol = std::make_unique<LIB_SYMBOL>( libSymbol );
1136 newSymbol->SetParent( &originalBufferedParent->GetSymbol() );
1146 aPlugin->
SaveSymbol( aFileName, parentSymbol, aBuffer ? &properties :
nullptr );
1154 aSymbolBuf.
SetOriginal( std::make_unique<LIB_SYMBOL>( libSymbol ) );
1157 wxArrayString derivedSymbols;
1163 for(
const wxString& entry : derivedSymbols )
1165 std::shared_ptr<SYMBOL_BUFFER> symbol =
GetBuffer( entry );
1167 wxCHECK2( symbol,
continue );
1170 derivedSymbol->
SetParent( parentSymbol );
1175 aBuffer ? &properties :
nullptr );
1193 for( std::shared_ptr<SYMBOL_BUFFER> entry :
m_symbols )
1195 if( entry->GetSymbol().GetName() == aSymbolName )
1199 return std::shared_ptr<SYMBOL_BUFFER>(
nullptr );
1205 for(
const std::shared_ptr<SYMBOL_BUFFER>& entry :
m_symbols )
1207 if( entry->GetSymbol().IsDerived() )
1212 wxCHECK( parent,
false );
1214 if( parent->GetName() == aParentName )
1225 for( std::shared_ptr<SYMBOL_BUFFER>& entry :
m_symbols )
1227 const LIB_SYMBOL& symbol = entry->GetSymbol();
1228 if( ( symbol.
IsDerived() && ( aFilter == SYMBOL_NAME_FILTER::ROOT_ONLY ) )
1229 || ( symbol.
IsRoot() && ( aFilter == SYMBOL_NAME_FILTER::DERIVED_ONLY ) ) )
1240 wxCHECK( !aSymbolName.IsEmpty(), 0 );
1242 for( std::shared_ptr<SYMBOL_BUFFER>& entry :
m_symbols )
1244 const LIB_SYMBOL& symbol = entry->GetSymbol();
1250 wxCHECK2( parent,
continue );
1252 if( parent->GetName() == aSymbolName )
1254 aList.Add( symbol.
GetName() );
1261 return aList.GetCount();
1268 wxArrayString derivedSymbolNames;
1269 std::deque<std::shared_ptr<SYMBOL_BUFFER>>::iterator it;
1273 for(
const wxString& symbolName : derivedSymbolNames )
1276 [symbolName]( std::shared_ptr<SYMBOL_BUFFER>& buf )
1278 return buf->GetSymbol().GetName() == symbolName;
1281 wxCHECK2( it !=
m_symbols.end(),
continue );
void SetContentModified(bool aModified=true)
void MessageSet(const wxString &message)
Add a message (in bold) to message list.
void AddHTML_Text(const wxString &message)
Add HTML text (without any change) to message list.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
virtual const wxString Problem() const
what was the problem?
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
Store a working copy of a library.
size_t GetDerivedSymbolNames(const wxString &aSymbolName, wxArrayString &aList)
Fetch all of the symbols derived from a aSymbolName into aList.
bool CreateBuffer(std::unique_ptr< LIB_SYMBOL > aCopy, std::unique_ptr< SCH_SCREEN > aScreen)
Create a new buffer to store a symbol. LIB_BUFFER takes ownership of aCopy.
bool DeleteBuffer(const SYMBOL_BUFFER &aSymbolBuf)
Delete the given symbol buffer from the library buffer.
void ClearDeletedBuffer()
void GetSymbolNames(wxArrayString &aSymbolNames, SYMBOL_NAME_FILTER aFilter=SYMBOL_NAME_FILTER::ALL)
Fetch a list of root symbols names from the library buffer.
std::deque< std::shared_ptr< SYMBOL_BUFFER > > m_symbols
std::deque< std::shared_ptr< SYMBOL_BUFFER > > m_deleted
Buffer for deleted symbols until library is saved.
bool SaveBuffer(SYMBOL_BUFFER &aSymbolBuf, const wxString &aFileName, SCH_IO *aPlugin, bool aBuffer)
Save stored modifications using a plugin.
const std::deque< std::shared_ptr< SYMBOL_BUFFER > > & GetBuffers() const
Return all buffered symbols.
std::shared_ptr< SYMBOL_BUFFER > GetBuffer(const wxString &aAlias) const
Return a symbol buffer with LIB_SYMBOL holding a symbolic alias.
LIB_SYMBOL * GetSymbol(const wxString &aAlias) const
Return the working copy of a LIB_SYMBOL root object with specified alias.
int removeChildSymbols(const SYMBOL_BUFFER &aSymbolBuf)
Remove all symbols derived from aParent from the library buffer.
bool HasDerivedSymbols(const wxString &aParentName) const
Check to see any symbols in the buffer are derived from a parent named aParentName.
bool UpdateBuffer(SYMBOL_BUFFER &aSymbolBuf, const LIB_SYMBOL &aCopy)
Update the buffered symbol with the contents of aCopy.
const wxString m_libName
Buffered library name.
A logical library item identifier and consists of various portions much like a URI.
int SetLibNickname(const UTF8 &aLibNickname)
Override the logical library name portion of the LIB_ID to aLibNickname.
const UTF8 & GetLibItemName() const
Define a library symbol object.
const LIB_ID & GetLibId() const override
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
void SetParent(LIB_SYMBOL *aParent=nullptr)
wxString GetName() const override
void SetLibId(const LIB_ID &aLibId)
LIB_SYMBOL_REF & GetParent()
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...
std::vector< wxString > GetLogicalLibs()
Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE.
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
bool InsertRow(LIB_TABLE_ROW *aRow, bool doReplace=false)
Adds aRow if it does not already exist or if doReplace is true.
bool RemoveRow(const LIB_TABLE_ROW *aRow)
Removes a row from the table and frees the pointer.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
A progress reporter interface for use in multi-threaded environments.
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
static SYMBOL_LIB_TABLE * SchSymbolLibTable(PROJECT *aProject)
Accessor for project symbol library table.
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
static const char * PropBuffering
The property used internally by the plugin to enable cache buffering which prevents the library file ...
static const wxString ShowType(SCH_FILE_T aFileType)
Return a brief name for a plugin, given aFileType enum.
static SCH_FILE_T GuessPluginTypeFromLibPath(const wxString &aLibPath, int aCtl=0)
Return a plugin type given a symbol library using the file extension of aLibPath.
Base class that schematic file and library loading and saving plugins should derive from.
virtual void SaveSymbol(const wxString &aLibraryPath, const LIB_SYMBOL *aSymbol, const std::map< std::string, UTF8 > *aProperties=nullptr)
Write aSymbol to an existing library located at aLibraryPath.
virtual void DeleteSymbol(const wxString &aLibraryPath, const wxString &aSymbolName, const std::map< std::string, UTF8 > *aProperties=nullptr)
Delete the entire LIB_SYMBOL associated with aAliasName from the library aLibraryPath.
virtual LIB_SYMBOL * LoadSymbol(const wxString &aLibraryPath, const wxString &aPartName, const std::map< std::string, UTF8 > *aProperties=nullptr)
Load a LIB_SYMBOL object having aPartName from the aLibraryPath containing a library format that this...
const wxString & GetErrors() const
void Start()
Spin up threads to load all the libraries in m_nicknames.
bool Join()
Finalize the threads and combines the output into the target output map.
std::unique_ptr< LIB_SYMBOL > m_symbol
std::unique_ptr< SCH_SCREEN > m_screen
void SetSymbol(std::unique_ptr< LIB_SYMBOL > aSymbol)
LIB_SYMBOL & GetSymbol() const
SYMBOL_BUFFER(std::unique_ptr< LIB_SYMBOL > aSymbol=nullptr, std::unique_ptr< SCH_SCREEN > aScreen=nullptr)
std::unique_ptr< LIB_SYMBOL > m_original
LIB_SYMBOL & GetOriginal() const
void SetOriginal(std::unique_ptr< LIB_SYMBOL > aSymbol)
bool IsLibraryReadOnly(const wxString &aLibrary) const
Return true if the library is stored in a read-only file.
bool LibraryExists(const wxString &aLibrary, bool aCheckEnabled=false) const
Return true if library exists.
size_t GetLibraryCount() const
bool ClearLibraryModified(const wxString &aLibrary) const
Clear the modified flag for all symbols in a library.
LIB_SYMBOL * GetBufferedSymbol(const wxString &aSymbolName, const wxString &aLibrary)
Return the symbol copy from the buffer.
bool ClearSymbolModified(const wxString &aSymbolName, const wxString &aLibrary) const
Clear the modified flag for a symbol.
SCH_SCREEN * GetScreen(const wxString &aSymbolName, const wxString &aLibrary)
Return the screen used to edit a specific symbol.
bool SymbolNameInUse(const wxString &aName, const wxString &aLibrary)
Return true if the symbol name is already in use in the specified library.
bool IsLibraryModified(const wxString &aLibrary) const
Return true if library has unsaved modifications.
LIB_SYMBOL * GetSymbol(const wxString &aSymbolName, const wxString &aLibrary) const
Return either an alias of a working LIB_SYMBOL copy, or alias of the original symbol if there is no w...
bool RemoveSymbol(const wxString &aSymbolName, const wxString &aLibrary)
Remove the symbol from the symbol buffer.
wxArrayString GetLibraryNames() const
Return the array of library names.
LIB_BUFFER & getLibraryBuffer(const wxString &aLibrary)
Return an existing library buffer or creates one to using symbol library table to get the original da...
wxString GetUniqueLibraryName() const
Return a library name that is not currently in use.
bool HasModifications() const
static wxString getLibraryName(const wxString &aFilePath)
Extract library name basing on the file name.
bool UpdateSymbolAfterRename(LIB_SYMBOL *aSymbol, const wxString &aOldSymbolName, const wxString &aLibrary)
Update the symbol buffer with a new version of the symbol when the name has changed.
bool IsSymbolModified(const wxString &aSymbolName, const wxString &aLibrary) const
Return true if symbol has unsaved modifications.
virtual void OnDataChanged() const
bool addLibrary(const wxString &aFilePath, bool aCreate, SYMBOL_LIB_TABLE &aTable)
Helper function to add either existing or create new library.
bool IsLibraryLoaded(const wxString &aLibrary) const
Return true if the library was successfully loaded.
void SetSymbolModified(const wxString &aSymbolName, const wxString &aLibrary)
SYMBOL_LIB_TABLE * symTable() const
Return the current symbol library table.
virtual ~SYMBOL_LIBRARY_MANAGER()
bool RevertLibrary(const wxString &aLibrary)
Revert unsaved changes for a symbol library.
LIB_ID RevertSymbol(const wxString &aSymbolName, const wxString &aLibrary)
Revert unsaved changes for a symbol.
void GetSymbolNames(const wxString &aLibName, wxArrayString &aSymbolNames, SYMBOL_NAME_FILTER aFilter=SYMBOL_NAME_FILTER::ALL)
std::set< LIB_SYMBOL * > getOriginalSymbols(const wxString &aLibrary)
Return a set of LIB_SYMBOL objects belonging to the original library.
int GetLibraryHash(const wxString &aLibrary) const
Return a library hash value to determine if it has changed.
void Preload(PROGRESS_REPORTER &aReporter)
Preload all symbol libraries in the symbol library table using SYMBOL_ASYNC_LOADER.
bool RevertAll()
Revert all pending changes.
SYMBOL_LIBRARY_MANAGER(SCH_BASE_FRAME &aFrame)
bool SymbolExists(const wxString &aSymbolName, const wxString &aLibrary) const
Return true if symbol with a specific alias exists in library (either original one or buffered).
SYMBOL_LIB_TABLE_ROW * GetLibrary(const wxString &aLibrary) const
Find a single library within the (aggregate) library table.
SCH_BASE_FRAME & m_frame
Parent frame.
std::list< LIB_SYMBOL * > EnumerateSymbols(const wxString &aLibrary) const
bool UpdateSymbol(LIB_SYMBOL *aSymbol, const wxString &aLibrary)
Update the symbol buffer with a new version of the symbol.
bool SaveLibrary(const wxString &aLibrary, const wxString &aFileName, SCH_IO_MGR::SCH_FILE_T aFileType=SCH_IO_MGR::SCH_FILE_T::SCH_LEGACY)
Save library to a file, including unsaved changes.
bool HasDerivedSymbols(const wxString &aSymbolName, const wxString &aLibraryName)
Check if symbol aSymbolName in library aLibraryName is a root symbol that has derived symbols.
std::map< wxString, LIB_BUFFER > m_libs
The library buffers.
bool UpdateLibraryBuffer(const wxString &aLibrary)
Update the library buffer with a new version of the library.
Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_IO object i...
void LoadSymbolLib(std::vector< LIB_SYMBOL * > &aAliasList, const wxString &aNickname, bool aPowerSymbolsOnly=false)
bool IsSymbolLibWritable(const wxString &aNickname)
Return true if the library given by aNickname is writable.
bool IsSymbolLibLoaded(const wxString &aNickname)
Return true if the library given by aNickname was successfully loaded.
void CreateSymbolLib(const wxString &aNickname)
void EnumerateSymbolLib(const wxString &aNickname, wxArrayString &aAliasNames, bool aPowerSymbolsOnly=false)
Return a list of symbol alias names contained within the library given by aNickname.
LIB_SYMBOL * LoadSymbol(const wxString &aNickname, const wxString &aName)
Load a LIB_SYMBOL having aName from the library given by aNickname.
SYMBOL_LIB_TABLE_ROW * FindRow(const wxString &aNickName, bool aCheckIfEnabled=false)
Return an SYMBOL_LIB_TABLE_ROW if aNickName is found in this table or in any chained fallBack table f...
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
wxString NormalizePath(const wxFileName &aFilePath, const ENV_VAR_MAP *aEnvVars, const wxString &aProjectPath)
Normalize a file path to an environmental variable, if possible.
Helper functions to substitute paths with environmental variables.
std::unique_ptr< T > IO_RELEASER
Helper to hold and release an IO_BASE object when exceptions are thrown.
#define THROW_IO_ERROR(msg)
#define KICTL_CREATE
caller thinks requested project files may not exist.
std::shared_ptr< LIB_SYMBOL > LIB_SYMBOL_SPTR
shared pointer to LIB_SYMBOL
PGM_BASE & Pgm()
The global program "get" accessor.
wxString UnescapeString(const wxString &aSource)
Definition for symbol library class.
#define FN_NORMALIZE_FLAGS
Default flags to pass to wxFileName::Normalize().