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.

111 lines
3.8 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2012-2017 Wayne Stambaugh <stambaughw@verizon.net>
  5. * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.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. * 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 override
  46. {
  47. return wxT( "Geda PCB" );
  48. }
  49. const wxString GetFileExtension() const override
  50. {
  51. return wxT( "fp" );
  52. }
  53. void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
  54. bool aBestEfforts, const PROPERTIES* aProperties = NULL ) override;
  55. const MODULE* GetEnumeratedFootprint( const wxString& aLibraryPath,
  56. const wxString& aFootprintName,
  57. const PROPERTIES* aProperties = NULL ) override;
  58. MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
  59. const PROPERTIES* aProperties = NULL ) override;
  60. void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
  61. const PROPERTIES* aProperties = NULL ) override;
  62. bool FootprintLibDelete( const wxString& aLibraryPath,
  63. const PROPERTIES* aProperties = NULL ) override;
  64. long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override;
  65. bool IsFootprintLibWritable( const wxString& aLibraryPath ) override;
  66. //-----</PLUGIN API>--------------------------------------------------------
  67. GPCB_PLUGIN();
  68. GPCB_PLUGIN( int aControlFlags );
  69. ~GPCB_PLUGIN();
  70. protected:
  71. wxString m_error; ///< for throwing exceptions
  72. const PROPERTIES* m_props; ///< passed via Save() or Load(), no ownership, may be NULL.
  73. GPCB_FPL_CACHE* m_cache; ///< Footprint library cache.
  74. int m_ctl;
  75. LINE_READER* m_reader; ///< no ownership here.
  76. wxString m_filename; ///< for saves only, name is in m_reader for loads
  77. private:
  78. void validateCache( const wxString& aLibraryPath, bool checkModified = true );
  79. const MODULE* getFootprint( const wxString& aLibraryPath, const wxString& aFootprintName,
  80. const PROPERTIES* aProperties, bool checkModified );
  81. void init( const PROPERTIES* aProperties );
  82. };
  83. #endif // _GPCB_PLUGIN_H_