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.

110 lines
3.7 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. * 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 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. const PROPERTIES* aProperties = NULL) override;
  55. MODULE* LoadEnumeratedFootprint( const wxString& aLibraryPath, const wxString& aFootprintName,
  56. const PROPERTIES* aProperties = NULL ) override;
  57. MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
  58. const PROPERTIES* aProperties = NULL ) override;
  59. void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
  60. const PROPERTIES* aProperties = NULL ) override;
  61. bool FootprintLibDelete( const wxString& aLibraryPath,
  62. const PROPERTIES* aProperties = NULL ) override;
  63. long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override;
  64. bool IsFootprintLibWritable( const wxString& aLibraryPath ) override;
  65. //-----</PLUGIN API>--------------------------------------------------------
  66. GPCB_PLUGIN();
  67. GPCB_PLUGIN( int aControlFlags );
  68. ~GPCB_PLUGIN();
  69. protected:
  70. wxString m_error; ///< for throwing exceptions
  71. const PROPERTIES* m_props; ///< passed via Save() or Load(), no ownership, may be NULL.
  72. GPCB_FPL_CACHE* m_cache; ///< Footprint library cache.
  73. int m_ctl;
  74. LINE_READER* m_reader; ///< no ownership here.
  75. wxString m_filename; ///< for saves only, name is in m_reader for loads
  76. private:
  77. void validateCache( const wxString& aLibraryPath, bool checkModified = true );
  78. MODULE* doLoadFootprint( const wxString& aLibraryPath, const wxString& aFootprintName,
  79. const PROPERTIES* aProperties, bool checkModified );
  80. void init( const PROPERTIES* aProperties );
  81. };
  82. #endif // _GPCB_PLUGIN_H_