KiCad PCB EDA Suite
SCH_IO_MGR Class Reference

SCH_IO_MGR is a factory which returns an instance of a SCH_PLUGIN. More...

#include <sch_io_mgr.h>

Public Member Functions

 DEFINE_ENUM_VECTOR (SCH_FILE_T, { SCH_LEGACY, SCH_KICAD, SCH_ALTIUM, SCH_CADSTAR_ARCHIVE, SCH_EAGLE, SCH_FILE_UNKNOWN }) APIEXPORT static SCH_PLUGIN *FindPlugin(SCH_FILE_T aFileType)
 A set of file types that the SCH_IO_MGR knows about, and for which there has been a plugin written. More...
 

Static Public Member Functions

static void ReleasePlugin (SCH_PLUGIN *aPlugin)
 Release a SCH_PLUGIN back to the system, and may cause it to be unloaded from memory. More...
 
static const wxString ShowType (SCH_FILE_T aFileType)
 Return a brief name for a plugin, given aFileType enum. More...
 
static SCH_FILE_T EnumFromStr (const wxString &aFileType)
 Return the #SCH_FILE_T from the corresponding plugin type name: "kicad", "legacy", etc. More...
 
static const wxString GetFileExtension (SCH_FILE_T aFileType)
 Return the schematic file extension for aFileType. More...
 
static const wxString GetLibraryFileExtension (SCH_FILE_T aFileType)
 Return the symbol library file extension (if any) for aFileType. More...
 
static SCH_FILE_T GuessPluginTypeFromLibPath (const wxString &aLibPath)
 Return a plugin type given a symbol library using the file extension of aLibPath. More...
 
static SCH_FILE_T GuessPluginTypeFromSchPath (const wxString &aSchematicPath)
 Return a plugin type given a schematic using the file extension of aSchematicPath. More...
 

Detailed Description

SCH_IO_MGR is a factory which returns an instance of a SCH_PLUGIN.

Definition at line 46 of file sch_io_mgr.h.

Member Function Documentation

◆ DEFINE_ENUM_VECTOR()

SCH_IO_MGR::DEFINE_ENUM_VECTOR ( SCH_FILE_T  ,
{ SCH_LEGACY, SCH_KICAD, SCH_ALTIUM, SCH_CADSTAR_ARCHIVE, SCH_EAGLE, SCH_FILE_UNKNOWN }   
)

A set of file types that the SCH_IO_MGR knows about, and for which there has been a plugin written.

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

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

Parameters
aFileTypeis from #SCH_FILE_T and tells which plugin to find.
Returns
the plugin corresponding to aFileType or NULL if not found. Caller owns the returned object, and must call PluginRelease when done using it.

◆ EnumFromStr()

SCH_IO_MGR::SCH_FILE_T SCH_IO_MGR::EnumFromStr ( const wxString &  aFileType)
static

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

Definition at line 116 of file sch_io_mgr.cpp.

117 {
118  // keep this function in sync with ShowType() relative to the
119  // text spellings. If you change the spellings, you will obsolete
120  // library tables, so don't do change, only additions are ok.
121 
122  if( aType == wxT( "Legacy" ) )
123  return SCH_LEGACY;
124  else if( aType == wxT( "KiCad" ) )
125  return SCH_KICAD;
126  else if( aType == wxT( "Altium" ) )
127  return SCH_ALTIUM;
128  else if( aType == wxT( "CADSTAR Schematic Archive" ) )
129  return SCH_CADSTAR_ARCHIVE;
130  else if( aType == wxT( "EAGLE" ) )
131  return SCH_EAGLE;
132 
133  // wxASSERT( blow up here )
134 
135  return SCH_FILE_T( -1 );
136 }

Referenced by SYMBOL_LIB_TABLE_ROW::SetType().

◆ GetFileExtension()

const wxString SCH_IO_MGR::GetFileExtension ( SCH_FILE_T  aFileType)
static

Return the schematic file extension for aFileType.

Parameters
aFileTypeis the #SCH_FILE_T type.
Returns
the file extension for aFileType or an empty string if aFileType is invalid.

Definition at line 139 of file sch_io_mgr.cpp.

140 {
141  wxString ext = wxEmptyString;
142  SCH_PLUGIN* plugin = FindPlugin( aFileType );
143 
144  if( plugin != NULL )
145  {
146  ext = plugin->GetFileExtension();
147  ReleasePlugin( plugin );
148  }
149 
150  return ext;
151 }
Base class that schematic file and library loading and saving plugins should derive from.
Definition: sch_io_mgr.h:153
#define NULL
virtual const wxString GetFileExtension() const =0
Returns the file extension for the SCH_PLUGIN.
static void ReleasePlugin(SCH_PLUGIN *aPlugin)
Release a SCH_PLUGIN back to the system, and may cause it to be unloaded from memory.
Definition: sch_io_mgr.cpp:77

References SCH_PLUGIN::GetFileExtension(), NULL, and ReleasePlugin().

Referenced by SCH_EDIT_FRAME::OnImportProject().

◆ GetLibraryFileExtension()

const wxString SCH_IO_MGR::GetLibraryFileExtension ( SCH_FILE_T  aFileType)
static

Return the symbol library file extension (if any) for aFileType.

Parameters
aFileTypeis the #SCH_FILE_T type.
Returns
the file extension for aFileType or an empty string if aFileType is invalid.

Definition at line 154 of file sch_io_mgr.cpp.

155 {
156  wxString ext = wxEmptyString;
157  SCH_PLUGIN* plugin = FindPlugin( aFileType );
158 
159  if( plugin != NULL )
160  {
161  ext = plugin->GetLibraryFileExtension();
162  ReleasePlugin( plugin );
163  }
164 
165  return ext;
166 }
virtual const wxString GetLibraryFileExtension() const =0
Return the library file extension for the SCH_PLUGIN object.
Base class that schematic file and library loading and saving plugins should derive from.
Definition: sch_io_mgr.h:153
#define NULL
static void ReleasePlugin(SCH_PLUGIN *aPlugin)
Release a SCH_PLUGIN back to the system, and may cause it to be unloaded from memory.
Definition: sch_io_mgr.cpp:77

References SCH_PLUGIN::GetLibraryFileExtension(), NULL, and ReleasePlugin().

Referenced by PANEL_SYM_LIB_TABLE::browseLibrariesHandler().

◆ GuessPluginTypeFromLibPath()

SCH_IO_MGR::SCH_FILE_T SCH_IO_MGR::GuessPluginTypeFromLibPath ( const wxString &  aLibPath)
static

Return a plugin type given a symbol library using the file extension of aLibPath.

Definition at line 169 of file sch_io_mgr.cpp.

170 {
171  SCH_FILE_T ret = SCH_KICAD; // default guess, unless detected otherwise.
172  wxFileName fn( aLibPath );
173 
174  if( fn.GetExt() == LegacySymbolLibFileExtension )
175  {
176  ret = SCH_LEGACY;
177  }
178  else if( fn.GetExt() == KiCadSymbolLibFileExtension )
179  {
180  ret = SCH_KICAD;
181  }
182 
183  return ret;
184 }
const std::string LegacySymbolLibFileExtension
const std::string KiCadSymbolLibFileExtension

References KiCadSymbolLibFileExtension, and LegacySymbolLibFileExtension.

Referenced by LIB_MANAGER::addLibrary(), LIB_EDIT_FRAME::ImportPart(), and LIB_EDIT_FRAME::saveLibrary().

◆ GuessPluginTypeFromSchPath()

SCH_IO_MGR::SCH_FILE_T SCH_IO_MGR::GuessPluginTypeFromSchPath ( const wxString &  aSchematicPath)
static

Return a plugin type given a schematic using the file extension of aSchematicPath.

Definition at line 187 of file sch_io_mgr.cpp.

188 {
189  SCH_FILE_T ret = SCH_KICAD; // default guess, unless detected otherwise.
190  wxFileName fn( aSchematicPath );
191 
192  if( fn.GetExt() == LegacySchematicFileExtension )
193  {
194  ret = SCH_LEGACY;
195  }
196  else if( fn.GetExt() == KiCadSchematicFileExtension )
197  {
198  ret = SCH_KICAD;
199  }
200 
201  return ret;
202 }
const std::string LegacySchematicFileExtension
const std::string KiCadSchematicFileExtension

References KiCadSchematicFileExtension, and LegacySchematicFileExtension.

Referenced by SCH_EDIT_FRAME::LoadSheetFromFile(), SCH_EDIT_FRAME::OpenProjectFiles(), and SCH_EDIT_FRAME::SaveEEFile().

◆ ReleasePlugin()

void SCH_IO_MGR::ReleasePlugin ( SCH_PLUGIN aPlugin)
static

Release a SCH_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 77 of file sch_io_mgr.cpp.

78 {
79  // This function is a place holder for a future point in time where
80  // the plugin is a DLL/DSO. It could do reference counting, and then
81  // unload the DLL/DSO when count goes to zero.
82 
83  delete aPlugin;
84 }

Referenced by GetFileExtension(), GetLibraryFileExtension(), and SCH_PLUGIN::SCH_PLUGIN_RELEASER::release().

◆ ShowType()

const wxString SCH_IO_MGR::ShowType ( SCH_FILE_T  aFileType)
static

Return a brief name for a plugin, given aFileType enum.

Definition at line 87 of file sch_io_mgr.cpp.

88 {
89  // keep this function in sync with EnumFromStr() relative to the
90  // text spellings. If you change the spellings, you will obsolete
91  // library tables, so don't do change, only additions are ok.
92 
93  switch( aType )
94  {
95  default:
96  return wxString::Format( _( "Unknown SCH_FILE_T value: %d" ), aType );
97 
98  case SCH_LEGACY:
99  return wxString( wxT( "Legacy" ) );
100 
101  case SCH_KICAD:
102  return wxString( wxT( "KiCad" ) );
103 
104  case SCH_ALTIUM:
105  return wxString( wxT( "Altium" ) );
106 
107  case SCH_CADSTAR_ARCHIVE:
108  return wxString( wxT( "CADSTAR Schematic Archive" ) );
109 
110  case SCH_EAGLE:
111  return wxString( wxT( "EAGLE" ) );
112  }
113 }
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:201
#define _(s)
Definition: 3d_actions.cpp:33

References _, and Format().

Referenced by LIB_MANAGER::addLibrary(), PANEL_SYM_LIB_TABLE::browseLibrariesHandler(), DIALOG_SYMBOL_REMAP::createProjectSymbolLibTable(), SYMBOL_LIB_TABLE_ROW::GetType(), and PANEL_SYM_LIB_TABLE::PANEL_SYM_LIB_TABLE().


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