27 #ifndef SYMBOL_LIBRARY_MANAGER_H 28 #define SYMBOL_LIBRARY_MANAGER_H 35 #include <wx/arrstr.h> 67 wxLog::SetActiveTarget(
this );
86 wxLogMessage(
_(
"Not all symbol libraries could be loaded. Use the Manage Symbol\n" 87 "Libraries dialog to adjust paths and add or remove libraries." ) );
109 void Sync(
const wxString& aForceRefresh,
110 std::function<
void(
int,
int,
const wxString& )> aProgressCallback );
142 std::list<LIB_PART*>
GetAliases(
const wxString& aLibrary )
const;
157 return addLibrary( aFilePath,
false, aTable );
172 const wxString& aLibrary );
178 bool RemovePart(
const wxString& aName,
const wxString& aLibrary );
184 LIB_PART*
GetAlias(
const wxString& aAlias,
const wxString& aLibrary )
const;
202 bool PartExists(
const wxString& aAlias,
const wxString& aLibrary )
const;
208 bool LibraryExists(
const wxString& aLibrary,
bool aCheckEnabled =
false )
const;
223 bool IsPartModified(
const wxString& aAlias,
const wxString& aLibrary )
const;
233 bool ClearPartModified(
const wxString& aAlias,
const wxString& aLibrary )
const;
248 bool FlushPart(
const wxString& aAlias,
const wxString& aLibrary );
257 bool SaveLibrary(
const wxString& aLibrary,
const wxString& aFileName,
258 SCH_IO_MGR::SCH_FILE_T aFileType = SCH_IO_MGR::SCH_FILE_T::SCH_LEGACY );
301 bool HasDerivedSymbols(
const wxString& aSymbolName,
const wxString& aLibraryName );
317 return static_cast<SYMBOL_TREE_SYNCHRONIZING_ADAPTER*>(
m_adapter.get() );
349 typedef std::shared_ptr<PART_BUFFER>
PTR;
374 for(
const auto& partBuf :
m_parts )
376 if( partBuf->IsModified() )
LIB_PART * GetOriginal() const
bool ClearPartModified(const wxString &aAlias, const wxString &aLibrary) const
Clear the modified flag for a part.
bool UpdatePartAfterRename(LIB_PART *aPart, const wxString &oldAlias, const wxString &aLibrary)
Update the part buffer with a new version of the part when the name has changed.
Hold a record identifying a symbol library accessed by the appropriate symbol library SCH_PLUGIN obje...
LIB_PART * GetAlias(const wxString &aAlias, const wxString &aLibrary) const
Return either an alias of a working LIB_PART copy, or alias of the original part if there is no worki...
void GetRootSymbolNames(const wxString &aLibName, wxArrayString &aRootSymbolNames)
bool RemovePart(const wxString &aName, const wxString &aLibrary)
Remove the part from the part buffer.
SCH_SCREEN * GetScreen() const
Transfer the screen ownership.
bool ClearLibraryModified(const wxString &aLibrary) const
Clear the modified flag for all parts in a library.
bool AddLibrary(const wxString &aFilePath, SYMBOL_LIB_TABLE *aTable)
Add an existing library.
A progress reporter for use in multi-threaded environments.
bool PartExists(const wxString &aAlias, const wxString &aLibrary) const
Return true if part with a specific alias exists in library (either original one or buffered).
SYMBOL_LIBRARY_MANAGER(SYMBOL_EDIT_FRAME &aFrame)
std::unique_ptr< SCH_SCREEN > m_screen
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 CreateBuffer(LIB_PART *aCopy, SCH_SCREEN *aScreen)
Update the buffered part with the contents of aCopy.
static wxString getLibraryName(const wxString &aFilePath)
< Extract library name basing on the file name.
SYMBOL_LIB_TABLE * symTable() const
int GetHash() const
Return the working copy of a LIB_PART root object with specified alias.
PART_BUFFER(LIB_PART *aPart=nullptr, std::unique_ptr< SCH_SCREEN > aScreen=nullptr)
A logical library item identifier and consists of various portions much like a URI.
std::deque< PART_BUFFER::PTR > m_parts
SYMBOL_EDIT_FRAME & m_frame
Parent frame.
std::weak_ptr< PART_BUFFER > WEAK_PTR
bool HasModifications() const
bool UpdatePart(LIB_PART *aPart, const wxString &aLibrary)
Update the part buffer with a new version of the part.
bool RevertLibrary(const wxString &aLibrary)
Revert unsaved changes for a particular library.
LIB_BUFFER & getLibraryBuffer(const wxString &aLibrary)
Return an existing library buffer or creates one to using Symbol Library Table to get the original da...
LIB_PART * GetPart(const wxString &aAlias) const
Create a new buffer to store a part. LIB_BUFFER takes ownership of aCopy.
std::deque< PART_BUFFER::PTR > m_deleted
bool addLibrary(const wxString &aFilePath, bool aCreate, SYMBOL_LIB_TABLE *aTable)
Return the current Symbol Library Table.
std::unique_ptr< SCH_SCREEN > RemoveScreen()
bool FlushPart(const wxString &aAlias, const wxString &aLibrary)
Save part changes to the library copy used by the schematic editor.
LIB_PART * GetBufferedPart(const wxString &aAlias, const wxString &aLibrary)
Return the part copy from the buffer.
Store a working copy of a library.
Base class that schematic file and library loading and saving plugins should derive from.
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > m_adapter
bool UpdateBuffer(PART_BUFFER::PTR aPartBuf, LIB_PART *aCopy)
bool RevertAll()
Revert all pending changes.
wxString GetUniqueLibraryName() const
Return a library name that is not currently in use.
SYMBOL_LIB_TABLE_ROW * GetLibrary(const wxString &aLibrary) const
Find a single library within the (aggregate) library table.
int GetLibraryHash(const wxString &aLibrary) const
Return a library hash value to determine if it has changed.
Class to handle modifications to the symbol libraries.
void ClearDeletedBuffer()
Save stored modifications to Symbol Lib Table.
bool IsLibraryReadOnly(const wxString &aLibrary) const
Return true if the library is stored in a read-only file.
Define a library symbol object.
std::map< wxString, LIB_BUFFER > m_libs
size_t GetLibraryCount() const
bool DeleteBuffer(PART_BUFFER::PTR aPartBuf)
SYMBOL_TREE_SYNCHRONIZING_ADAPTER * getAdapter()
Class to store a working copy of a LIB_PART object and editor context.
bool HasDerivedSymbols(const wxString &aSymbolName, const wxString &aLibraryName)
Check if symbol aSymbolName in library aLibraryName is a root symbol that has derived symbols.
void Sync(const wxString &aForceRefresh, std::function< void(int, int, const wxString &)> aProgressCallback)
Updates the SYMBOL_LIBRARY_MANAGER data to synchronize with Symbol Library Table.
void Preload(PROGRESS_REPORTER &aReporter)
Preloads all symbol libraries in the symbol library table using SYMBOL_ASYNC_LOADER.
const std::deque< PART_BUFFER::PTR > & GetBuffers() const
void GetRootSymbolNames(wxArrayString &aRootSymbolNames)
Fetch a list of root symbols names from the library buffer.
int removeChildSymbols(PART_BUFFER::PTR aPartBuf)
Remove all symbols derived from aParent from the library buffer.
void SetPart(LIB_PART *aPart)
wxArrayString GetLibraryNames() const
Return the array of library names.
std::set< LIB_PART * > getOriginalParts(const wxString &aLibrary)
Return a set of LIB_PART objects belonging to the original library.
LIB_ID RevertPart(const wxString &aAlias, const wxString &aLibrary)
Revert unsaved changes for a particular part.
bool IsLibraryModified(const wxString &aLibrary) const
Return true if library has unsaved modifications.
LIB_BUFFER(const wxString &aLibrary)
bool LibraryExists(const wxString &aLibrary, bool aCheckEnabled=false) const
Return true if library exists.
void SetOriginal(LIB_PART *aPart)
wxObjectDataPtr< LIB_TREE_MODEL_ADAPTER > & GetAdapter()
Return the adapter object that provides the stored data.
bool IsLibraryLoaded(const wxString &aLibrary) const
Return true if the library was successfully loaded.
size_t GetDerivedSymbolNames(const wxString &aSymbolName, wxArrayString &aList)
Fetch all of the symbols derived from a aSymbolName into aList.
int m_syncHash
Symbol lib table hash value from last synchronization.
PART_BUFFER::PTR GetBuffer(const wxString &aAlias) const
Return all buffered parts.
SCH_SCREEN * GetScreen(const wxString &aAlias, const wxString &aLibrary)
Return the screen used to edit a specific part.
bool CreateLibrary(const wxString &aFilePath, SYMBOL_LIB_TABLE *aTable)
Create an empty library and adds it to the library table.
bool SetScreen(std::unique_ptr< SCH_SCREEN > aScreen)
std::list< LIB_PART * > GetAliases(const wxString &aLibrary) const
bool SaveBuffer(PART_BUFFER::PTR aPartBuf, SYMBOL_LIB_TABLE *aLibTable)
Save stored modifications using a plugin.
bool HasDerivedSymbols(const wxString &aParentName) const
Check to see any parts in the buffer are derived from a parent named aParentName.
Object used to load, save, search, and otherwise manipulate symbol library files.
std::shared_ptr< PART_BUFFER > PTR
The symbol library editor main window.
LIB_PART * GetPart() const
bool IsPartModified(const wxString &aAlias, const wxString &aLibrary) const
Return true if part has unsaved modifications.