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.

75 lines
2.1 KiB

5 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2020 KiCad Developers, see change_log.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. #include <board.h>
  24. #include <board_item.h>
  25. #include <drc/drc_rule.h>
  26. #include <drc/drc_rule_condition.h>
  27. DRC_RULE::DRC_RULE() :
  28. m_Unary( false ),
  29. m_Implicit( false ),
  30. m_ImplicitItemId( 0 ),
  31. m_LayerCondition( LSET::AllLayersMask() ),
  32. m_Condition( nullptr ),
  33. m_Severity( RPT_SEVERITY_UNDEFINED )
  34. {
  35. }
  36. DRC_RULE::DRC_RULE( const wxString& aName ) :
  37. m_Unary( false ),
  38. m_Implicit( false ),
  39. m_ImplicitItemId( 0 ),
  40. m_Name( aName ),
  41. m_LayerCondition( LSET::AllLayersMask() ),
  42. m_Condition( nullptr ),
  43. m_Severity( RPT_SEVERITY_UNDEFINED )
  44. {
  45. }
  46. DRC_RULE::~DRC_RULE()
  47. {
  48. delete m_Condition;
  49. }
  50. void DRC_RULE::AddConstraint( DRC_CONSTRAINT& aConstraint )
  51. {
  52. aConstraint.SetParentRule( this );
  53. m_Constraints.push_back( aConstraint );
  54. }
  55. std::optional<DRC_CONSTRAINT> DRC_RULE::FindConstraint( DRC_CONSTRAINT_T aType )
  56. {
  57. for( DRC_CONSTRAINT& c : m_Constraints)
  58. {
  59. if( c.m_Type == aType )
  60. return c;
  61. }
  62. return std::optional<DRC_CONSTRAINT>();
  63. }