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.

174 lines
6.0 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-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. #include <io_mgr.h>
  25. #include <properties.h>
  26. #define FMT_UNIMPLEMENTED _( "Plugin \"%s\" does not implement the \"%s\" function." )
  27. /**
  28. * Function not_implemented
  29. * throws 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().GetData(),
  38. wxString::FromUTF8( aCaller ).GetData() ) );
  39. }
  40. BOARD* PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, const PROPERTIES* aProperties )
  41. {
  42. not_implemented( this, __FUNCTION__ );
  43. return NULL;
  44. }
  45. void PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, const PROPERTIES* aProperties )
  46. {
  47. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  48. not_implemented( this, __FUNCTION__ );
  49. }
  50. void PLUGIN::FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibraryPath,
  51. bool aBestEfforts, const PROPERTIES* 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::PrefetchLib( const wxString& aLibraryPath, const PROPERTIES* aProperties )
  57. {
  58. (void) aLibraryPath;
  59. (void) aProperties;
  60. }
  61. const MODULE* PLUGIN::GetEnumeratedFootprint( const wxString& aLibraryPath,
  62. const wxString& aFootprintName,
  63. const PROPERTIES* aProperties )
  64. {
  65. // default implementation
  66. return FootprintLoad( aLibraryPath, aFootprintName, aProperties );
  67. }
  68. bool PLUGIN::FootprintExists( const wxString& aLibraryPath, const wxString& aFootprintName,
  69. const PROPERTIES* aProperties )
  70. {
  71. // default implementation
  72. return FootprintLoad( aLibraryPath, aFootprintName, aProperties ) != nullptr;
  73. }
  74. MODULE* PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
  75. const PROPERTIES* aProperties )
  76. {
  77. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  78. not_implemented( this, __FUNCTION__ );
  79. return NULL;
  80. }
  81. void PLUGIN::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootprint,
  82. const PROPERTIES* aProperties )
  83. {
  84. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  85. not_implemented( this, __FUNCTION__ );
  86. }
  87. void PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
  88. const PROPERTIES* aProperties )
  89. {
  90. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  91. not_implemented( this, __FUNCTION__ );
  92. }
  93. void PLUGIN::FootprintLibCreate( const wxString& aLibraryPath, const PROPERTIES* aProperties )
  94. {
  95. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  96. not_implemented( this, __FUNCTION__ );
  97. }
  98. bool PLUGIN::FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties )
  99. {
  100. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  101. not_implemented( this, __FUNCTION__ );
  102. return false;
  103. }
  104. bool PLUGIN::IsFootprintLibWritable( const wxString& aLibraryPath )
  105. {
  106. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  107. not_implemented( this, __FUNCTION__ );
  108. return false;
  109. }
  110. void PLUGIN::FootprintLibOptions( PROPERTIES* aListToAppendTo ) const
  111. {
  112. // disable all these in another couple of months, after everyone has seen them:
  113. #if 1
  114. (*aListToAppendTo)["debug_level"] = UTF8( _(
  115. "Enable <b>debug</b> logging for Footprint*() functions in this PLUGIN."
  116. ));
  117. (*aListToAppendTo)["read_filter_regex"] = UTF8( _(
  118. "Regular expression <b>footprint name</b> filter."
  119. ));
  120. (*aListToAppendTo)["enable_transaction_logging"] = UTF8( _(
  121. "Enable transaction logging. The mere presence of this option turns on the "
  122. "logging, no need to set a Value."
  123. ));
  124. (*aListToAppendTo)["username"] = UTF8( _(
  125. "User name for <b>login</b> to some special library server."
  126. ));
  127. (*aListToAppendTo)["password"] = UTF8( _(
  128. "Password for <b>login</b> to some special library server."
  129. ));
  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( _(
  135. "Enter the python module which implements the PLUGIN::Footprint*() functions."
  136. ));
  137. #endif
  138. }