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.

166 lines
5.7 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. 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. MODULE* PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
  69. const PROPERTIES* aProperties )
  70. {
  71. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  72. not_implemented( this, __FUNCTION__ );
  73. return NULL;
  74. }
  75. void PLUGIN::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootprint,
  76. const PROPERTIES* aProperties )
  77. {
  78. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  79. not_implemented( this, __FUNCTION__ );
  80. }
  81. void PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
  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::FootprintLibCreate( const wxString& aLibraryPath, const PROPERTIES* aProperties )
  88. {
  89. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  90. not_implemented( this, __FUNCTION__ );
  91. }
  92. bool PLUGIN::FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties )
  93. {
  94. // not pure virtual so that plugins only have to implement subset of the PLUGIN interface.
  95. not_implemented( this, __FUNCTION__ );
  96. return false;
  97. }
  98. bool PLUGIN::IsFootprintLibWritable( const wxString& aLibraryPath )
  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. void PLUGIN::FootprintLibOptions( PROPERTIES* aListToAppendTo ) const
  105. {
  106. // disable all these in another couple of months, after everyone has seen them:
  107. #if 1
  108. (*aListToAppendTo)["debug_level"] = UTF8( _(
  109. "Enable <b>debug</b> logging for Footprint*() functions in this PLUGIN."
  110. ));
  111. (*aListToAppendTo)["read_filter_regex"] = UTF8( _(
  112. "Regular expression <b>footprint name</b> filter."
  113. ));
  114. (*aListToAppendTo)["enable_transaction_logging"] = UTF8( _(
  115. "Enable transaction logging. The mere presence of this option turns on the "
  116. "logging, no need to set a Value."
  117. ));
  118. (*aListToAppendTo)["username"] = UTF8( _(
  119. "User name for <b>login</b> to some special library server."
  120. ));
  121. (*aListToAppendTo)["password"] = UTF8( _(
  122. "Password for <b>login</b> to some special library server."
  123. ));
  124. #endif
  125. #if 1
  126. // Suitable for a C++ to python PLUGIN::Footprint*() adapter, move it to the adapter
  127. // if and when implemented.
  128. (*aListToAppendTo)["python_footprint_plugin"] = UTF8( _(
  129. "Enter the python module which implements the PLUGIN::Footprint*() functions."
  130. ));
  131. #endif
  132. }