Commit 3335ccd9 authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

Initial work on new component library stucture.

* Use C++ map in component library instead of boost::ptr_vector.
* Drop Boost pointer containers for standard C++ containers.
* Moved duplicate name user interface elements from library object to
  library editor.
* Added code to support direct addition and replacement of component
  alias objects into libraries.
* Removed temporary strings used to add and remove alias objects.
* Libraries only store alias objects, components now accessed thru alias.
* Simplify library API for adding, removing, and replacing components.
* Updated edit component in library dialog and library editor to reflect
  component library object changes.
* Fixed bug in library viewer when displaying alias name.
* Made a few header files compile stand alone per the new coding policy.
* Remove some dead code and the usual code formatting fixes.
parent ffec0b84
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ void ReAnnotatePowerSymbolsOnly( void )
            LIB_COMPONENT* Entry =
                CMP_LIBRARY::FindLibraryComponent( DrawLibItem->m_ChipName );

            if( ( Entry == NULL ) || !Entry->isPower() )
            if( ( Entry == NULL ) || !Entry->IsPower() )
                continue;

            //DrawLibItem->ClearAnnotation(sheet); this clears all annotation :(
+163 −138
Original line number Diff line number Diff line
/**********************************************************/
/*  lib_entry.cpp                                         */
/**********************************************************/
/*************************/
/*  class_libentry.cpp   */
/*************************/

#include "fctsys.h"
#include "common.h"
@@ -20,6 +20,15 @@
#include <boost/foreach.hpp>


// Set this to 1 to print debugging ouput in alias and component destructors to verify
// objects get cleaned up properly.
#if defined( TRACE_DESTRUCTOR )
#undef TRACE_DESTRUCTOR
#endif

#define TRACE_DESTRUCTOR 0


/** class CMP_LIB_ENTRY
 * Base class to describe library components and aliases.
 * This class is not to be used directly.
@@ -134,41 +143,31 @@ int LibraryEntryCompare( const CMP_LIB_ENTRY* aItem1, const CMP_LIB_ENTRY* aItem
 *  (like 74LS00, 74HC00 ... and many op amps )
 */

LIB_ALIAS::LIB_ALIAS( const wxString& aName, LIB_COMPONENT* aRootComponent,
                      CMP_LIBRARY* aLibrary ) :
    CMP_LIB_ENTRY( ALIAS, aName, aLibrary )
LIB_ALIAS::LIB_ALIAS( const wxString& aName, LIB_COMPONENT* aRootComponent ) :
    CMP_LIB_ENTRY( ALIAS, aName, NULL )
{
    wxASSERT( aRootComponent != NULL && aRootComponent->isComponent() );

    root = aRootComponent;
    if( aLibrary == NULL )
        library = aRootComponent->GetLibrary();
}


LIB_ALIAS::LIB_ALIAS( LIB_ALIAS& aAlias, CMP_LIBRARY* aLibrary ) :
    CMP_LIB_ENTRY( aAlias )
LIB_ALIAS::LIB_ALIAS( LIB_ALIAS& aAlias, LIB_COMPONENT* aRootComponent ) : CMP_LIB_ENTRY( aAlias )
{
    root = aAlias.root;
    root = aRootComponent;
}


LIB_ALIAS::~LIB_ALIAS()
{
#if TRACE_DESTRUCTOR
    wxLogDebug( wxT( "Destroying alias \"%s\" of component \"%s\" with alais list count %d." ),
                GetChars( name ), GetChars( root->GetName() ), root->m_aliases.size() );
#endif
}


void LIB_ALIAS::SetComponent( LIB_COMPONENT* aComponent )
{
    wxASSERT( aComponent != NULL && aComponent->isComponent() );

    root = aComponent;
}


/********************************/
/***********************/
/* class LIB_COMPONENT */
/********************************/
/***********************/

/**
 * Library component object definition.
@@ -188,6 +187,10 @@ LIB_COMPONENT::LIB_COMPONENT( const wxString& aName, CMP_LIBRARY* aLibrary ) :
    m_showPinNumbers      = true;
    m_showPinNames        = true;

    // Create the default alias if the name paremeter is not empty.
    if( !aName.IsEmpty() )
        m_aliases.push_back( new LIB_ALIAS( aName, this ) );

    // Add the MANDATORY_FIELDS in RAM only.  These are assumed to be present
    // when the field editors are invoked.
    LIB_FIELD* value = new LIB_FIELD( this, VALUE );
@@ -205,8 +208,6 @@ LIB_COMPONENT::LIB_COMPONENT( LIB_COMPONENT& aComponent, CMP_LIBRARY* aLibrary )
{
    LIB_DRAW_ITEM* newItem;

    m_AliasList           = aComponent.m_AliasList;
    m_aliasListData       = aComponent.m_aliasListData;
    m_FootprintList       = aComponent.m_FootprintList;
    unitCount             = aComponent.unitCount;
    m_unitsLocked         = aComponent.m_unitsLocked;
@@ -225,12 +226,37 @@ LIB_COMPONENT::LIB_COMPONENT( LIB_COMPONENT& aComponent, CMP_LIBRARY* aLibrary )
        newItem->SetParent( this );
        drawings.push_back( newItem );
    }

    for( size_t i = 0; i < aComponent.m_aliases.size(); i++ )
    {
        LIB_ALIAS* alias = new LIB_ALIAS( *aComponent.m_aliases[i], this );
        m_aliases.push_back( alias );
    }
}


LIB_COMPONENT::~LIB_COMPONENT()
{
#if TRACE_DESTRUCTOR
    wxLogDebug( wxT( "Destroying component <%s> with alias list count of %d" ),
                GetChars( GetName() ), m_aliases.size() );
#endif

    // If the component is being delete directly rather than trough the library, free all
    // of the memory allocated by the aliases.
    if( !m_aliases.empty() )
    {
        LIB_ALIAS* alias;

        while( !m_aliases.empty() )
        {
            alias = m_aliases.back();
            m_aliases.pop_back();
            delete alias;
        }
    }
}


/** function IsMulti
 * @return the sub reference for component having multiple parts per package.
@@ -592,15 +618,17 @@ bool LIB_COMPONENT::Save( FILE* aFile )
        }
    }

    /* Save the alias list: a line starting by "ALIAS" */
    if( m_AliasList.GetCount() != 0 )
    // Save the alias list: a line starting by "ALIAS".  The first alias is the root
    // and has the same name as the component.  In the old library file format this
    // alias does not get added to the alias list.
    if( m_aliases.size() > 1 )
    {
        if( fprintf( aFile, "ALIAS" ) < 0 )
            return false;

        for( i = 0; i < m_AliasList.GetCount(); i++ )
        for( i = 1; i < m_aliases.size(); i++ )
        {
            if( fprintf( aFile, " %s", CONV_TO_UTF8( m_AliasList[i] ) ) < 0 )
            if( fprintf( aFile, " %s", CONV_TO_UTF8( m_aliases[i]->GetName() ) ) < 0 )
                return false;
        }

@@ -616,8 +644,7 @@ bool LIB_COMPONENT::Save( FILE* aFile )

        for( i = 0; i < m_FootprintList.GetCount(); i++ )
        {
            if( fprintf( aFile, " %s\n",
                         CONV_TO_UTF8( m_FootprintList[i] ) ) < 0 )
            if( fprintf( aFile, " %s\n", CONV_TO_UTF8( m_FootprintList[i] ) ) < 0 )
                return false;
        }

@@ -655,8 +682,7 @@ bool LIB_COMPONENT::Save( FILE* aFile )
}


bool LIB_COMPONENT::Load( FILE* aFile, char* aLine, int* aLineNum,
                          wxString& aErrorMsg )
bool LIB_COMPONENT::Load( FILE* aFile, char* aLine, int* aLineNum, wxString& aErrorMsg )
{
    int      unused;
    char*    p;
@@ -723,6 +749,9 @@ bool LIB_COMPONENT::Load( FILE* aFile, char* aLine, int* aLineNum,
        value.m_Attributs |= TEXT_NO_VISIBLE;
    }

    // Add the root alias to the alias list.
    m_aliases.push_back( new LIB_ALIAS( name, this ) );

    LIB_FIELD& reference = GetReferenceField();

    if( strcmp( prefix, "~" ) == 0 )
@@ -872,7 +901,7 @@ bool LIB_COMPONENT::LoadAliases( char* aLine, wxString& aErrorMsg )

    while( text )
    {
        m_AliasList.Add( CONV_FROM_UTF8( text ) );
        m_aliases.push_back( new LIB_ALIAS( CONV_FROM_UTF8( text ), this ) );
        text = strtok( NULL, " \t\r\n" );
    }

@@ -1454,144 +1483,140 @@ void LIB_COMPONENT::SetConversion( bool aSetConvert )
}


/* accessors to aliases data, used by the component editor, during edition
*/
/** Function LocateAliasData
 * @return an index in array string to the alias data (doc, keywords, docfile)
 *         or -1 if not found
 * @param aAliasName = the alias name
 * @param aCreateIfNotExist = true if the alias data must be created, when not exists
 */
int LIB_COMPONENT::LocateAliasData( const wxString & aAliasName, bool aCreateIfNotExist)
wxArrayString LIB_COMPONENT::GetAliasNames( bool aIncludeRoot ) const
{
    int idx = -1;
    for( unsigned ii = 0; ii < m_aliasListData.size(); ii += ALIAS_NEXT_IDX )
    wxArrayString names;

    LIB_ALIAS_LIST::const_iterator it;

    for( it=m_aliases.begin();  it<m_aliases.end();  ++it )
    {
        if( aAliasName.CmpNoCase( m_aliasListData[ii] ) != 0 )
        if( !aIncludeRoot && (*it)->IsRoot() )
            continue;
        // Found!
        idx = (int) ii;
        break;
    }

    // Alias not found, create on demand
    if( aCreateIfNotExist && (idx < 0) )
    {
        idx = (int) m_aliasListData.size();
        m_aliasListData.Add( aAliasName );
        // Add void strings for data:
        m_aliasListData.Add( wxEmptyString );     //Doc string
        m_aliasListData.Add( wxEmptyString );     //keywords string
        m_aliasListData.Add( wxEmptyString );     //Doc fliname string
        names.Add( (*it)->GetName() );
    }

    return idx;
    return names;
}


/** Function GetAliasDataDoc
 * @param aAliasName = the alias name
 * @return the Doc string
 */
wxString LIB_COMPONENT::GetAliasDataDoc( const wxString & aAliasName )
bool LIB_COMPONENT::HasAlias( const wxString& aName ) const
{
    wxCHECK2_MSG( !aName.IsEmpty(), return false,
                  wxT( "Cannot get alias with an empty name, bad programmer." ) );

    for( size_t i = 0; i < m_aliases.size(); i++ )
    {
    wxString data;
    int idx = LocateAliasData( aAliasName );
    if ( idx >= 0 )
        data = m_aliasListData[idx + ALIAS_DOC_IDX];
        if( aName.CmpNoCase( m_aliases[i]->GetName() ) == 0 )
            return true;
    }

    return data;
    return false;
}


/** Function GetAliasDataKeyWords
 * @param aAliasName = the alias name
 * @return aAliasData = the keywords string
 */
wxString LIB_COMPONENT::GetAliasDataKeyWords( const wxString & aAliasName )
void LIB_COMPONENT::SetAliases( const wxArrayString& aAliasList )
{
    wxString data;
    int idx = LocateAliasData( aAliasName );
    if ( idx >= 0 )
        data = m_aliasListData[idx + ALIAS_KEYWORD_IDX];
    wxCHECK_RET( library == NULL,
                 wxT( "Component aliases cannot be changed when they are owned by a library." ) );

    return data;
    if( aAliasList == GetAliasNames() )
        return;

    // Add names not existing in the current component alias list.
    for( size_t i = 0; i < aAliasList.GetCount(); i++ )
    {
        if( HasAlias( aAliasList[ i ] ) )
            continue;

        m_aliases.push_back( new LIB_ALIAS( aAliasList[ i ], this ) );
    }

    /* Remove names in the current component that are not in the new alias list. */
    LIB_ALIAS_LIST::iterator it;

/** Function GetAliasDataDocFileName
 * @param aAliasName = the alias name
 * @return the Doc filename string
 */
wxString LIB_COMPONENT::GetAliasDataDocFileName( const wxString & aAliasName )
    for( it = m_aliases.begin(); it < m_aliases.end(); it++ )
    {
    wxString data;
    int idx = LocateAliasData( aAliasName );
    if ( idx >= 0 )
        data = m_aliasListData[idx + ALIAS_DOC_FILENAME_IDX];
        int index = aAliasList.Index( (*it)->GetName(), false );

        if( index != wxNOT_FOUND || (*it)->IsRoot() )
            continue;

    return data;
        it = m_aliases.erase( it );
    }
}


void LIB_COMPONENT::RemoveAlias( const wxString& aName )
{
    wxCHECK_RET( library == NULL,
                 wxT( "Component aliases cannot be changed when they are owned by a library." ) );
    wxCHECK_RET( !aName.IsEmpty(), wxT( "Cannot get alias with an empty name." ) );

    LIB_ALIAS_LIST::iterator it;

/** Function SetAliasDataDoc
 * @param aAliasName = the alias name
 * @param aAliasData = the Doc string
 */
void LIB_COMPONENT::SetAliasDataDoc( const wxString & aAliasName, const wxString & aAliasData )
    for( it = m_aliases.begin(); it < m_aliases.end(); it++ )
    {
        if( aName.CmpNoCase( (*it)->GetName() ) == 0 )
        {
    int idx = LocateAliasData( aAliasName, true );
    m_aliasListData[idx + ALIAS_DOC_IDX] = aAliasData;
            m_aliases.erase( it );
            break;
        }
    }
}

/** Function SetAliasDataKeywords
 * @param aAliasName = the alias name
 * @param aAliasData = the keywords string
 */
void LIB_COMPONENT::SetAliasDataKeywords( const wxString & aAliasName, const wxString & aAliasData )

LIB_ALIAS* LIB_COMPONENT::RemoveAlias( LIB_ALIAS* aAlias )
{
    int idx = LocateAliasData( aAliasName, true );
    m_aliasListData[idx + ALIAS_KEYWORD_IDX] = aAliasData;
}
    wxCHECK_MSG( aAlias != NULL, NULL, wxT( "Cannot remove alias by NULL pointer." ) );

/** Function SetAliasDataDocFileName
 * @param aAliasName = the alias name
 * @param aAliasData = the Doc filename string
 */
void LIB_COMPONENT::SetAliasDataDocFileName( const wxString & aAliasName,
                                             const wxString & aAliasData )
    LIB_ALIAS* nextAlias = NULL;
    LIB_ALIAS_LIST::iterator it = find( m_aliases.begin(), m_aliases.end(), aAlias );

    if( it != m_aliases.end() )
    {
    int idx = LocateAliasData( aAliasName, true );
    m_aliasListData[idx + ALIAS_DOC_FILENAME_IDX] = aAliasData;
}
        bool rename = aAlias->IsRoot();

        it = m_aliases.erase( it );
        delete aAlias;

/** Function RemoveAliasData
 * remove an alias data from list
 * @param aAliasName = the alias name
 */
void LIB_COMPONENT::RemoveAliasData(const wxString & aAliasName )
        if( !m_aliases.empty() )
        {
    int idx = LocateAliasData( aAliasName );
    if ( idx >= 0 )
        m_aliasListData.RemoveAt( idx + ALIAS_NAME_IDX, ALIAS_NEXT_IDX );
            if( it == m_aliases.end() )
                it = m_aliases.begin();

            nextAlias = (*it);

            if( rename )
                SetName( nextAlias->GetName() );
        }

/** Function CollectAliasesData
 * store in m_aliasListData alias data (doc, keywords, docfile)
 * for each alias found in m_AliasList
*/
void LIB_COMPONENT::CollectAliasesData( CMP_LIBRARY* aLibrary )
    }

    return nextAlias;
}


LIB_ALIAS* LIB_COMPONENT::GetAlias( const wxString& aName )
{
    for( unsigned ii = 0; ii < m_AliasList.GetCount(); ii++ )
    wxCHECK2_MSG( !aName.IsEmpty(), return NULL,
                  wxT( "Cannot get alias with an empty name.  Bad programmer!" ) );

    for( size_t i = 0; i < m_aliases.size(); i++ )
    {
        CMP_LIB_ENTRY* entry = aLibrary->FindEntry( m_AliasList[ii] );
        if ( ! entry )
            continue;
        if( aName.CmpNoCase( m_aliases[i]->GetName() ) == 0 )
            return m_aliases[i];
    }

        SetAliasDataDoc( m_AliasList[ii], entry->GetDescription() );
        SetAliasDataKeywords( m_AliasList[ii], entry->GetKeyWords() );
        SetAliasDataDocFileName( m_AliasList[ii], entry->GetDocFileName() );
    return NULL;
}


LIB_ALIAS* LIB_COMPONENT::GetAlias( size_t aIndex )
{
    wxCHECK2_MSG( aIndex < m_aliases.size(), return NULL,
                  wxT( "Illegal alias list index, bad programmer." ) );

    return m_aliases[aIndex];
}
+59 −118
Original line number Diff line number Diff line
@@ -8,11 +8,27 @@
#include "classes_body_items.h"
#include "class_libentry_fields.h"

#include <boost/ptr_container/ptr_vector.hpp>
#include <map>


class CMP_LIBRARY;
class LIB_ALIAS;

/**
 * LIB_ALIAS map sorting.
 */
struct AliasMapSort
{
    bool operator() ( const wxString& aItem1, const wxString& aItem2 ) const
        { return aItem1.CmpNoCase( aItem2 ) < 0; }
};

/**
 * Alias map used by component library object.
 */
typedef std::map< wxString, LIB_ALIAS*, AliasMapSort > LIB_ALIAS_MAP;

typedef std::vector< LIB_ALIAS* > LIB_ALIAS_LIST;

/* Types for components in libraries
 * components can be a true component or an alias of a true component.
@@ -114,10 +130,9 @@ public:
    {
        return !( *this == aName );
    }
};

typedef boost::ptr_vector< CMP_LIB_ENTRY > LIB_ENTRY_LIST;

    bool operator==( const wxString& aName ) const { return *this == ( const wxChar* ) aName; }
};

extern bool operator<( const CMP_LIB_ENTRY& aItem1, const CMP_LIB_ENTRY& aItem2 );

@@ -142,42 +157,21 @@ class LIB_COMPONENT : public CMP_LIB_ENTRY
    LibrEntryOptions   m_options;        ///< Special component features such as POWER or NORMAL.)
    int                unitCount;        ///< Number of units (parts) per package.
    LIB_DRAW_ITEM_LIST drawings;         ///< How to draw this part.
    wxArrayString      m_aliasListData;  /* ALIAS data (name, doc, keywords and doc filename).
                                          * Used only by the component editor LibEdit
                                          * to store aliases info during edition
                                          * usually void outside the component editor */
    wxArrayString      m_AliasList;      ///< List of alias names for the component.
    wxArrayString      m_FootprintList;  /**< List of suitable footprint names for the
                                              component (wild card names accepted). */

    LIB_ALIAS_LIST     m_aliases;        ///< List of alias object pointers associated with the
                                         ///< component.

    void deleteAllFields();

    friend class CMP_LIBRARY;
    friend class LIB_ALIAS;

public:
    /* Offsets used in editing library component,
     * for handle aliases data in m_AliasListData array string
     * when editing a library component, aliases data is stored
     * in m_AliasListData.
     * 4 strings by alias are stored:
     * name, doc, keywords and doc filename
     * these constants are indexes in m_AliasListData
     * to read/write strings for a given alias
     */
    enum alias_idx
    {
        ALIAS_NAME_IDX         = 0,
        ALIAS_DOC_IDX          = 1,
        ALIAS_KEYWORD_IDX      = 2,
        ALIAS_DOC_FILENAME_IDX = 3,
        ALIAS_NEXT_IDX         = 4
    };

    LIB_COMPONENT( const wxString& aName, CMP_LIBRARY* aLibrary = NULL );
    LIB_COMPONENT( LIB_COMPONENT& aComponent, CMP_LIBRARY* aLibrary = NULL );

    ~LIB_COMPONENT();
    virtual ~LIB_COMPONENT();

    virtual wxString GetClass() const
    {
@@ -191,72 +185,31 @@ public:
        GetValueField().m_Text = aName;
    }

    wxArrayString& GetAliasList() { return m_AliasList; }
    wxArrayString GetAliasNames( bool aIncludeRoot = true ) const;

    wxArrayString& GetFootPrints() { return m_FootprintList; }
    size_t GetAliasCount() const { return m_aliases.size(); }

    /* accessors to aliases data, used by the component editor, during edition
    */
    /** Function CollectAliasesData
     * store in m_aliasListData alias data (doc, keywords, docfile)
     * for each alias found in m_AliasList
    */
    void CollectAliasesData( CMP_LIBRARY* aLibrary );
    LIB_ALIAS* GetAlias( size_t aIndex );

    /** Function LocateAliasData
     * @return an index in array string to the alias data (doc, keywords, docfile)
     *         or -1 if not found
     * @param aAliasName = the alias name
     * @param aCreateIfNotExist = true if the alias data must be created, when not exists
     */
    int LocateAliasData( const wxString & aAliasName, bool aCreateIfNotExist = false );

    /** Function GetAliasDataDoc
     * @param aAliasName = the alias name
     * @return the Doc string
     */
    wxString GetAliasDataDoc( const wxString & aAliasName );
    LIB_ALIAS* GetAlias( const wxString& aName );

    /** Function GetAliasDataKeyWords
     * @param aAliasName = the alias name
     * @return aAliasData = the keywords string
     */
    wxString GetAliasDataKeyWords( const wxString & aAliasName );

    /** Function GetAliasDataDocFileName
     * @param aAliasName = the alias name
     * @return the Doc filename string
     */
    wxString GetAliasDataDocFileName( const wxString & aAliasName );

    /** Function SetAliasDataDoc
     * @param aAliasName = the alias name
     * @return aAliasData = the Doc string
    /**
     * Test if alias \a aName is in component alias list.
     *
     * Alias name comparisons are case insensitive.
     *
     * @param aName - Name of alias.
     * @return True if alias name in alias list.
     */
    void SetAliasDataDoc( const wxString & aAliasName, const wxString & aAliasData );
    bool HasAlias( const wxString& aName ) const;

    /** Function SetAliasDataKeywords
     * @param aAliasName = the alias name
     * @param aAliasData = the keywords string
     */
    void SetAliasDataKeywords( const wxString & aAliasName, const wxString & aAliasData );
    void SetAliases( const wxArrayString& aAliasList );

    /** Function SetAliasDataDocFileName
     * @param aAliasName = the alias name
     * @param aAliasData = the Doc filename string
     */
    void SetAliasDataDocFileName( const wxString & aAliasName, const wxString & aAliasData );
    void RemoveAlias( const wxString& aName );

    /** Function ClearAliasDataDoc
     * clear aliases data list
     */
    void ClearAliasDataDoc( ) { m_aliasListData.Clear(); }
    LIB_ALIAS* RemoveAlias( LIB_ALIAS* aAlias );

    /** Function RemoveAliasData
     * remove an alias data from list
     * @param aAliasName = the alias name
     */
    void RemoveAliasData(const wxString & aAliasName );
    wxArrayString& GetFootPrints() { return m_FootprintList; }

    EDA_Rect GetBoundaryBox( int aUnit, int aConvert );

@@ -286,8 +239,8 @@ public:
    bool LoadAliases( char* aLine, wxString& aErrorMsg );
    bool LoadFootprints( FILE* aFile, char* aLine, int* aLineNum, wxString& aErrorMsg );

    bool isPower() { return m_options == ENTRY_POWER; }
    bool isNormal() { return m_options == ENTRY_NORMAL; }
    bool IsPower() { return m_options == ENTRY_POWER; }
    bool IsNormal() { return m_options == ENTRY_NORMAL; }

    void SetPower() { m_options = ENTRY_POWER; }
    void SetNormal() { m_options = ENTRY_NORMAL; }
@@ -301,7 +254,7 @@ public:
     * in \a aFieldsList.  The only known caller of this function is the
     * library component field editor, and it establishes needed behavior.
     *
     * @param aFieldsList is a set of fields to import, removing all previous fields.
`     * @param aFieldsList is a set of fields to import, removing all previous fields.
     */
    void SetFields( const std::vector <LIB_FIELD>& aFieldsList );

@@ -460,20 +413,6 @@ public:
     */
    bool HasConversion() const;

    /**
     * Test if alias \a aName is in component alias list.
     *
     * Alias name comparisons are case insensitive.
     *
     * @param aName - Name of alias.
     * @return True if alias name in alias list.
     */
    bool HasAlias( const wxChar* aName )
    {
        wxASSERT( aName != NULL );
        return m_AliasList.Index( aName ) != wxNOT_FOUND;
    }

    /**
     * Clears the status flag all draw objects in this component.
     */
@@ -630,6 +569,8 @@ public:
    void SetShowPinNumbers( bool aShow ) { m_showPinNumbers = aShow; }

    bool ShowPinNumbers() { return m_showPinNumbers; }

    bool operator==( const LIB_COMPONENT* aComponent ) const { return this == aComponent; }
};


@@ -641,23 +582,24 @@ public:
 */
class LIB_ALIAS : public CMP_LIB_ENTRY
{
    friend class LIB_COMPONENT;

protected:
    /**
     * The actual component of the alias.
     *
     * @note - Do not delete the root component.  The root component is owned
     *         by library the component is part of.  Deleting the root component
     *         will likely cause EESchema to crash.
     *         Or, if the root component is deleted, aliases must be deleted or their .root member
     *         must be changed to point a new root component
     * @note - Do not delete the root component.  The root component is actually shared by
     *         all of the aliases associated with it.  The component pointer will be delete
     *         in the destructor of the last alias that shares this component is deleted.
     *         Deleting the root component will likely cause EESchema to crash.
     */
    LIB_COMPONENT* root;

public:
    LIB_ALIAS( const wxString& aName, LIB_COMPONENT* aRootComponent,
               CMP_LIBRARY* aLibrary = NULL );
    LIB_ALIAS( LIB_ALIAS& aAlias, CMP_LIBRARY* aLibrary = NULL );
    ~LIB_ALIAS();
    LIB_ALIAS( const wxString& aName, LIB_COMPONENT* aRootComponent );
    LIB_ALIAS( LIB_ALIAS& aAlias, LIB_COMPONENT* aRootComponent = NULL );

    virtual ~LIB_ALIAS();

    virtual wxString GetClass() const
    {
@@ -672,10 +614,9 @@ public:
        return root;
    }

    /**
     * Set the alias root component.
     */
    void SetComponent( LIB_COMPONENT* aComponent );
    bool IsRoot() const { return name.CmpNoCase( root->GetName() ) == 0; }

    bool operator==( const LIB_ALIAS* aAlias ) const { return this == aAlias; }
};


+1 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
#ifndef CLASS_LIBENTRY_FIELDS_H
#define CLASS_LIBENTRY_FIELDS_H


#include "program.h"
#include "classes_body_items.h"


Loading