KiCad PCB EDA Suite
Loading...
Searching...
No Matches
IO_MGR Class Reference

A factory which returns an instance of a PLUGIN. More...

#include <io_mgr.h>

Classes

class  PLUGIN_REGISTRY
 Hold a list of available plugins, created using a singleton REGISTER_PLUGIN object. More...
 
struct  REGISTER_PLUGIN
 Register a plugin. More...
 

Public Types

enum  PCB_FILE_T {
  KICAD_SEXP , LEGACY , ALTIUM_CIRCUIT_MAKER , ALTIUM_CIRCUIT_STUDIO ,
  ALTIUM_DESIGNER , CADSTAR_PCB_ARCHIVE , EAGLE , EASYEDA ,
  EASYEDAPRO , FABMASTER , GEDA_PCB , PCAD ,
  SOLIDWORKS_PCB , FILE_TYPE_NONE
}
 The set of file types that the IO_MGR knows about, and for which there has been a plugin written, in alphabetical order. More...
 

Static Public Member Functions

static PLUGINPluginFind (PCB_FILE_T aFileType)
 Return a PLUGIN which the caller can use to import, export, save, or load design documents. More...
 
static void PluginRelease (PLUGIN *aPlugin)
 Release a PLUGIN back to the system and may cause it to be unloaded from memory. More...
 
static const wxString ShowType (PCB_FILE_T aFileType)
 Return a brief name for a plugin given aFileType enum. More...
 
static PCB_FILE_T EnumFromStr (const wxString &aFileType)
 Return the PCB_FILE_T from the corresponding plugin type name: "kicad", "legacy", etc. More...
 
static PCB_FILE_T FindPluginTypeFromBoardPath (const wxString &aFileName, int aCtl=0)
 Return a plugin type given a path for a board file. More...
 
static PCB_FILE_T GuessPluginTypeFromLibPath (const wxString &aLibPath, int aCtl=0)
 Return a plugin type given a footprint library's libPath. More...
 
static BOARDLoad (PCB_FILE_T aFileType, const wxString &aFileName, BOARD *aAppendToMe=nullptr, const STRING_UTF8_MAP *aProperties=nullptr, PROJECT *aProject=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr)
 Find the requested PLUGIN and if found, calls the PLUGIN::LoadBoard() function on it using the arguments passed to this function. More...
 
static void Save (PCB_FILE_T aFileType, const wxString &aFileName, BOARD *aBoard, const STRING_UTF8_MAP *aProperties=nullptr)
 Write either a full aBoard to a storage file in a format that this implementation knows about, or it can be used to write a portion ofaBoard to a special kind of export file. More...
 

Detailed Description

A factory which returns an instance of a PLUGIN.

Definition at line 45 of file io_mgr.h.

Member Enumeration Documentation

◆ PCB_FILE_T

The set of file types that the IO_MGR knows about, and for which there has been a plugin written, in alphabetical order.

Enumerator
KICAD_SEXP 

S-expression Pcbnew file format.

LEGACY 

Legacy Pcbnew file formats prior to s-expression.

ALTIUM_CIRCUIT_MAKER 
ALTIUM_CIRCUIT_STUDIO 
ALTIUM_DESIGNER 
CADSTAR_PCB_ARCHIVE 
EAGLE 
EASYEDA 
EASYEDAPRO 
FABMASTER 
GEDA_PCB 

Geda PCB file formats.

PCAD 
SOLIDWORKS_PCB 
FILE_TYPE_NONE 

Definition at line 53 of file io_mgr.h.

Member Function Documentation

◆ EnumFromStr()

IO_MGR::PCB_FILE_T IO_MGR::EnumFromStr ( const wxString &  aFileType)
static

Return the PCB_FILE_T from the corresponding plugin type name: "kicad", "legacy", etc.

Definition at line 98 of file io_mgr.cpp.

References IO_MGR::PLUGIN_REGISTRY::AllPlugins(), and IO_MGR::PLUGIN_REGISTRY::Instance().

Referenced by FP_GRID_TRICKS::optionsEditor(), and FP_LIB_TABLE_ROW::SetType().

◆ FindPluginTypeFromBoardPath()

IO_MGR::PCB_FILE_T IO_MGR::FindPluginTypeFromBoardPath ( const wxString &  aFileName,
int  aCtl = 0 
)
static

◆ GuessPluginTypeFromLibPath()

◆ Load()

BOARD * IO_MGR::Load ( PCB_FILE_T  aFileType,
const wxString &  aFileName,
BOARD aAppendToMe = nullptr,
const STRING_UTF8_MAP aProperties = nullptr,
PROJECT aProject = nullptr,
PROGRESS_REPORTER aProgressReporter = nullptr 
)
static

Find the requested PLUGIN and if found, calls the PLUGIN::LoadBoard() function on it using the arguments passed to this function.

After the PLUGIN::LoadBoard() function returns, the PLUGIN is Released() as part of this call.

Parameters
aFileTypeis the PCB_FILE_T of file to load.
aFileNameis the name of the file to load.
aAppendToMeis an existing BOARD to append to, use NULL if fresh board load is wanted.
aPropertiesis an associative array that allows the caller to pass additional tuning parameters to the PLUGIN.
aProjectis the optional PROJECT object primarily used by third party importers.
Returns
the loaded BOARD object. The caller owns it an it will never NULL because exception thrown if error.
Exceptions
IO_ERRORif the PLUGIN cannot be found, file cannot be found, or file cannot be loaded.

Definition at line 164 of file io_mgr.cpp.

References FMT_NOTFOUND, PLUGIN::LoadBoard(), PluginFind(), ShowType(), and THROW_IO_ERROR.

Referenced by LoadBoard().

◆ PluginFind()

PLUGIN * IO_MGR::PluginFind ( PCB_FILE_T  aFileType)
static

Return a PLUGIN which the caller can use to import, export, save, or load design documents.

The returned PLUGIN, may be reference counted, so please call PluginRelease() when you are done using the returned PLUGIN. It may or may not be code running from a DLL/DSO.

Note
The caller owns the returned object and must call PluginRelease when done using it.
Parameters
aFileTypeis from PCB_FILE_T and tells which plugin to find.
Returns
the plug in corresponding to aFileType or NULL if not found.

Definition at line 63 of file io_mgr.cpp.

References IO_MGR::PLUGIN_REGISTRY::Create(), and IO_MGR::PLUGIN_REGISTRY::Instance().

Referenced by PCB_CONTROL::AppendBoardFromFile(), BOOST_AUTO_TEST_CASE(), PANEL_FP_LIB_TABLE::convertLibrary(), PCB_BASE_EDIT_FRAME::createNewLibrary(), PCB_CONTROL::DdAppendBoard(), PCB_EDIT_FRAME::ExportFootprintsToLibrary(), FP_LIB_TABLE::FindRow(), FOOTPRINT_EDIT_FRAME::ImportFootprint(), Load(), DIALOG_BOARD_SETUP::onAuxiliaryAction(), PCB_EDIT_FRAME::OpenProjectFiles(), FP_GRID_TRICKS::optionsEditor(), Save(), FOOTPRINT_EDIT_FRAME::SaveLibraryAs(), PCB_EDIT_FRAME::SavePcbCopy(), and PCB_EDIT_FRAME::SavePcbFile().

◆ PluginRelease()

void IO_MGR::PluginRelease ( PLUGIN aPlugin)
static

Release a PLUGIN back to the system and may cause it to be unloaded from memory.

Parameters
aPluginis the one to be released, and which is no longer usable after calling this.

Definition at line 72 of file io_mgr.cpp.

Referenced by PLUGIN::RELEASER::release().

◆ Save()

void IO_MGR::Save ( PCB_FILE_T  aFileType,
const wxString &  aFileName,
BOARD aBoard,
const STRING_UTF8_MAP aProperties = nullptr 
)
static

Write either a full aBoard to a storage file in a format that this implementation knows about, or it can be used to write a portion ofaBoard to a special kind of export file.

Parameters
aFileTypeis the PCB_FILE_T of file to save.
aFileNameis the name of a file to save to on disk.
aBoardis the BOARD document (data tree) to save or export to disk.
aBoardis the in memory document tree from which to extract information when writing to aFileName. The caller continues to own the BOARD, and the plugin should refrain from modifying the BOARD if possible.
aPropertiesis an associative array that can be used to tell the saver how to save the file, because it can take any number of additional named tuning arguments that the plugin is known to support. The caller continues to own this object (plugin may not delete it), and plugins should expect it to be optionally NULL.
Exceptions
IO_ERRORif there is a problem saving or exporting.

Definition at line 180 of file io_mgr.cpp.

References FMT_NOTFOUND, PluginFind(), PLUGIN::SaveBoard(), ShowType(), and THROW_IO_ERROR.

Referenced by SaveBoard().

◆ ShowType()

const wxString IO_MGR::ShowType ( PCB_FILE_T  aFileType)
static

The documentation for this class was generated from the following files: