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.

183 lines
6.2 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2016 CERN
  5. * Copyright (C) 2016-2021 KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * @author Wayne Stambaugh <stambaughw@gmail.com>
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version 2
  12. * of the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program. If not, see <http://www.gnu.org/licenses/>.
  21. */
  22. #include <string_utf8_map.h>
  23. #include <sch_io_mgr.h>
  24. #include <wx/translation.h>
  25. #define FMT_UNIMPLEMENTED "Plugin \"%s\" does not implement the \"%s\" function."
  26. /**
  27. * Function not_implemented
  28. * throws an IO_ERROR and complains of an API function not being implemented.
  29. *
  30. * @param aPlugin is a SCH_PLUGIN instance
  31. * @param aCaller is the name of the unimplemented API function.
  32. */
  33. static void not_implemented( const SCH_PLUGIN* aPlugin, const char* aCaller )
  34. {
  35. THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED,
  36. aPlugin->GetName().GetData(),
  37. wxString::FromUTF8( aCaller ).GetData() ) );
  38. }
  39. void SCH_PLUGIN::SaveLibrary( const wxString& aFileName, const STRING_UTF8_MAP* aProperties )
  40. {
  41. not_implemented( this, __FUNCTION__ );
  42. }
  43. SCH_SHEET* SCH_PLUGIN::Load( const wxString& aFileName, SCHEMATIC* aSchematic,
  44. SCH_SHEET* aAppendToMe, const STRING_UTF8_MAP* aProperties )
  45. {
  46. not_implemented( this, __FUNCTION__ );
  47. return nullptr;
  48. }
  49. void SCH_PLUGIN::Save( const wxString& aFileName, SCH_SHEET* aSheet, SCHEMATIC* aSchematic,
  50. const STRING_UTF8_MAP* aProperties )
  51. {
  52. // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
  53. not_implemented( this, __FUNCTION__ );
  54. }
  55. void SCH_PLUGIN::EnumerateSymbolLib( wxArrayString& aAliasNameList,
  56. const wxString& aLibraryPath,
  57. const STRING_UTF8_MAP* aProperties )
  58. {
  59. // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
  60. not_implemented( this, __FUNCTION__ );
  61. }
  62. void SCH_PLUGIN::EnumerateSymbolLib( std::vector<LIB_SYMBOL*>& aSymbolList,
  63. const wxString& aLibraryPath,
  64. const STRING_UTF8_MAP* aProperties )
  65. {
  66. // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
  67. not_implemented( this, __FUNCTION__ );
  68. }
  69. LIB_SYMBOL* SCH_PLUGIN::LoadSymbol( const wxString& aLibraryPath, const wxString& aSymbolName,
  70. const STRING_UTF8_MAP* aProperties )
  71. {
  72. // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
  73. not_implemented( this, __FUNCTION__ );
  74. return nullptr;
  75. }
  76. void SCH_PLUGIN::SaveSymbol( const wxString& aLibraryPath, const LIB_SYMBOL* aSymbol,
  77. const STRING_UTF8_MAP* aProperties )
  78. {
  79. // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
  80. not_implemented( this, __FUNCTION__ );
  81. }
  82. void SCH_PLUGIN::DeleteSymbol( const wxString& aLibraryPath, const wxString& aSymbolName,
  83. const STRING_UTF8_MAP* aProperties )
  84. {
  85. // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
  86. not_implemented( this, __FUNCTION__ );
  87. }
  88. void SCH_PLUGIN::CreateSymbolLib( const wxString& aLibraryPath, const STRING_UTF8_MAP* aProperties )
  89. {
  90. // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
  91. not_implemented( this, __FUNCTION__ );
  92. }
  93. bool SCH_PLUGIN::DeleteSymbolLib( const wxString& aLibraryPath, const STRING_UTF8_MAP* aProperties )
  94. {
  95. // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
  96. not_implemented( this, __FUNCTION__ );
  97. return false;
  98. }
  99. bool SCH_PLUGIN::IsSymbolLibWritable( const wxString& aLibraryPath )
  100. {
  101. // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
  102. not_implemented( this, __FUNCTION__ );
  103. return false;
  104. }
  105. void SCH_PLUGIN::SymbolLibOptions( STRING_UTF8_MAP* aListToAppendTo ) const
  106. {
  107. // disable all these in another couple of months, after everyone has seen them:
  108. #if 1
  109. (*aListToAppendTo)["debug_level"] = UTF8( _(
  110. "Enable <b>debug</b> logging for Symbol*() functions in this SCH_PLUGIN."
  111. ) );
  112. (*aListToAppendTo)["read_filter_regex"] = UTF8( _(
  113. "Regular expression <b>symbol name</b> filter."
  114. ) );
  115. (*aListToAppendTo)["enable_transaction_logging"] = UTF8( _(
  116. "Enable transaction logging. The mere presence of this option turns on the "
  117. "logging, no need to set a Value."
  118. ) );
  119. (*aListToAppendTo)["username"] = UTF8( _(
  120. "User name for <b>login</b> to some special library server."
  121. ) );
  122. (*aListToAppendTo)["password"] = UTF8( _(
  123. "Password for <b>login</b> to some special library server."
  124. ) );
  125. #endif
  126. #if 1
  127. // Suitable for a C++ to python SCH_PLUGIN::Footprint*() adapter, move it to the adapter
  128. // if and when implemented.
  129. (*aListToAppendTo)["python_symbol_plugin"] = UTF8( _(
  130. "Enter the python symbol which implements the SCH_PLUGIN::Symbol*() functions."
  131. ) );
  132. #endif
  133. }
  134. bool SCH_PLUGIN::CheckHeader( const wxString& aFileName )
  135. {
  136. // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
  137. not_implemented( this, __FUNCTION__ );
  138. return false;
  139. }
  140. const wxString& SCH_PLUGIN::GetError() const
  141. {
  142. // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
  143. not_implemented( this, __FUNCTION__ );
  144. static wxString error;
  145. return error;
  146. }