2009-09-25 18:49:04 +00:00
|
|
|
/*********************************************/
|
|
|
|
/* Headers for component library definition */
|
|
|
|
/*********************************************/
|
2008-09-13 18:59:57 +00:00
|
|
|
|
|
|
|
#ifndef CLASS_LIBRARY_H
|
|
|
|
#define CLASS_LIBRARY_H
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2008-12-31 09:27:19 +00:00
|
|
|
#include "class_libentry.h"
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2009-09-25 18:49:04 +00:00
|
|
|
/*
|
|
|
|
* Component Library version and file header macros.
|
|
|
|
*/
|
|
|
|
#define LIB_VERSION_MAJOR 2
|
|
|
|
#define LIB_VERSION_MINOR 3
|
|
|
|
|
|
|
|
/* Must be the first line of component library (.lib) files. */
|
|
|
|
#define LIBFILE_IDENT "EESchema-LIBRARY Version"
|
|
|
|
|
|
|
|
#define LIB_VERSION( major, minor ) ( major * 100 + minor )
|
|
|
|
|
|
|
|
#define IS_LIB_CURRENT_VERSION( major, minor ) \
|
|
|
|
( \
|
|
|
|
LIB_VERSION( major1, minor1 ) == \
|
|
|
|
LIB_VERSION( LIB_VERSION_MAJOR, LIB_VERSION_MINOR) \
|
|
|
|
)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Library versions 2.3 and lower use the old separate library (.lib) and
|
|
|
|
* document (.dcm) files. Component libraries after 2.3 merged the library
|
|
|
|
* and document files into a single library file. This macro checks if the
|
|
|
|
* library version supports the old format
|
|
|
|
*/
|
|
|
|
#define USE_OLD_DOC_FILE_FORMAT( major, minor ) \
|
|
|
|
( LIB_VERSION( major, minor ) <= LIB_VERSION( 2, 3 ) )
|
|
|
|
|
|
|
|
/* Must be the first line of component library document (.dcm) files. */
|
|
|
|
#define DOCFILE_IDENT "EESchema-DOCLIB Version 2.0"
|
|
|
|
|
|
|
|
#define DOC_EXT wxT( "dcm" )
|
|
|
|
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
/* Helpers for creating a list of component libraries. */
|
|
|
|
class CMP_LIBRARY;
|
2009-10-08 13:19:28 +00:00
|
|
|
class wxRegEx;
|
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
|
|
|
|
typedef boost::ptr_vector< CMP_LIBRARY > CMP_LIBRARY_LIST;
|
|
|
|
|
|
|
|
extern bool operator<( const CMP_LIBRARY& item1, const CMP_LIBRARY& item2 );
|
|
|
|
|
|
|
|
|
2009-09-02 18:12:45 +00:00
|
|
|
/**
|
|
|
|
* Component library object.
|
|
|
|
*
|
|
|
|
* Component libraries are used to load, save, search, and otherwise manipulate
|
|
|
|
* component library files.
|
|
|
|
*/
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
class CMP_LIBRARY
|
2008-09-13 18:59:57 +00:00
|
|
|
{
|
|
|
|
public:
|
2009-09-18 14:56:05 +00:00
|
|
|
int m_Type; /* type indicator */
|
2009-12-15 21:11:05 +00:00
|
|
|
int m_Flags;
|
2008-09-13 18:59:57 +00:00
|
|
|
|
2009-12-22 20:08:56 +00:00
|
|
|
protected:
|
|
|
|
wxFileName fileName; /* Library file name. */
|
|
|
|
wxDateTime timeStamp; /* Library save time and date. */
|
|
|
|
int versionMajor; /* Library major version number. */
|
|
|
|
int versionMinor; /* Library minor version number. */
|
|
|
|
LIB_ENTRY_LIST entries; /* Parts themselves are saved here. */
|
|
|
|
bool isCache; /* False for the "standard" libraries,
|
|
|
|
* True for the library cache */
|
|
|
|
wxString header; /* first line of loaded library. */
|
|
|
|
|
|
|
|
static CMP_LIBRARY_LIST libraryList;
|
|
|
|
static wxArrayString libraryListSortOrder;
|
|
|
|
|
|
|
|
friend class CMP_LIB_ENTRY;
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool isModified; /* Library modification status. */
|
|
|
|
|
2008-09-13 18:59:57 +00:00
|
|
|
public:
|
2009-12-15 21:11:05 +00:00
|
|
|
CMP_LIBRARY( int aType, const wxFileName& aFileName );
|
|
|
|
CMP_LIBRARY( int aType, const wxString& aFileName )
|
2009-09-18 14:56:05 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
CMP_LIBRARY( aType, wxFileName( aFileName ) );
|
2009-09-18 14:56:05 +00:00
|
|
|
}
|
|
|
|
~CMP_LIBRARY();
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-12-22 20:08:56 +00:00
|
|
|
/** Modify flags handling:
|
|
|
|
*/
|
|
|
|
void SetModifyFlags( ) { isModified = true; }
|
|
|
|
void ClearModifyFlag( ) { isModified = false; }
|
|
|
|
bool getModifyFlag( ) { return isModified;}
|
|
|
|
|
2008-09-18 17:10:54 +00:00
|
|
|
/**
|
2009-08-27 11:41:56 +00:00
|
|
|
* Save library to file.
|
|
|
|
*
|
2009-09-25 18:49:04 +00:00
|
|
|
* Prior to component library version 3.0, two files were created. The
|
|
|
|
* component objects are wer as component library (*.lib) files. The
|
|
|
|
* library entry ojbect document strings were save in library document
|
|
|
|
* definition (*.dcm) files. After version component library version 3.0,
|
|
|
|
* the document string information is saved as part of the library file.
|
|
|
|
* Saving separate document is maintained for backwards compatability.
|
|
|
|
* Please note that this behavior may change in the future. If the
|
|
|
|
* component library already exists, it is backup up in file *.bak.
|
|
|
|
*
|
|
|
|
* @param aFullFileName - The library filename with path.
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aOldDocFormat - Save the document information in a separate
|
|
|
|
* file if true. The default is to save as the
|
|
|
|
* current library file format.
|
2009-11-03 13:26:31 +00:00
|
|
|
* @return True if success writing else false.
|
2009-09-25 18:49:04 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
bool Save( const wxString& aFullFileName, bool aOldDocFormat = false );
|
2009-09-25 18:49:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Save library document information to file.
|
|
|
|
*
|
|
|
|
* If the document definition file* already exists, it is backed up in
|
|
|
|
* file *.bck.
|
2009-08-27 11:41:56 +00:00
|
|
|
*
|
|
|
|
* @param aFullFileName - The library filename with path.
|
2009-11-03 13:26:31 +00:00
|
|
|
* @return True if success writing else false.
|
2008-09-18 17:10:54 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
bool SaveDocFile( const wxString& aFullFileName );
|
2008-09-18 17:10:54 +00:00
|
|
|
|
2009-09-02 18:12:45 +00:00
|
|
|
/**
|
|
|
|
* Load library from file.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aErrorMsg - Error message if load fails.
|
2009-11-03 13:26:31 +00:00
|
|
|
* @return True if load was successful otherwise false.
|
2009-09-02 18:12:45 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
bool Load( wxString& aErrorMsg );
|
2009-09-02 18:12:45 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
bool LoadDocs( wxString& aErrorMsg );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2008-09-18 17:10:54 +00:00
|
|
|
private:
|
2009-12-15 21:11:05 +00:00
|
|
|
bool SaveHeader( FILE* aFile );
|
2009-09-02 18:12:45 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
bool LoadHeader( FILE* aFile, int* aLineNum );
|
|
|
|
void LoadAliases( LIB_COMPONENT* aComponent );
|
2009-09-02 18:12:45 +00:00
|
|
|
|
2010-02-13 13:16:09 +00:00
|
|
|
/** function RemoveEntryName
|
|
|
|
* Remove an /a aName entry from the library list names.
|
|
|
|
* Warning: this is a partiel remove, because if aname is an alias
|
|
|
|
* it is not removed from its root component.
|
|
|
|
* this is for internal use only
|
|
|
|
* Use RemoveEntry( CMP_LIB_ENTRY* aEntry ) to remove safely an entry.
|
|
|
|
* @param aName - Entry name to remove from library.
|
|
|
|
*/
|
|
|
|
void RemoveEntryName( const wxString& aName );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
public:
|
2009-08-27 11:41:56 +00:00
|
|
|
/**
|
|
|
|
* Get library entry status.
|
|
|
|
*
|
2009-11-03 13:26:31 +00:00
|
|
|
* @return True if there are no entries in the library.
|
2009-08-27 11:41:56 +00:00
|
|
|
*/
|
2009-09-18 14:56:05 +00:00
|
|
|
bool IsEmpty() const
|
2009-08-27 11:41:56 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
return entries.empty();
|
2009-09-02 18:12:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the number of entries in the library.
|
|
|
|
*
|
|
|
|
* @return The number of component and alias entries.
|
|
|
|
*/
|
2009-09-18 14:56:05 +00:00
|
|
|
int GetCount() const
|
2009-09-02 18:12:45 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
return entries.size();
|
2009-09-02 18:12:45 +00:00
|
|
|
}
|
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
bool IsModified() const
|
2009-09-02 18:12:45 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
return isModified;
|
2009-08-27 11:41:56 +00:00
|
|
|
}
|
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
bool IsCache() const { return isCache; }
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
void SetModified( void ) { isModified = true; }
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
void SetCache( void ) { isCache = true; }
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2009-12-22 20:08:56 +00:00
|
|
|
/**
|
2009-08-27 11:41:56 +00:00
|
|
|
* Load a string array with the names of all the entries in this library.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aNames - String array to place entry names into.
|
|
|
|
* @param aSort - Sort names if true.
|
|
|
|
* @param aMakeUpperCase - Force entry names to upper case.
|
2009-08-27 11:41:56 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void GetEntryNames( wxArrayString& aNames, bool aSort = true,
|
|
|
|
bool aMakeUpperCase = true );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Load string array with entry names matching name and/or key word.
|
|
|
|
*
|
|
|
|
* This currently mimics the old behavior of calling KeyWordOk() and
|
|
|
|
* WildCompareString(). The names array will be populated with the
|
|
|
|
* library entry names that meat the search criteria on exit.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aNames - String array to place entry names into.
|
|
|
|
* @param aNameSearch - Name wild card search criteria.
|
|
|
|
* @param aKeySearch - Key word search criteria.
|
|
|
|
* @param aSort - Sort names if true.
|
2009-08-27 11:41:56 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void SearchEntryNames( wxArrayString& aNames,
|
|
|
|
const wxString& aNameSearch = wxEmptyString,
|
|
|
|
const wxString& aKeySearch = wxEmptyString,
|
|
|
|
bool aSort = true );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2009-10-08 13:19:28 +00:00
|
|
|
/**
|
|
|
|
* Find components in library by key word regular expression search.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aNames - String array to place found component names into.
|
|
|
|
* @param aRe - Regular expression used to seach component key words.
|
|
|
|
* @param aSort - Sort component name list.
|
2009-10-08 13:19:28 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void SearchEntryNames( wxArrayString& aNames, const wxRegEx& aRe,
|
|
|
|
bool aSort = true );
|
2009-10-08 13:19:28 +00:00
|
|
|
|
2009-08-27 11:41:56 +00:00
|
|
|
/**
|
|
|
|
* Find entry by name.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aName - Name of entry, case insensitive.
|
|
|
|
* @return Entry if found. NULL if not found.
|
2009-08-27 11:41:56 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
CMP_LIB_ENTRY* FindEntry( const wxChar* aName );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
|
|
|
/**
|
2009-12-15 21:11:05 +00:00
|
|
|
* Find entry by /a aName and /a aType.
|
2009-08-27 11:41:56 +00:00
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aName - Name of entry, case insensitive.
|
|
|
|
* @param aType - Type of entry, root or alias.
|
|
|
|
* @return Entry if found. NULL if not found.
|
2009-08-27 11:41:56 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
CMP_LIB_ENTRY* FindEntry( const wxChar* aName, LibrEntryType aType );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
/**
|
2009-12-15 21:11:05 +00:00
|
|
|
* Find component by /a aName.
|
2009-09-14 13:24:17 +00:00
|
|
|
*
|
2009-09-18 14:56:05 +00:00
|
|
|
* This is a helper for FindEntry so casting a CMP_LIB_ENTRY pointer to
|
|
|
|
* a LIB_COMPONENT pointer is not required.
|
2009-09-14 13:24:17 +00:00
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aName - Name of component, case insensitive.
|
|
|
|
* @return Component if found. NULL if not found.
|
2009-09-14 13:24:17 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
LIB_COMPONENT* FindComponent( const wxChar* aName );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
|
|
|
/**
|
2009-12-15 21:11:05 +00:00
|
|
|
* Find alias by /a nName.
|
2009-09-14 13:24:17 +00:00
|
|
|
*
|
2009-09-18 14:56:05 +00:00
|
|
|
* This is a helper for FindEntry so casting a CMP_LIB_ENTRY pointer to
|
|
|
|
* a LIB_ALIAS pointer is not required.
|
2009-09-14 13:24:17 +00:00
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aName - Name of alias, case insensitive.
|
|
|
|
* @return Alias if found. NULL if not found.
|
2009-09-14 13:24:17 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
LIB_ALIAS* FindAlias( const wxChar* aName )
|
2009-09-14 13:24:17 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
return (LIB_ALIAS*) FindEntry( aName, ALIAS );
|
2009-09-14 13:24:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-12-15 21:11:05 +00:00
|
|
|
* Add a new /a aAlias entry to the library.
|
2009-09-14 13:24:17 +00:00
|
|
|
*
|
|
|
|
* First check if a component or alias with the same name already exists
|
|
|
|
* in the library and add alias if no conflict occurs. Once the alias
|
|
|
|
* is added to the library it is owned by the library. Deleting the
|
|
|
|
* alias pointer will render the library unstable. Use RemoveEntry to
|
|
|
|
* remove the alias from the library.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aAlias - Alias to add to library.
|
|
|
|
* @return True if alias added to library. False if a conflict exists.
|
2009-09-14 13:24:17 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
bool AddAlias( LIB_ALIAS* aAlias );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2009-08-27 11:41:56 +00:00
|
|
|
/**
|
2009-12-15 21:11:05 +00:00
|
|
|
* Add /a aComponent entry to library.
|
2010-02-13 13:16:09 +00:00
|
|
|
* Note a component can have an alias list,
|
|
|
|
* so these alias will be added in library.
|
|
|
|
* Conflicts can happen if aliases are already existing.
|
|
|
|
* User is asked to choose what alias is removed (existing, or new)
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aComponent - Component to add.
|
|
|
|
* @return Added component if successful.
|
2009-08-27 11:41:56 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
LIB_COMPONENT* AddComponent( LIB_COMPONENT* aComponent );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
|
|
|
/**
|
2010-02-13 13:16:09 +00:00
|
|
|
* Remove safely an /a aEntry from the library.
|
2009-08-27 11:41:56 +00:00
|
|
|
*
|
|
|
|
* If the entry is an alias, the alias is removed from the library and from
|
|
|
|
* the alias list of the root component. If the entry is a root component
|
|
|
|
* with no aliases, it is removed from the library. If the entry is a root
|
|
|
|
* component with aliases, the root component is renamed to the name of
|
|
|
|
* the first alias and the root name for all remaining aliases are updated
|
|
|
|
* to reflect the new root name.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aEntry - Entry to remove from library.
|
2009-08-27 11:41:56 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void RemoveEntry( CMP_LIB_ENTRY* aEntry );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2009-09-14 13:24:17 +00:00
|
|
|
/**
|
|
|
|
* Replace an existing component entry in the library.
|
2010-02-13 13:16:09 +00:00
|
|
|
* Note a component can have an alias list,
|
|
|
|
* so these alias will be added in library (and previously existing alias removed)
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aOldComponent - The component to replace.
|
|
|
|
* @param aNewComponent - The new component.
|
2009-09-14 13:24:17 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
LIB_COMPONENT* ReplaceComponent( LIB_COMPONENT* aOldComponent,
|
|
|
|
LIB_COMPONENT* aNewComponent );
|
2009-09-14 13:24:17 +00:00
|
|
|
|
2009-08-27 11:41:56 +00:00
|
|
|
/**
|
|
|
|
* Return the first entry in the library.
|
|
|
|
*
|
|
|
|
* @return The first entry or NULL if the library has no entries.
|
|
|
|
*/
|
2009-09-18 14:56:05 +00:00
|
|
|
CMP_LIB_ENTRY* GetFirstEntry()
|
2009-08-27 11:41:56 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
return &entries.front();
|
2009-08-27 11:41:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-12-15 21:11:05 +00:00
|
|
|
* Find next library entry by /a aName.
|
2009-08-27 11:41:56 +00:00
|
|
|
*
|
|
|
|
* If the name of the entry is the last entry in the library, the first
|
|
|
|
* entry in the list is returned.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aName - Name of current entry.
|
|
|
|
* @return Next entry if entry name is found. Otherwise NULL.
|
2009-08-27 11:41:56 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
CMP_LIB_ENTRY* GetNextEntry( const wxChar* aName );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2009-12-15 21:11:05 +00:00
|
|
|
* Find previous library entry by /a aName.
|
2009-08-27 11:41:56 +00:00
|
|
|
*
|
|
|
|
* If the name of the entry is the first entry in the library, the last
|
|
|
|
* entry in the list is returned.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aName - Name of current entry.
|
2009-11-03 13:26:31 +00:00
|
|
|
* @return Previous entry if entry name is found, otherwise NULL.
|
2009-09-18 14:56:05 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
CMP_LIB_ENTRY* GetPreviousEntry( const wxChar* aName );
|
2009-09-18 14:56:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the file name without path or extension.
|
|
|
|
*
|
2009-11-03 13:26:31 +00:00
|
|
|
* @return Name of library file.
|
2009-09-18 14:56:05 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
wxString GetName() const { return fileName.GetName(); }
|
2009-09-18 14:56:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the full file library name with path and extension.
|
|
|
|
*
|
2009-11-03 13:26:31 +00:00
|
|
|
* @return Full library file name with path and extension.
|
2009-09-18 14:56:05 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
wxString GetFullFileName() { return fileName.GetFullPath(); }
|
2009-09-18 14:56:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the component library file name.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aFileName - New library file name.
|
2009-09-18 14:56:05 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
void SetFileName( const wxFileName aFileName )
|
2009-09-18 14:56:05 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
if( aFileName != fileName )
|
|
|
|
fileName = aFileName;
|
2009-09-18 14:56:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The following static methods are for manipulating the list of
|
|
|
|
* component libraries. This eliminates the need for yet another
|
|
|
|
* global variable ( formerly g_LibraryList ) and gives some measure
|
|
|
|
* of safety from abusing the library list.
|
|
|
|
*/
|
|
|
|
|
2009-12-22 20:08:56 +00:00
|
|
|
/**
|
|
|
|
* Test for an existing library.
|
|
|
|
*
|
|
|
|
* @param aLibptr - aLibptr.
|
|
|
|
* @return true found. false if not found.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static bool LibraryExists( const CMP_LIBRARY* aLibptr );
|
2009-09-18 14:56:05 +00:00
|
|
|
/**
|
|
|
|
* Load a component library file.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aFileName - File name of the component library to load.
|
|
|
|
* @param aErrorMsg - Error message if the component library failed to load.
|
2009-11-03 13:26:31 +00:00
|
|
|
* @return Library object if library file loaded successfully,
|
|
|
|
* otherwise NULL.
|
2009-09-18 14:56:05 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
static CMP_LIBRARY* LoadLibrary( const wxFileName& aFileName,
|
|
|
|
wxString& aErrorMsg );
|
2009-09-18 14:56:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a compnent library to the library list.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aFileName - File name object of component library.
|
|
|
|
* @param aErrorMsg - Error message if the component library failed to load.
|
2009-11-03 13:26:31 +00:00
|
|
|
* @return True if library loaded properly otherwise false.
|
2009-09-18 14:56:05 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
static bool AddLibrary( const wxFileName& aFileName, wxString& aErrorMsg );
|
2009-09-18 14:56:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Insert a compnent library to the library list.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aFileName - File name object of component library.
|
|
|
|
* @param aErrerMsg - Error message if the component library failed to load.
|
|
|
|
* @param aIteratir - Iterator to insert library in front of.
|
2009-11-03 13:26:31 +00:00
|
|
|
* @return True if library loaded properly otherwise false.
|
2009-09-18 14:56:05 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
static bool AddLibrary( const wxFileName& aFileName, wxString& aErrorMsg,
|
|
|
|
CMP_LIBRARY_LIST::iterator& aIterator );
|
2009-09-18 14:56:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove component library from the library list.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aName - Name of component library to remove.
|
2009-09-18 14:56:05 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
static void RemoveLibrary( const wxString& aName );
|
2009-09-18 14:56:05 +00:00
|
|
|
|
|
|
|
/**
|
2009-12-15 21:11:05 +00:00
|
|
|
* Find component library by /a aName.
|
2009-09-18 14:56:05 +00:00
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aName - Library file name without path or extension to find.
|
|
|
|
* @return Component library if found, otherwise NULL.
|
2009-09-18 14:56:05 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
static CMP_LIBRARY* FindLibrary( const wxString& aName );
|
2009-09-18 14:56:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the list of component library file names without path and extension.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aSorted - Sort the list of name if true. Otherwise use the
|
|
|
|
* library load order.
|
2009-11-03 13:26:31 +00:00
|
|
|
* @return The list of library names.
|
2009-08-27 11:41:56 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
static wxArrayString GetLibraryNames( bool aSorted = true );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
/**
|
|
|
|
* Search all libraries in the list for a component.
|
|
|
|
*
|
|
|
|
* A component object will always be returned. If the entry found
|
|
|
|
* is an alias. The root component will be found and returned.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aCompoentName - Name of component to search for.
|
|
|
|
* @param aLibraryName - Name of the library to search for component.
|
2009-11-03 13:26:31 +00:00
|
|
|
* @return The component object if found, otherwise NULL.
|
2009-09-18 14:56:05 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
static LIB_COMPONENT* FindLibraryComponent( const wxString& aComponentName,
|
|
|
|
const wxString& aLibraryName = wxEmptyString );
|
2009-09-18 14:56:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Search all libraries in the list for an entry.
|
|
|
|
*
|
|
|
|
* The object can be either a component or an alias.
|
|
|
|
*
|
2009-12-15 21:11:05 +00:00
|
|
|
* @param aEntryName - Name of entry to search for.
|
|
|
|
* @param aLibraryName - Name of the library to search.
|
2009-11-03 13:26:31 +00:00
|
|
|
* @return The entry object if found, otherwise NULL.
|
2009-09-18 14:56:05 +00:00
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
static CMP_LIB_ENTRY* FindLibraryEntry( const wxString& aEntryName,
|
|
|
|
const wxString& aLibraryName = wxEmptyString );
|
2009-09-18 14:56:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove all cache libraries from library list.
|
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
static void RemoveCacheLibrary();
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
static int GetLibraryCount() { return libraryList.size(); }
|
2009-09-18 14:56:05 +00:00
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
static CMP_LIBRARY_LIST& GetLibraryList()
|
2009-09-18 14:56:05 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
return libraryList;
|
2009-09-18 14:56:05 +00:00
|
|
|
}
|
|
|
|
|
2009-12-15 21:11:05 +00:00
|
|
|
static void SetSortOrder( const wxArrayString& aSortOrder )
|
2009-09-18 14:56:05 +00:00
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
libraryListSortOrder = aSortOrder;
|
2009-09-18 14:56:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static wxArrayString& GetSortOrder( void )
|
|
|
|
{
|
2009-12-15 21:11:05 +00:00
|
|
|
return libraryListSortOrder;
|
2009-09-18 14:56:05 +00:00
|
|
|
}
|
2008-09-13 18:59:57 +00:00
|
|
|
};
|
|
|
|
|
2009-08-27 11:41:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Case insensitive library name comparison.
|
|
|
|
*/
|
2009-12-15 21:11:05 +00:00
|
|
|
extern bool operator==( const CMP_LIBRARY& aLibrary, const wxChar* aName );
|
|
|
|
extern bool operator!=( const CMP_LIBRARY& aLibrary, const wxChar* aName );
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2008-09-13 18:59:57 +00:00
|
|
|
#endif // CLASS_LIBRARY_H
|