KiCad PCB EDA Suite
Loading...
Searching...
No Matches
scratch_doc.h File Reference
#include <functional>
#include <memory>
#include <utility>
#include <project.h>
#include <settings/settings_manager.h>
#include <wildcards_and_files_ext.h>
#include <wx/filename.h>
#include <wx/string.h>

Go to the source code of this file.

Classes

class  SCRATCH_PROJECT
 Move-only RAII wrapper for "load a foreign PROJECT non-active and unload it on scope exit. More...
 
struct  SCRATCH_DOC< DOC >
 Move-only RAII wrapper for "load a KiCad document into a non-active scratch PROJECT and clean up after. More...
 

Functions

template<typename DOC, typename Loader, typename ClearFn>
SCRATCH_DOC< DOC > LoadScratchDoc (SETTINGS_MANAGER &aMgr, const wxString &aDocPath, Loader aLoader, ClearFn aClearFn)
 Construct a SCRATCH_DOC by loading a project non-active and then handing it to the caller's document loader.
 

Function Documentation

◆ LoadScratchDoc()

template<typename DOC, typename Loader, typename ClearFn>
SCRATCH_DOC< DOC > LoadScratchDoc ( SETTINGS_MANAGER & aMgr,
const wxString & aDocPath,
Loader aLoader,
ClearFn aClearFn )

Construct a SCRATCH_DOC by loading a project non-active and then handing it to the caller's document loader.

The loader gets the live PROJECT* and must return a unique_ptr<DOC> (nullptr on failure). The clear callback severs the document's project back-pointer in the destructor.

Definition at line 231 of file scratch_doc.h.

References SCRATCH_DOC< DOC >::clearProject, SCRATCH_DOC< DOC >::doc, SETTINGS_MANAGER::GetProject(), SETTINGS_MANAGER::LoadProject(), SCRATCH_DOC< DOC >::mgr, SCRATCH_DOC< DOC >::ownsProject, SETTINGS_MANAGER::Prj(), SCRATCH_DOC< DOC >::project, FILEEXT::ProjectFileExtension, and SETTINGS_MANAGER::UnloadProject().

Referenced by loadScratchBoard(), and loadScratchSchematic().