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.

199 lines
6.7 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-2017 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 <properties.h>
  23. #include <sch_io_mgr.h>
  24. #define FMT_UNIMPLEMENTED _( "Plugin \"%s\" does not implement the \"%s\" function." )
  25. /**
  26. * Function not_implemented
  27. * throws an IO_ERROR and complains of an API function not being implemented.
  28. *
  29. * @param aPlugin is a SCH_PLUGIN instance
  30. * @param aCaller is the name of the unimplemented API function.
  31. */
  32. static void not_implemented( const SCH_PLUGIN* aPlugin, const char* aCaller )
  33. {
  34. THROW_IO_ERROR( wxString::Format( FMT_UNIMPLEMENTED,
  35. aPlugin->GetName().GetData(),
  36. wxString::FromUTF8( aCaller ).GetData() ) );
  37. }
  38. void SCH_PLUGIN::SaveLibrary( const wxString& aFileName, const PROPERTIES* aProperties )
  39. {
  40. not_implemented( this, __FUNCTION__ );
  41. }
  42. SCH_SHEET* SCH_PLUGIN::Load( const wxString& aFileName, KIWAY* aKiway, SCH_SHEET* aAppendToMe,
  43. const PROPERTIES* aProperties )
  44. {
  45. not_implemented( this, __FUNCTION__ );
  46. return NULL;
  47. }
  48. void SCH_PLUGIN::Save( const wxString& aFileName, SCH_SCREEN* aSchematic, KIWAY* aKiway,
  49. const PROPERTIES* aProperties )
  50. {
  51. // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
  52. not_implemented( this, __FUNCTION__ );
  53. }
  54. size_t SCH_PLUGIN::GetSymbolLibCount( const wxString& aLibraryPath,
  55. const PROPERTIES* aProperties )
  56. {
  57. // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
  58. not_implemented( this, __FUNCTION__ );
  59. return 0;
  60. }
  61. void SCH_PLUGIN::EnumerateSymbolLib( wxArrayString& aAliasNameList,
  62. const wxString& aLibraryPath,
  63. const PROPERTIES* aProperties )
  64. {
  65. // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
  66. not_implemented( this, __FUNCTION__ );
  67. }
  68. void SCH_PLUGIN::EnumerateSymbolLib( std::vector<LIB_ALIAS*>& aAliasList,
  69. const wxString& aLibraryPath,
  70. const PROPERTIES* 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. }
  75. LIB_ALIAS* SCH_PLUGIN::LoadSymbol( const wxString& aLibraryPath, const wxString& aSymbolName,
  76. const PROPERTIES* aProperties )
  77. {
  78. // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
  79. not_implemented( this, __FUNCTION__ );
  80. return NULL;
  81. }
  82. void SCH_PLUGIN::SaveSymbol( const wxString& aLibraryPath, const LIB_PART* aSymbol,
  83. const PROPERTIES* 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::DeleteAlias( const wxString& aLibraryPath, const wxString& aAliasName,
  89. const PROPERTIES* aProperties )
  90. {
  91. // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
  92. not_implemented( this, __FUNCTION__ );
  93. }
  94. void SCH_PLUGIN::DeleteSymbol( const wxString& aLibraryPath, const wxString& aAliasName,
  95. const PROPERTIES* aProperties )
  96. {
  97. // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
  98. not_implemented( this, __FUNCTION__ );
  99. }
  100. void SCH_PLUGIN::CreateSymbolLib( const wxString& aLibraryPath, const PROPERTIES* aProperties )
  101. {
  102. // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
  103. not_implemented( this, __FUNCTION__ );
  104. }
  105. bool SCH_PLUGIN::DeleteSymbolLib( const wxString& aLibraryPath, const PROPERTIES* aProperties )
  106. {
  107. // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
  108. not_implemented( this, __FUNCTION__ );
  109. return false;
  110. }
  111. bool SCH_PLUGIN::IsSymbolLibWritable( const wxString& aLibraryPath )
  112. {
  113. // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
  114. not_implemented( this, __FUNCTION__ );
  115. return false;
  116. }
  117. void SCH_PLUGIN::SymbolLibOptions( PROPERTIES* aListToAppendTo ) const
  118. {
  119. // disable all these in another couple of months, after everyone has seen them:
  120. #if 1
  121. (*aListToAppendTo)["debug_level"] = UTF8( _(
  122. "Enable <b>debug</b> logging for Symbol*() functions in this SCH_PLUGIN."
  123. ) );
  124. (*aListToAppendTo)["read_filter_regex"] = UTF8( _(
  125. "Regular expression <b>symbol name</b> filter."
  126. ) );
  127. (*aListToAppendTo)["enable_transaction_logging"] = UTF8( _(
  128. "Enable transaction logging. The mere presence of this option turns on the "
  129. "logging, no need to set a Value."
  130. ) );
  131. (*aListToAppendTo)["username"] = UTF8( _(
  132. "User name for <b>login</b> to some special library server."
  133. ));
  134. (*aListToAppendTo)["password"] = UTF8( _(
  135. "Password for <b>login</b> to some special library server."
  136. ) );
  137. #endif
  138. #if 1
  139. // Suitable for a C++ to python SCH_PLUGIN::Footprint*() adapter, move it to the adapter
  140. // if and when implemented.
  141. (*aListToAppendTo)["python_symbol_plugin"] = UTF8( _(
  142. "Enter the python symbol which implements the SCH_PLUGIN::Symbol*() functions."
  143. ) );
  144. #endif
  145. }
  146. bool SCH_PLUGIN::CheckHeader( const wxString& aFileName )
  147. {
  148. // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
  149. not_implemented( this, __FUNCTION__ );
  150. return false;
  151. }
  152. const wxString& SCH_PLUGIN::GetError() const
  153. {
  154. // not pure virtual so that plugins only have to implement subset of the SCH_PLUGIN interface.
  155. not_implemented( this, __FUNCTION__ );
  156. static wxString error;
  157. return error;
  158. }