26#ifndef _LIB_TABLE_BASE_H_ 
   27#define _LIB_TABLE_BASE_H_ 
   30#include <boost/ptr_container/ptr_vector.hpp> 
   33#include <shared_mutex> 
   78    virtual std::unique_ptr<LINE_READER> 
GetReader( 
const wxString& aURI ) 
const = 0;
 
   96    virtual std::unique_ptr<OUTPUTFORMATTER> 
GetWriter( 
const wxString& aURI ) 
const = 0;
 
 
  110    std::unique_ptr<LINE_READER> 
GetReader( 
const wxString& aURI ) 
const override;
 
  112    bool CanSaveToUri( 
const wxString& aURI ) 
const override;
 
  114    bool UrisAreEquivalent( 
const wxString& aURI1, 
const wxString& aURI2 ) 
const override;
 
  116    std::unique_ptr<OUTPUTFORMATTER> 
GetWriter( 
const wxString& aURI ) 
const override;
 
 
  139    LIB_TABLE_ROW( 
const wxString& aNick, 
const wxString& aURI, 
const wxString& aOptions,
 
  140                   const wxString& aDescr = wxEmptyString, 
LIB_TABLE* aParent = 
nullptr ) :
 
 
  203    virtual void SetType( 
const wxString& aType ) = 0;
 
  215    const wxString GetFullURI( 
bool aSubstituted = 
false ) 
const;
 
  220    void SetFullURI( 
const wxString& aFullURI );
 
  231    void SetOptions( 
const wxString& aOptions );
 
  289    void setProperties( 
const std::map<std::string, UTF8>& aProperties );
 
 
  368    virtual void Parse( LIB_TABLE_LEXER* aLexer ) = 0;
 
  393               std::unique_ptr<LIB_TABLE_IO> aTableIo = 
nullptr );
 
  455    bool IsEmpty( 
bool aIncludeFallback = 
true );
 
  461    const wxString GetDescription( 
const wxString& aNickname );
 
  469    bool HasLibrary( 
const wxString& aNickname, 
bool aCheckEnabled = 
false ) 
const;
 
  477    bool HasLibraryWithPath( 
const wxString& aPath ) 
const;
 
  483    std::vector<wxString> GetLogicalLibs();
 
  488    wxString GetFullURI( 
const wxString& aLibNickname, 
bool aExpandEnvVars = 
true ) 
const;
 
  502    bool InsertRow( 
LIB_TABLE_ROW* aRow, 
bool doReplace = 
false );
 
  523    bool ChangeRowOrder( 
size_t aIndex, 
int aOffset );
 
  544    void Load( 
const wxString& aFileName );
 
  551    void Save( 
const wxString& aFileName ) 
const;
 
  565    static std::map<std::string, UTF8> ParseOptions( 
const std::string& aOptionsList );
 
  577    static UTF8 FormatOptions( 
const std::map<std::string, UTF8>* aProperties );
 
  603    LIB_TABLE_ROW* findRow( 
const wxString& aNickname, 
bool aCheckIfEnabled = 
false ) 
const;
 
  608    bool doInsertRow( 
LIB_TABLE_ROW* aRow, 
bool doReplace = 
false );
 
  625    std::unique_ptr<LIB_TABLE_IO> 
m_io;
 
 
KICAD_PLUGIN_EXPORT SCENEGRAPH * Load(char const *aFileName)
Read a model file and creates a generic display structure.
 
bool operator==(const wxAuiPaneInfo &aLhs, const wxAuiPaneInfo &aRhs)
 
bool CanSaveToUri(const wxString &aURI) const override
Check if the given URI is writable.
 
bool UrisAreEquivalent(const wxString &aURI1, const wxString &aURI2) const override
Compare two URIs for equivalence.
 
FILE_LIB_TABLE_IO()=default
 
std::unique_ptr< LINE_READER > GetReader(const wxString &aURI) const override
Create a reader for the given URI.
 
std::unique_ptr< OUTPUTFORMATTER > GetWriter(const wxString &aURI) const override
Save the given table to the given URI.
 
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
 
A logical library item identifier and consists of various portions much like a URI.
 
This abstract base class mixes any object derived from LIB_TABLE into wxGridTableBase so the result c...
 
LIB_TABLE_IO abstracts the file I/O operations for the library table loading and saving.
 
virtual std::unique_ptr< OUTPUTFORMATTER > GetWriter(const wxString &aURI) const =0
Save the given table to the given URI.
 
virtual ~LIB_TABLE_IO()=default
 
virtual std::unique_ptr< LINE_READER > GetReader(const wxString &aURI) const =0
Create a reader for the given URI.
 
virtual bool CanSaveToUri(const wxString &aURI) const =0
Check if the given URI is writable.
 
virtual bool UrisAreEquivalent(const wxString &aURI1, const wxString &aURI2) const =0
Compare two URIs for equivalence.
 
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
 
void SetFullURI(const wxString &aFullURI)
Change the full URI for the library.
 
bool visible
Whether the LIB_TABLE_ROW is visible in choosers.
 
const wxString & GetOptions() const
Return the options string, which may hold a password or anything else needed to instantiate the under...
 
const wxString & GetDescr() const
Return the description of the library referenced by this row.
 
virtual LIB_TABLE_ROW * do_clone() const =0
 
void SetVisible(bool aVisible=true)
 
void operator=(const LIB_TABLE_ROW &aRow)
 
void SetNickName(const wxString &aNickName)
Change the logical name of this library, useful for an editor.
 
void setProperties(const std::map< std::string, UTF8 > &aProperties)
 
wxString uri_user
what user entered from UI or loaded from disk
 
LIB_TABLE * GetParent() const
 
bool operator!=(const LIB_TABLE_ROW &r) const
 
virtual const wxString GetType() const =0
Return the type of library represented by this row.
 
void SetEnabled(bool aEnabled=true)
Change the enabled status of this library.
 
void SetDescr(const wxString &aDescr)
Change the description of the library referenced by this row.
 
virtual void ShowSettingsDialog(wxWindow *aParent) const
 
bool enabled
Whether the LIB_TABLE_ROW is enabled.
 
void SetParent(LIB_TABLE *aParent)
 
const std::map< std::string, UTF8 > & GetProperties() const
Return the constant #PROPERTIES for this library (LIB_TABLE_ROW).
 
bool m_loaded
Whether the LIB_TABLE_ROW is loaded.
 
virtual bool LibraryExists() const =0
 
LIB_TABLE_ROW(const LIB_TABLE_ROW &aRow)
 
void SetLoaded(bool aLoaded)
Mark the row as being a loaded library.
 
LIB_TABLE * m_parent
Pointer to the table this row lives in (maybe null)
 
virtual void SetType(const wxString &aType)=0
Change the type of library represented by this row that must be implemented in the derived object to ...
 
const wxString & GetNickName() const
 
std::map< std::string, UTF8 > properties
 
LIB_TABLE_ROW(const wxString &aNick, const wxString &aURI, const wxString &aOptions, const wxString &aDescr=wxEmptyString, LIB_TABLE *aParent=nullptr)
 
LIB_TABLE_ROW * clone() const
 
bool GetIsEnabled() const
 
void SetOptions(const wxString &aOptions)
Change the library options strings.
 
virtual bool SupportsSettingsDialog() const
 
bool GetIsVisible() const
 
Manage LIB_TABLE_ROW records (rows), and can be searched based on library nickname.
 
std::shared_mutex m_mutex
Mutex to protect access to the rows vector.
 
std::map< wxString, LIB_TABLE_ROWS_ITER > m_rowsMap
this is a non-owning index into the LIB_TABLE_ROWS table
 
int m_version
Versioning to handle importing old tables.
 
LIB_TABLE_ROW & At(unsigned aIndex)
Get the 'n'th LIB_TABLE_ROW object.
 
bool operator==(const LIB_TABLE &r) const
Compares this table against another.
 
LIB_TABLE_ROWS m_rows
Owning set of rows.
 
virtual void Format(OUTPUTFORMATTER *aOutput, int aIndentLevel) const =0
Generate the table in s-expression format to aOutput with an indentation level of aIndentLevel.
 
LIB_TABLE(LIB_TABLE *aFallBackTable=nullptr, std::unique_ptr< LIB_TABLE_IO > aTableIo=nullptr)
Build a library table by pre-pending this table fragment in front of aFallBackTable.
 
unsigned GetCount() const
Get the number of rows contained in the table.
 
virtual void Parse(LIB_TABLE_LEXER *aLexer)=0
Parse the #LIB_TABLE_LEXER s-expression library table format into the appropriate LIB_TABLE_ROW objec...
 
std::unique_ptr< LIB_TABLE_IO > m_io
 
bool operator!=(const LIB_TABLE &r) const
 
const LIB_TABLE_ROW & At(unsigned aIndex) const
Get the 'n'th LIB_TABLE_ROW object.
 
int GetVersion() const
Returns the version number (0 if unset)
 
A PROJECT can hold stuff it knows nothing about, in the form of _ELEM derivatives.
 
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
 
boost::ptr_vector< LIB_TABLE_ROW > LIB_TABLE_ROWS
 
LIB_TABLE_ROWS::iterator LIB_TABLE_ROWS_ITER
 
LIB_TABLE_ROWS::const_iterator LIB_TABLE_ROWS_CITER
 
KICOMMON_API LIB_TABLE_ROW * new_clone(const LIB_TABLE_ROW &aRow)
Allows boost pointer containers to make clones of the data stored in them.
 
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.