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.

109 lines
3.6 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, you may find one here:
  18. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  19. * or you may search the http://www.gnu.org website for the version 2 license,
  20. * or you may write to the Free Software Foundation, Inc.,
  21. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  22. */
  23. #ifndef ERC_ITEM_H
  24. #define ERC_ITEM_H
  25. #include <rc_item.h>
  26. class ERC_ITEM : public RC_ITEM
  27. {
  28. public:
  29. /**
  30. * Constructs an ERC_ITEM for the given error code
  31. * @see ERCE_T
  32. */
  33. static std::shared_ptr<ERC_ITEM> Create( int aErrorCode );
  34. static std::shared_ptr<ERC_ITEM> Create( const wxString& aErrorKey )
  35. {
  36. for( const RC_ITEM& item : allItemTypes )
  37. {
  38. if( aErrorKey == item.GetSettingsKey() )
  39. return std::make_shared<ERC_ITEM>( static_cast<const ERC_ITEM&>( item ) );
  40. }
  41. return nullptr;
  42. }
  43. static std::vector<std::reference_wrapper<RC_ITEM>> GetItemsWithSeverities()
  44. {
  45. return allItemTypes;
  46. }
  47. bool IsSheetSpecific() const { return m_sheetSpecific; }
  48. void SetIsSheetSpecific( bool aSpecific = true ) { m_sheetSpecific = aSpecific; }
  49. private:
  50. ERC_ITEM( int aErrorCode = 0, const wxString& aTitle = "", const wxString& aSettingsKey = "" )
  51. {
  52. m_errorCode = aErrorCode;
  53. m_errorTitle = aTitle;
  54. m_settingsKey = aSettingsKey;
  55. m_sheetSpecific = false;
  56. }
  57. /// A list of all ERC_ITEM types which are valid error codes
  58. static std::vector<std::reference_wrapper<RC_ITEM>> allItemTypes;
  59. static ERC_ITEM heading_connections;
  60. static ERC_ITEM heading_conflicts;
  61. static ERC_ITEM heading_misc;
  62. static ERC_ITEM duplicateSheetName;
  63. static ERC_ITEM endpointOffGrid;
  64. static ERC_ITEM pinNotConnected;
  65. static ERC_ITEM pinNotDriven;
  66. static ERC_ITEM powerpinNotDriven;
  67. static ERC_ITEM pinTableWarning;
  68. static ERC_ITEM pinTableError;
  69. static ERC_ITEM hierLabelMismatch;
  70. static ERC_ITEM noConnectConnected;
  71. static ERC_ITEM noConnectDangling;
  72. static ERC_ITEM labelDangling;
  73. static ERC_ITEM globalLabelDangling;
  74. static ERC_ITEM similarLabels;
  75. static ERC_ITEM differentUnitFootprint;
  76. static ERC_ITEM differentUnitNet;
  77. static ERC_ITEM busDefinitionConflict;
  78. static ERC_ITEM multipleNetNames;
  79. static ERC_ITEM netNotBusMember;
  80. static ERC_ITEM busLabelSyntax;
  81. static ERC_ITEM busToBusConflict;
  82. static ERC_ITEM busToNetConflict;
  83. static ERC_ITEM unresolvedVariable;
  84. static ERC_ITEM wireDangling;
  85. static ERC_ITEM libSymbolIssues;
  86. static ERC_ITEM unannotated;
  87. static ERC_ITEM extraUnits;
  88. static ERC_ITEM differentUnitValue;
  89. static ERC_ITEM duplicateReference;
  90. static ERC_ITEM busEntryNeeded;
  91. /// True if this item is specific to a sheet instance (as opposed to applying to all instances)
  92. bool m_sheetSpecific;
  93. };
  94. #endif // ERC_ITEM_H