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.

175 lines
6.6 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2011-2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  5. * Copyright (C) 2016-2020 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. #include <io_mgr.h>
  25. #include <string_utf8_map.h>
  26. #include <wx/translation.h>
  27. #define FMT_UNIMPLEMENTED wxT( "Plugin \"%s\" does not implement the \"%s\" function." )
  28. /**
  29. * Throw an #IO_ERROR and complains of an API function not being implemented.
  30. *
  31. * @param aPlugin is a #PLUGIN instance.
  32. * @param aCaller is the name of the unimplemented API function.
  33. */
  34. static void not_implemented( PLUGIN* aPlugin, const char* aCaller )
  35. {
  36. THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED,
  37. aPlugin->PluginName(),
  38. wxString::FromUTF8( aCaller ) ) );
  39. }
  40. BOARD* PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, const STRING_UTF8_MAP* aProperties,
  41. PROJECT* aProject, PROGRESS_REPORTER* aProgressReporter )
  42. {
  43. not_implemented( this, __FUNCTION__ );
  44. return nullptr;
  45. }
  46. std::vector<FOOTPRINT*> PLUGIN::GetImportedCachedLibraryFootprints()
  47. {
  48. not_implemented( this, __FUNCTION__ );
  49. return std::vector<FOOTPRINT*>();
  50. }
  51. void PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, const STRING_UTF8_MAP* aProperties )
  52. {
  53. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  54. not_implemented( this, __FUNCTION__ );
  55. }
  56. void PLUGIN::FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
  57. bool aBestEfforts, const STRING_UTF8_MAP* aProperties )
  58. {
  59. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  60. not_implemented( this, __FUNCTION__ );
  61. }
  62. void PLUGIN::PrefetchLib( const wxString&, const STRING_UTF8_MAP* )
  63. {
  64. }
  65. const FOOTPRINT* PLUGIN::GetEnumeratedFootprint( const wxString& aLibraryPath,
  66. const wxString& aFootprintName,
  67. const STRING_UTF8_MAP* aProperties )
  68. {
  69. // default implementation
  70. return FootprintLoad( aLibraryPath, aFootprintName, false, aProperties );
  71. }
  72. bool PLUGIN::FootprintExists( const wxString& aLibraryPath, const wxString& aFootprintName,
  73. const STRING_UTF8_MAP* aProperties )
  74. {
  75. // default implementation
  76. return FootprintLoad( aLibraryPath, aFootprintName, true, aProperties ) != nullptr;
  77. }
  78. FOOTPRINT* PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
  79. bool aKeepUUID, const STRING_UTF8_MAP* aProperties )
  80. {
  81. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  82. not_implemented( this, __FUNCTION__ );
  83. return nullptr;
  84. }
  85. void PLUGIN::FootprintSave( const wxString& aLibraryPath, const FOOTPRINT* aFootprint,
  86. const STRING_UTF8_MAP* aProperties )
  87. {
  88. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  89. not_implemented( this, __FUNCTION__ );
  90. }
  91. void PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
  92. const STRING_UTF8_MAP* aProperties )
  93. {
  94. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  95. not_implemented( this, __FUNCTION__ );
  96. }
  97. void PLUGIN::FootprintLibCreate( const wxString& aLibraryPath, const STRING_UTF8_MAP* aProperties )
  98. {
  99. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  100. not_implemented( this, __FUNCTION__ );
  101. }
  102. bool PLUGIN::FootprintLibDelete( const wxString& aLibraryPath, const STRING_UTF8_MAP* aProperties )
  103. {
  104. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  105. not_implemented( this, __FUNCTION__ );
  106. return false;
  107. }
  108. bool PLUGIN::IsFootprintLibWritable( const wxString& aLibraryPath )
  109. {
  110. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  111. not_implemented( this, __FUNCTION__ );
  112. return false;
  113. }
  114. void PLUGIN::FootprintLibOptions( STRING_UTF8_MAP* aListToAppendTo ) const
  115. {
  116. // disable all these in another couple of months, after everyone has seen them:
  117. #if 1
  118. (*aListToAppendTo)["debug_level"] = UTF8( _( "Enable <b>debug</b> logging for Footprint*() "
  119. "functions in this PLUGIN." ) );
  120. (*aListToAppendTo)["read_filter_regex"] = UTF8( _( "Regular expression <b>footprint name</b> "
  121. "filter." ) );
  122. (*aListToAppendTo)["enable_transaction_logging"] = UTF8( _( "Enable transaction logging. The "
  123. "mere presence of this option "
  124. "turns on the logging, no need to "
  125. "set a Value." ) );
  126. (*aListToAppendTo)["username"] = UTF8( _( "User name for <b>login</b> to some special library "
  127. "server." ) );
  128. (*aListToAppendTo)["password"] = UTF8( _( "Password for <b>login</b> to some special library "
  129. "server." ) );
  130. #endif
  131. #if 1
  132. // Suitable for a C++ to python PLUGIN::Footprint*() adapter, move it to the adapter
  133. // if and when implemented.
  134. (*aListToAppendTo)["python_footprint_plugin"] = UTF8( _( "Enter the python module which "
  135. "implements the PLUGIN::Footprint*() "
  136. "functions." ) );
  137. #endif
  138. }