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.

102 lines
3.3 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
  5. * Copyright (C) 1992-2012 KiCad Developers, see change_log.txt for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. /**
  25. * @file gpcb_plugin.cpp
  26. * @brief Geda PCB file plugin definition file.
  27. */
  28. #ifndef _GPCB_PLUGIN_H_
  29. #define _GPCB_PLUGIN_H_
  30. #include <io_mgr.h>
  31. #include <string>
  32. class GPCB_FPL_CACHE;
  33. /**
  34. * Class GPCB_PLUGIN
  35. * is a PLUGIN derivation for saving and loading Geda PCB files.
  36. *
  37. * @note This class is not thread safe, but it is re-entrant multiple times in sequence.
  38. * @note Currently only reading GPCB footprint files is implemented.
  39. */
  40. class GPCB_PLUGIN : public PLUGIN
  41. {
  42. friend class GPCB_FPL_CACHE;
  43. public:
  44. //-----<PLUGIN API>---------------------------------------------------------
  45. const wxString PluginName() const
  46. {
  47. return wxT( "Geda PCB" );
  48. }
  49. const wxString GetFileExtension() const
  50. {
  51. return wxT( "fp" );
  52. }
  53. wxArrayString FootprintEnumerate( const wxString& aLibraryPath,
  54. const PROPERTIES* aProperties = NULL);
  55. MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
  56. const PROPERTIES* aProperties = NULL );
  57. void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
  58. const PROPERTIES* aProperties = NULL );
  59. bool FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties = NULL );
  60. bool IsFootprintLibWritable( const wxString& aLibraryPath );
  61. //-----</PLUGIN API>--------------------------------------------------------
  62. GPCB_PLUGIN();
  63. GPCB_PLUGIN( int aControlFlags );
  64. ~GPCB_PLUGIN();
  65. protected:
  66. wxString m_error; ///< for throwing exceptions
  67. const PROPERTIES* m_props; ///< passed via Save() or Load(), no ownership, may be NULL.
  68. GPCB_FPL_CACHE* m_cache; ///< Footprint library cache.
  69. int m_ctl;
  70. LINE_READER* m_reader; ///< no ownership here.
  71. wxString m_filename; ///< for saves only, name is in m_reader for loads
  72. private:
  73. /// we only cache one footprint library for now, this determines which one.
  74. void cacheLib( const wxString& aLibraryPath, const wxString& aFootprintName = wxEmptyString );
  75. void init( const PROPERTIES* aProperties );
  76. };
  77. #endif // _GPCB_PLUGIN_H_