You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

477 lines
18 KiB

++PCBNew * Removed Pcb_Frame argument from BOARD() constructor, since it precludes having a BOARD being edited by more than one editor, it was a bad design. And this meant removing m_PcbFrame from BOARD. * removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame * Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp * added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance * a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed, such as dialog_mask_clearance, dialog_drc, etc. * Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it with build_version.h's #define BOARD_FILE_VERSION, although there may be a better place for this constant. * Made the public functions in PARAM_CFG_ARRAY be type const. void SaveParam(..) const and void ReadParam(..) const * PARAM_CFG_BASE now has virtual destructor since we have various way of destroying the derived class and boost::ptr_vector must be told about this. * Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use an automatic PARAM_CFG_ARRAY which is on the stack.\ * PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array, since it has to access the current BOARD and the BOARD can change. Remember BOARD_DESIGN_SETTINGS are now in the BOARD. * Made the m_BoundingBox member private, this was a brutally hard task, and indicative of the lack of commitment to accessors and object oriented design on the part of KiCad developers. We must do better. Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox(). * Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
14 years ago
++PCBNew * Removed Pcb_Frame argument from BOARD() constructor, since it precludes having a BOARD being edited by more than one editor, it was a bad design. And this meant removing m_PcbFrame from BOARD. * removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame * Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp * added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance * a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed, such as dialog_mask_clearance, dialog_drc, etc. * Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it with build_version.h's #define BOARD_FILE_VERSION, although there may be a better place for this constant. * Made the public functions in PARAM_CFG_ARRAY be type const. void SaveParam(..) const and void ReadParam(..) const * PARAM_CFG_BASE now has virtual destructor since we have various way of destroying the derived class and boost::ptr_vector must be told about this. * Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use an automatic PARAM_CFG_ARRAY which is on the stack.\ * PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array, since it has to access the current BOARD and the BOARD can change. Remember BOARD_DESIGN_SETTINGS are now in the BOARD. * Made the m_BoundingBox member private, this was a brutally hard task, and indicative of the lack of commitment to accessors and object oriented design on the part of KiCad developers. We must do better. Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox(). * Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
14 years ago
++PCBNew * Removed Pcb_Frame argument from BOARD() constructor, since it precludes having a BOARD being edited by more than one editor, it was a bad design. And this meant removing m_PcbFrame from BOARD. * removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame * Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp * added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance * a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed, such as dialog_mask_clearance, dialog_drc, etc. * Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it with build_version.h's #define BOARD_FILE_VERSION, although there may be a better place for this constant. * Made the public functions in PARAM_CFG_ARRAY be type const. void SaveParam(..) const and void ReadParam(..) const * PARAM_CFG_BASE now has virtual destructor since we have various way of destroying the derived class and boost::ptr_vector must be told about this. * Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use an automatic PARAM_CFG_ARRAY which is on the stack.\ * PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array, since it has to access the current BOARD and the BOARD can change. Remember BOARD_DESIGN_SETTINGS are now in the BOARD. * Made the m_BoundingBox member private, this was a brutally hard task, and indicative of the lack of commitment to accessors and object oriented design on the part of KiCad developers. We must do better. Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox(). * Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
14 years ago
++PCBNew * Removed Pcb_Frame argument from BOARD() constructor, since it precludes having a BOARD being edited by more than one editor, it was a bad design. And this meant removing m_PcbFrame from BOARD. * removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame * Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp * added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance * a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed, such as dialog_mask_clearance, dialog_drc, etc. * Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it with build_version.h's #define BOARD_FILE_VERSION, although there may be a better place for this constant. * Made the public functions in PARAM_CFG_ARRAY be type const. void SaveParam(..) const and void ReadParam(..) const * PARAM_CFG_BASE now has virtual destructor since we have various way of destroying the derived class and boost::ptr_vector must be told about this. * Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use an automatic PARAM_CFG_ARRAY which is on the stack.\ * PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array, since it has to access the current BOARD and the BOARD can change. Remember BOARD_DESIGN_SETTINGS are now in the BOARD. * Made the m_BoundingBox member private, this was a brutally hard task, and indicative of the lack of commitment to accessors and object oriented design on the part of KiCad developers. We must do better. Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox(). * Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
14 years ago
++PCBNew * Removed Pcb_Frame argument from BOARD() constructor, since it precludes having a BOARD being edited by more than one editor, it was a bad design. And this meant removing m_PcbFrame from BOARD. * removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame * Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp * added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance * a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed, such as dialog_mask_clearance, dialog_drc, etc. * Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it with build_version.h's #define BOARD_FILE_VERSION, although there may be a better place for this constant. * Made the public functions in PARAM_CFG_ARRAY be type const. void SaveParam(..) const and void ReadParam(..) const * PARAM_CFG_BASE now has virtual destructor since we have various way of destroying the derived class and boost::ptr_vector must be told about this. * Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use an automatic PARAM_CFG_ARRAY which is on the stack.\ * PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array, since it has to access the current BOARD and the BOARD can change. Remember BOARD_DESIGN_SETTINGS are now in the BOARD. * Made the m_BoundingBox member private, this was a brutally hard task, and indicative of the lack of commitment to accessors and object oriented design on the part of KiCad developers. We must do better. Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox(). * Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
14 years ago
++PCBNew * Removed Pcb_Frame argument from BOARD() constructor, since it precludes having a BOARD being edited by more than one editor, it was a bad design. And this meant removing m_PcbFrame from BOARD. * removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame * Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp * added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance * a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed, such as dialog_mask_clearance, dialog_drc, etc. * Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it with build_version.h's #define BOARD_FILE_VERSION, although there may be a better place for this constant. * Made the public functions in PARAM_CFG_ARRAY be type const. void SaveParam(..) const and void ReadParam(..) const * PARAM_CFG_BASE now has virtual destructor since we have various way of destroying the derived class and boost::ptr_vector must be told about this. * Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use an automatic PARAM_CFG_ARRAY which is on the stack.\ * PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array, since it has to access the current BOARD and the BOARD can change. Remember BOARD_DESIGN_SETTINGS are now in the BOARD. * Made the m_BoundingBox member private, this was a brutally hard task, and indicative of the lack of commitment to accessors and object oriented design on the part of KiCad developers. We must do better. Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox(). * Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
14 years ago
  1. #ifndef IO_MGR_H_
  2. #define IO_MGR_H_
  3. /*
  4. * This program source code file is part of KICAD, a free EDA CAD application.
  5. *
  6. * Copyright (C) 2011-2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  7. * Copyright (C) 2011 Kicad Developers, see change_log.txt for contributors.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, you may find one here:
  21. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  22. * or you may search the http://www.gnu.org website for the version 2 license,
  23. * or you may write to the Free Software Foundation, Inc.,
  24. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  25. */
  26. #include <richio.h>
  27. #include <map>
  28. class BOARD;
  29. class PLUGIN;
  30. class MODULE;
  31. /**
  32. * Class PROPERTIES
  33. * is a name/value tuple with unique names and optional values. The names
  34. * may be iterated alphabetically.
  35. */
  36. class PROPERTIES : public std::map< std::string, std::string >
  37. {
  38. // alphabetical tuple of name and value hereby defined.
  39. };
  40. /**
  41. * Class IO_MGR
  42. * is a factory which returns an instance of a PLUGIN.
  43. */
  44. class IO_MGR
  45. {
  46. public:
  47. /**
  48. * Enum PCB_FILE_T
  49. * is a set of file types that the IO_MGR knows about, and for which there
  50. * has been a plugin written.
  51. */
  52. enum PCB_FILE_T
  53. {
  54. LEGACY, ///< Legacy Pcbnew file formats prior to s-expression.
  55. KICAD, ///< S-expression Pcbnew file format.
  56. EAGLE,
  57. PCAD,
  58. GEDA_PCB, ///< Geda PCB file formats.
  59. GITHUB, ///< Read only http://github.com repo holding pretty footprints
  60. // add your type here.
  61. // ALTIUM,
  62. // etc.
  63. };
  64. /**
  65. * Function PluginFind
  66. * returns a PLUGIN which the caller can use to import, export, save, or load
  67. * design documents. The returned PLUGIN, may be reference counted, so please
  68. * call PluginRelease() when you are done using the returned PLUGIN. It may or
  69. * may not be code running from a DLL/DSO.
  70. *
  71. * @param aFileType is from PCB_FILE_T and tells which plugin to find.
  72. *
  73. * @return PLUGIN* - the plugin corresponding to aFileType or NULL if not found.
  74. * Caller owns the returned object, and must call PluginRelease when done using it.
  75. */
  76. static PLUGIN* PluginFind( PCB_FILE_T aFileType );
  77. /**
  78. * Function PluginRelease
  79. * releases a PLUGIN back to the system, and may cause it to be unloaded from memory.
  80. *
  81. * @param aPlugin is the one to be released, and which is no longer usable
  82. * after calling this.
  83. */
  84. static void PluginRelease( PLUGIN* aPlugin );
  85. /**
  86. * Function ShowType
  87. * returns a brief name for a plugin, given aFileType enum.
  88. */
  89. static const wxString ShowType( PCB_FILE_T aFileType );
  90. /**
  91. * Function EnumFromStr
  92. * returns the PCB_FILE_T from the corresponding plugin type name: "kicad", "legacy", etc.
  93. */
  94. static PCB_FILE_T EnumFromStr( const wxString& aFileType );
  95. /**
  96. * Function GetFileExtension
  97. * returns the file extension for \a aFileType.
  98. *
  99. * @param aFileType The #PCB_FILE_T type.
  100. * @return A wxString object containing the file extension for \a aFileType or an empty
  101. * string if \a aFileType is invalid.
  102. */
  103. static const wxString GetFileExtension( PCB_FILE_T aFileType );
  104. /**
  105. * Function GuessPluginTypeFromLibPath
  106. * returns a plugin type given a footprint library's libPath.
  107. */
  108. static PCB_FILE_T GuessPluginTypeFromLibPath( const wxString& aLibPath );
  109. /**
  110. * Function Load
  111. * finds the requested PLUGIN and if found, calls the PLUGIN->Load(..) funtion
  112. * on it using the arguments passed to this function. After the PLUGIN->Load()
  113. * function returns, the PLUGIN is Released() as part of this call.
  114. *
  115. * @param aFileType is the PCB_FILE_T of file to load.
  116. *
  117. * @param aFileName is the name of the file to load.
  118. *
  119. * @param aAppendToMe is an existing BOARD to append to, use NULL if fresh
  120. * board load is wanted.
  121. *
  122. * @param aProperties is an associative array that allows the caller to
  123. * pass additional tuning parameters to the PLUGIN.
  124. *
  125. * @return BOARD* - caller owns it, never NULL because exception thrown if error.
  126. *
  127. * @throw IO_ERROR if the PLUGIN cannot be found, file cannot be found,
  128. * or file cannot be loaded.
  129. */
  130. static BOARD* Load( PCB_FILE_T aFileType, const wxString& aFileName,
  131. BOARD* aAppendToMe = NULL, const PROPERTIES* aProperties = NULL );
  132. /**
  133. * Function Save
  134. * will write either a full aBoard to a storage file in a format that this
  135. * implementation knows about, or it can be used to write a portion of
  136. * aBoard to a special kind of export file.
  137. *
  138. * @param aFileType is the PCB_FILE_T of file to save.
  139. *
  140. * @param aFileName is the name of a file to save to on disk.
  141. * @param aBoard is the BOARD document (data tree) to save or export to disk.
  142. *
  143. * @param aBoard is the in memory document tree from which to extract information
  144. * when writing to \a aFileName. The caller continues to own the BOARD, and
  145. * the plugin should refrain from modifying the BOARD if possible.
  146. *
  147. * @param aProperties is an associative array that can be used to tell the
  148. * saver how to save the file, because it can take any number of
  149. * additional named tuning arguments that the plugin is known to support.
  150. * The caller continues to own this object (plugin may not delete it), and
  151. * plugins should expect it to be optionally NULL.
  152. *
  153. * @throw IO_ERROR if there is a problem saving or exporting.
  154. */
  155. static void Save( PCB_FILE_T aFileType, const wxString& aFileName,
  156. BOARD* aBoard, const PROPERTIES* aProperties = NULL );
  157. };
  158. /**
  159. * Class PLUGIN
  160. * is a base class that BOARD loading and saving plugins should derive from.
  161. * Implementations can provide either Load() or Save() functions, or both.
  162. * PLUGINs throw exceptions, so it is best that you wrap your calls to these
  163. * functions in a try catch block. Plugins throw exceptions because it is illegal
  164. * for them to have any user interface calls in them whatsoever, i.e. no windowing
  165. * or screen printing at all.
  166. *
  167. * <pre>
  168. * try
  169. * {
  170. * IO_MGR::Load(...);
  171. * or
  172. * IO_MGR::Save(...);
  173. * }
  174. * catch( IO_ERROR ioe )
  175. * {
  176. * // grab text from ioe, show in error window.
  177. * }
  178. * </pre>
  179. */
  180. class PLUGIN
  181. {
  182. public:
  183. //-----<PUBLIC PLUGIN API>-------------------------------------------------
  184. /**
  185. * Function PluginName
  186. * returns a brief hard coded name for this PLUGIN.
  187. */
  188. virtual const wxString& PluginName() const = 0;
  189. /**
  190. * Function GetFileExtension
  191. * returns the file extension for the PLUGIN.
  192. */
  193. virtual const wxString& GetFileExtension() const = 0;
  194. /**
  195. * Function Load
  196. * loads information from some input file format that this PLUGIN implementation
  197. * knows about, into either a new BOARD or an existing one. This may be used to load an
  198. * entire new BOARD, or to augment an existing one if @a aAppendToMe is not NULL.
  199. *
  200. * @param aFileName is the name of the file to use as input and may be foreign in
  201. * nature or native in nature.
  202. *
  203. * @param aAppendToMe is an existing BOARD to append to, but if NULL then
  204. * this means "do not append, rather load anew".
  205. *
  206. * @param aProperties is an associative array that can be used to tell the
  207. * loader how to load the file, because it can take any number of
  208. * additional named arguments that the plugin is known to support. These are
  209. * tuning parameters for the import or load. The caller continues to own
  210. * this object (plugin may not delete it), and plugins should expect it to
  211. * be optionally NULL.
  212. *
  213. * @return BOARD* - the successfully loaded board, or the same one as aAppendToMe
  214. * if aAppendToMe was not NULL, and caller owns it.
  215. *
  216. * @throw IO_ERROR if there is a problem loading, and its contents should
  217. * say what went wrong, using line number and character offsets of the
  218. * input file if possible.
  219. */
  220. virtual BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe,
  221. const PROPERTIES* aProperties = NULL );
  222. /**
  223. * Function Save
  224. * will write @a aBoard to a storage file in a format that this
  225. * PLUGIN implementation knows about, or it can be used to write a portion of
  226. * aBoard to a special kind of export file.
  227. *
  228. * @param aFileName is the name of a file to save to on disk.
  229. *
  230. * @param aBoard is the class BOARD in memory document tree from which to
  231. * extract information when writing to \a aFileName. The caller continues to
  232. * own the BOARD, and the plugin should refrain from modifying the BOARD if possible.
  233. *
  234. * @param aProperties is an associative array that can be used to tell the
  235. * saver how to save the file, because it can take any number of
  236. * additional named tuning arguments that the plugin is known to support.
  237. * The caller continues to own this object (plugin may not delete it),
  238. * and plugins should expect it to be optionally NULL.
  239. *
  240. * @throw IO_ERROR if there is a problem saving or exporting.
  241. */
  242. virtual void Save( const wxString& aFileName, BOARD* aBoard,
  243. const PROPERTIES* aProperties = NULL );
  244. //-----<Footprint Stuff>-----------------------------
  245. /**
  246. * Function FootprintEnumerate
  247. * returns a list of footprint names contained within the library at @a aLibraryPath.
  248. *
  249. * @param aLibraryPath is a locator for the "library", usually a directory
  250. * or file containing several footprints.
  251. *
  252. * @param aProperties is an associative array that can be used to tell the
  253. * plugin how to access the library.
  254. * The caller continues to own this object (plugin may not delete it), and
  255. * plugins should expect it to be optionally NULL.
  256. *
  257. * @return wxArrayString - is the array of available footprint names inside
  258. * a library
  259. *
  260. * @throw IO_ERROR if the library cannot be found, or footprint cannot be loaded.
  261. */
  262. virtual wxArrayString FootprintEnumerate( const wxString& aLibraryPath,
  263. const PROPERTIES* aProperties = NULL );
  264. /**
  265. * Function FootprintLoad
  266. * loads a footprint having @a aFootprintName from the @a aLibraryPath containing
  267. * a library format that this PLUGIN knows about.
  268. *
  269. * @param aLibraryPath is a locator for the "library", usually a directory
  270. * or file containing several footprints.
  271. *
  272. * @param aFootprintName is the name of the footprint to load.
  273. *
  274. * @param aProperties is an associative array that can be used to tell the
  275. * loader implementation to do something special, because it can take any number of
  276. * additional named tuning arguments that the plugin is known to support.
  277. * The caller continues to own this object (plugin may not delete it), and
  278. * plugins should expect it to be optionally NULL.
  279. *
  280. * @return MODULE* - if found caller owns it, else NULL if not found.
  281. *
  282. * @throw IO_ERROR if the library cannot be found or read. No exception
  283. * is thrown in the case where aFootprintName cannot be found.
  284. */
  285. virtual MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
  286. const PROPERTIES* aProperties = NULL );
  287. /**
  288. * Function FootprintSave
  289. * will write @a aModule to an existing library located at @a aLibraryPath.
  290. * If a footprint by the same name already exists, it is replaced.
  291. *
  292. * @param aLibraryPath is a locator for the "library", usually a directory
  293. * or file containing several footprints. This is where the footprint is
  294. * to be stored.
  295. *
  296. * @param aFootprint is what to store in the library. The caller continues
  297. * to own the footprint after this call.
  298. *
  299. * @param aProperties is an associative array that can be used to tell the
  300. * saver how to save the footprint, because it can take any number of
  301. * additional named tuning arguments that the plugin is known to support.
  302. * The caller continues to own this object (plugin may not delete it), and
  303. * plugins should expect it to be optionally NULL.
  304. *
  305. * @throw IO_ERROR if there is a problem saving.
  306. */
  307. virtual void FootprintSave( const wxString& aLibraryPath, const MODULE* aFootprint,
  308. const PROPERTIES* aProperties = NULL );
  309. /**
  310. * Function FootprintDelete
  311. * deletes the @a aFootprintName from the library at @a aLibraryPath.
  312. *
  313. * @param aLibraryPath is a locator for the "library", usually a directory
  314. * or file containing several footprints.
  315. *
  316. * @param aFootprintName is the name of a footprint to delete from the specified library.
  317. *
  318. * @param aProperties is an associative array that can be used to tell the
  319. * library create function anything special, because it can take any number of
  320. * additional named tuning arguments that the plugin is known to support.
  321. * The caller continues to own this object (plugin may not delete it), and
  322. * plugins should expect it to be optionally NULL.
  323. *
  324. * @throw IO_ERROR if there is a problem finding the footprint or the library, or deleting it.
  325. */
  326. virtual void FootprintDelete( const wxString& aLibraryPath,
  327. const wxString& aFootprintName, const PROPERTIES* aProperties = NULL );
  328. /**
  329. * Function FootprintLibCreate
  330. * creates a new empty footprint library at @a aLibraryPath empty. It is an
  331. * error to attempt to create an existing library or to attempt to create
  332. * on a "read only" location.
  333. *
  334. * @param aLibraryPath is a locator for the "library", usually a directory
  335. * or file which will contain footprints.
  336. *
  337. * @param aProperties is an associative array that can be used to tell the
  338. * library create function anything special, because it can take any number of
  339. * additional named tuning arguments that the plugin is known to support.
  340. * The caller continues to own this object (plugin may not delete it), and
  341. * plugins should expect it to be optionally NULL.
  342. *
  343. * @throw IO_ERROR if there is a problem finding the library, or creating it.
  344. */
  345. virtual void FootprintLibCreate( const wxString& aLibraryPath, const PROPERTIES* aProperties = NULL );
  346. /**
  347. * Function FootprintLibDelete
  348. * deletes an existing footprint library and returns true, or if library does not
  349. * exist returns false, or throws an exception if library exists but is read only or
  350. * cannot be deleted for some other reason.
  351. *
  352. * @param aLibraryPath is a locator for the "library", usually a directory
  353. * or file which will contain footprints.
  354. *
  355. * @param aProperties is an associative array that can be used to tell the
  356. * library delete implementation function anything special, because it can
  357. * take any number of additional named tuning arguments that the plugin is
  358. * known to support. The caller continues to own this object (plugin may
  359. * not delete it), and plugins should expect it to be optionally NULL.
  360. *
  361. * @return bool - true if library deleted, false if library did not exist.
  362. *
  363. * @throw IO_ERROR if there is a problem deleting an existing library.
  364. */
  365. virtual bool FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties = NULL );
  366. /**
  367. * Function IsFootprintLibWritable
  368. * returns true iff the library at @a aLibraryPath is writable. (Often
  369. * system libraries are read only because of where they are installed.)
  370. *
  371. * @throw IO_ERROR if no library at aLibraryPath exists.
  372. */
  373. virtual bool IsFootprintLibWritable( const wxString& aLibraryPath );
  374. //-----</PUBLIC PLUGIN API>------------------------------------------------
  375. /* The compiler writes the "zero argument" constructor for a PLUGIN
  376. automatically if you do not provide one. If you decide you need to
  377. provide a zero argument constructor of your own design, that is allowed.
  378. It must be public, and it is what the IO_MGR uses. Parameters may be
  379. passed into a PLUGIN via the PROPERTIES variable for any of the public
  380. API functions which take one.
  381. */
  382. virtual ~PLUGIN()
  383. {
  384. //printf( "~%s", __func__ );
  385. };
  386. /**
  387. * Class RELEASER
  388. * releases a PLUGIN in the context of a potential thrown exception, through
  389. * its destructor.
  390. */
  391. class RELEASER
  392. {
  393. PLUGIN* plugin;
  394. // private assignment operator so it's illegal
  395. RELEASER& operator=( RELEASER& aOther ) { return *this; }
  396. // private copy constructor so it's illegal
  397. RELEASER( const RELEASER& aOther ) {}
  398. public:
  399. RELEASER( PLUGIN* aPlugin = NULL ) :
  400. plugin( aPlugin )
  401. {
  402. }
  403. ~RELEASER()
  404. {
  405. if( plugin )
  406. release();
  407. }
  408. void release()
  409. {
  410. IO_MGR::PluginRelease( plugin );
  411. plugin = NULL;
  412. }
  413. void set( PLUGIN* aPlugin )
  414. {
  415. if( plugin )
  416. release();
  417. plugin = aPlugin;
  418. }
  419. operator PLUGIN* () const
  420. {
  421. return plugin;
  422. }
  423. PLUGIN* operator -> () const
  424. {
  425. return plugin;
  426. }
  427. };
  428. };
  429. #endif // IO_MGR_H_