KiCad PCB EDA Suite
drc_rule.cpp
Go to the documentation of this file.
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 
24 
25 #include <board.h>
26 #include <board_item.h>
27 #include <drc/drc_rule.h>
28 #include <drc/drc_rule_condition.h>
29 
30 
32  m_Unary( false ),
33  m_Implicit( false ),
34  m_LayerCondition( LSET::AllLayersMask() ),
35  m_Condition( nullptr )
36 {
37 }
38 
39 
41 {
42  delete m_Condition;
43 }
44 
45 
47 {
48  aConstraint.SetParentRule( this );
49  m_Constraints.push_back( aConstraint );
50 }
51 
52 
54 {
55  for( DRC_CONSTRAINT& c : m_Constraints)
56  {
57  if( c.m_Type == aType )
58  return c;
59  }
60 
61  return OPT<DRC_CONSTRAINT>();
62 }
OPT< DRC_CONSTRAINT > FindConstraint(DRC_CONSTRAINT_T aType)
Definition: drc_rule.cpp:53
virtual ~DRC_RULE()
Definition: drc_rule.cpp:40
DRC_RULE_CONDITION * m_Condition
Definition: drc_rule.h:99
DRC_RULE()
Definition: drc_rule.cpp:31
DRC_CONSTRAINT_T
Definition: drc_rule.h:41
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:504
std::vector< DRC_CONSTRAINT > m_Constraints
Definition: drc_rule.h:100
void SetParentRule(DRC_RULE *aParentRule)
Definition: drc_rule.h:125
void AddConstraint(DRC_CONSTRAINT &aConstraint)
Definition: drc_rule.cpp:46
boost::optional< T > OPT
Definition: optional.h:7