Commit b0c739e7 authored by Dick Hollenbeck's avatar Dick Hollenbeck
Browse files

*) Implement "Copy On Write" (COW) support in GITHUB_PLUGIN. See class header

   comment for GITHUB_PLUGIN which should flow into Doxygen output.
*) Rewrote: 
        PCB_BASE_FRAME::Save_Module_In_Library(): now uses fp-lib-table and PROPERTIES.  
        PCB_EDIT_FRAME::ArchiveModulesOnBoard(): now can archive to any writable library type.
        PCB_BASE_FRAME::SelectLibrary(): is now generic for selecting a library, not just the active library.
parent 56615d16
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -62,10 +62,6 @@ PCBNew

Dick's Final TODO List:
======================
*) Rewrite
        PCB_BASE_FRAME::Save_Module_In_Library
        PCB_EDIT_FRAME::ArchiveModulesOnBoard
   to use FP_LIB_TABLE mechanisms.
*) Apply Fabrizio and Alexander's linux desktop patches after unifying them.
*) Get licensing cleaned up.
*) Re-arrange the repo architecture.
+34 −2
Original line number Diff line number Diff line
@@ -179,11 +179,27 @@ MODULE* FP_LIB_TABLE::FootprintLoad( const wxString& aNickname, const wxString&
}


void FP_LIB_TABLE::FootprintSave( const wxString& aNickname, const MODULE* aFootprint )
FP_LIB_TABLE::SAVE_T FP_LIB_TABLE::FootprintSave( const wxString& aNickname, const MODULE* aFootprint, bool aOverwrite )
{
    const ROW* row = FindRow( aNickname );
    wxASSERT( (PLUGIN*) row->plugin );
    return row->plugin->FootprintSave( row->GetFullURI( true ), aFootprint, row->GetProperties() );

    if( !aOverwrite )
    {
        // Try loading the footprint to see if it already exists, caller wants overwrite
        // protection, which is atypical, not the default.

        wxString fpname = FROM_UTF8( aFootprint->GetFPID().GetFootprintName().c_str() );

        std::auto_ptr<MODULE>   m( row->plugin->FootprintLoad( row->GetFullURI( true ), fpname, row->GetProperties() ) );

        if( m.get() )
            return SAVE_SKIPPED;
    }

    row->plugin->FootprintSave( row->GetFullURI( true ), aFootprint, row->GetProperties() );

    return SAVE_OK;
}


@@ -203,6 +219,22 @@ bool FP_LIB_TABLE::IsFootprintLibWritable( const wxString& aNickname )
}


void FP_LIB_TABLE::FootprintLibDelete( const wxString& aNickname )
{
    const ROW* row = FindRow( aNickname );
    wxASSERT( (PLUGIN*) row->plugin );
    row->plugin->FootprintLibDelete( row->GetFullURI( true ), row->GetProperties() );
}


void FP_LIB_TABLE::FootprintLibCreate( const wxString& aNickname )
{
    const ROW* row = FindRow( aNickname );
    wxASSERT( (PLUGIN*) row->plugin );
    row->plugin->FootprintLibCreate( row->GetFullURI( true ), row->GetProperties() );
}


const wxString FP_LIB_TABLE::GetDescription( const wxString& aNickname )
{
    // use "no exception" form of find row:
+20 −1
Original line number Diff line number Diff line
@@ -394,6 +394,16 @@ public:
     */
    MODULE* FootprintLoad( const wxString& aNickname, const wxString& aFootprintName );

    /**
     * Enum SAVE_T
     * is the set of return values from FootprintSave() below.
     */
    enum SAVE_T
    {
        SAVE_OK,
        SAVE_SKIPPED,
    };

    /**
     * Function FootprintSave
     * will write @a aFootprint to an existing library given by @a aNickname.
@@ -405,9 +415,14 @@ public:
     * @param aFootprint is what to store in the library. The caller continues
     *    to own the footprint after this call.
     *
     * @param aOverwrite when true means overwrite any existing footprint by the
     *  same name, else if false means skip the write and return SAVE_SKIPPED.
     *
     * @return SAVE_T - SAVE_OK or SAVE_SKIPPED.  If error saving, then IO_ERROR is thrown.
     *
     * @throw IO_ERROR if there is a problem saving.
     */
    void FootprintSave( const wxString& aNickname, const MODULE* aFootprint );
    SAVE_T FootprintSave( const wxString& aNickname, const MODULE* aFootprint, bool aOverwrite = true );

    /**
     * Function FootprintDelete
@@ -431,6 +446,10 @@ public:
     */
    bool IsFootprintLibWritable( const wxString& aNickname );

    void FootprintLibDelete( const wxString& aNickname );

    void FootprintLibCreate( const wxString& aNickname );

    //-----</PLUGIN API SUBSET, REBASED ON aNickname>---------------------------

    /**
+11 −1
Original line number Diff line number Diff line
@@ -295,7 +295,7 @@ public:
     * @param aLibName = name of the library to use
     * @param aModule = the given footprint
     * @param aOverwrite = true to overwrite an existing footprint, false to
     *                     abort an existing footprint is found
     *                     abort if an existing footprint with same name is found
     * @param aDisplayDialog = true to display a dialog to enter or confirm the
     *                         footprint name
     * @return : true if OK, false if abort
@@ -305,6 +305,16 @@ public:
                                 bool            aOverwrite,
                                 bool            aDisplayDialog );

    /**
     * Function SelectLibrary
     * puts up a dialog and allows the user to pick a library, for unspecified use.
     *
     * @param aNicknameExisting is the current choice to highlight
     *
     * @return wxString - the library or wxEmptyString on abort.
     */
    wxString SelectLibrary( const wxString& aNicknameExisting );

    MODULE* GetModuleByName();

    /**
+2 −3
Original line number Diff line number Diff line
@@ -906,12 +906,11 @@ public:
    /**
     * Function ArchiveModulesOnBoard
     * Save modules in a library:
     * @param aLibName: the full filename of the library to create or modify
     * @param aNewModulesOnly:
     *              true : save modules not already existing in this lib
     *              false: save all modules
     */
    void ArchiveModulesOnBoard( const wxString& aLibName, bool aNewModulesOnly );
    void ArchiveModulesOnBoard( bool aNewModulesOnly );

    /**
     * Function RecreateBOMFileFromBoard
Loading