KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcbexpr_evaluator.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 The 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
24#include "pcbexpr_evaluator.h"
25
26#include <cstdio>
27#include <memory>
28#include <mutex>
29
30#include <board.h>
31#include <footprint.h>
32#include <lset.h>
34#include <drc/drc_engine.h>
36#include <string_utils.h>
37
38
39/* --------------------------------------------------------------------------------------------
40 * Specialized Expression References
41 */
42
44{
45 wxASSERT( dynamic_cast<const PCBEXPR_CONTEXT*>( aCtx ) );
46
47 const PCBEXPR_CONTEXT* ctx = static_cast<const PCBEXPR_CONTEXT*>( aCtx );
48 BOARD_ITEM* item = ctx->GetItem( m_itemIndex );
49 return item;
50}
51
52
54{
55public:
57 LIBEVAL::VALUE( LayerName( aLayer ) ),
58 m_layer( aLayer )
59 {};
60
61 virtual bool EqualTo( LIBEVAL::CONTEXT* aCtx, const VALUE* b ) const override
62 {
63 // For boards with user-defined layer names there will be 2 entries for each layer
64 // in the ENUM_MAP: one for the canonical layer name and one for the user layer name.
65 // We need to check against both.
66
67 wxPGChoices& layerMap = ENUM_MAP<PCB_LAYER_ID>::Instance().Choices();
68 const wxString& layerName = b->AsString();
69 BOARD* board = static_cast<PCBEXPR_CONTEXT*>( aCtx )->GetBoard();
70
71 {
72 std::shared_lock<std::shared_mutex> readLock( board->m_CachesMutex );
73
74 auto i = board->m_LayerExpressionCache.find( layerName );
75
76 if( i != board->m_LayerExpressionCache.end() )
77 return i->second.Contains( m_layer );
78 }
79
80 LSET mask;
81
82 for( unsigned ii = 0; ii < layerMap.GetCount(); ++ii )
83 {
84 wxPGChoiceEntry& entry = layerMap[ii];
85
86 if( entry.GetText().Matches( layerName ) )
87 mask.set( ToLAYER_ID( entry.GetValue() ) );
88 }
89
90 {
91 std::unique_lock<std::shared_mutex> writeLock( board->m_CachesMutex );
92 board->m_LayerExpressionCache[ layerName ] = mask;
93 }
94
95 return mask.Contains( m_layer );
96 }
97
98protected:
100};
101
102
104{
105public:
106 PCBEXPR_PINTYPE_VALUE( const wxString& aPinTypeName ) :
107 LIBEVAL::VALUE( aPinTypeName )
108 {};
109
110 bool EqualTo( LIBEVAL::CONTEXT* aCtx, const VALUE* b ) const override
111 {
112 const wxString& thisStr = AsString();
113 const wxString& otherStr = b->AsString();
114
115 // Case insensitive
116 if( thisStr.IsSameAs( otherStr, false ) )
117 return true;
118
119 // Wildcards
120 if( thisStr.Matches( otherStr ) )
121 return true;
122
123 // Handle cases where the netlist token is different from the EEschema token
124 wxString altStr;
125
126 if( thisStr == wxT( "tri_state" ) )
127 altStr = wxT( "Tri-state" );
128 else if( thisStr == wxT( "power_in" ) )
129 altStr = wxT( "Power input" );
130 else if( thisStr == wxT( "power_out" ) )
131 altStr = wxT( "Power output" );
132 else if( thisStr == wxT( "no_connect" ) )
133 altStr = wxT( "Unconnected" );
134
135 if( !altStr.IsEmpty() )
136 {
137 // Case insensitive
138 if( altStr.IsSameAs( otherStr, false ) )
139 return true;
140
141 // Wildcards
142 if( altStr.Matches( otherStr ) )
143 return true;
144 }
145
146 return false;
147 }
148};
149
150
152{
153public:
155 LIBEVAL::VALUE( wxEmptyString ),
156 m_item( aItem )
157 {};
158
159 const wxString& AsString() const override
160 {
161 const_cast<PCBEXPR_NETCLASS_VALUE*>( this )->Set( m_item->GetEffectiveNetClass()->GetName() );
163 }
164
165 bool EqualTo( LIBEVAL::CONTEXT* aCtx, const VALUE* b ) const override
166 {
167 if( const PCBEXPR_NETCLASS_VALUE* bValue = dynamic_cast<const PCBEXPR_NETCLASS_VALUE*>( b ) )
168 return *( m_item->GetEffectiveNetClass() ) == *( bValue->m_item->GetEffectiveNetClass() );
169
170 if( b->GetType() == LIBEVAL::VT_STRING )
171 {
172 // Test constituent net class names. The effective net class name (e.g. CLASS1,CLASS2,OTHER_CLASS) is
173 // tested in the fallthrough condition.
174 for( const NETCLASS* nc : m_item->GetEffectiveNetClass()->GetConstituentNetclasses() )
175 {
176 const wxString& ncName = nc->GetName();
177
178 if( b->StringIsWildcard() )
179 {
180 if( WildCompareString( b->AsString(), ncName, false ) )
181 return true;
182 }
183 else
184 {
185 if( ncName.IsSameAs( b->AsString(), false ) )
186 return true;
187 }
188 }
189 }
190
191 return LIBEVAL::VALUE::EqualTo( aCtx, b );
192 }
193
194 bool NotEqualTo( LIBEVAL::CONTEXT* aCtx, const LIBEVAL::VALUE* b ) const override
195 {
196 if( const PCBEXPR_NETCLASS_VALUE* bValue = dynamic_cast<const PCBEXPR_NETCLASS_VALUE*>( b ) )
197 return *( m_item->GetEffectiveNetClass() ) != *( bValue->m_item->GetEffectiveNetClass() );
198
199 if( b->GetType() == LIBEVAL::VT_STRING )
200 {
201 // Test constituent net class names
202 bool isInConstituents = false;
203
204 for( const NETCLASS* nc : m_item->GetEffectiveNetClass()->GetConstituentNetclasses() )
205 {
206 const wxString& ncName = nc->GetName();
207
208 if( b->StringIsWildcard() )
209 {
210 if( WildCompareString( b->AsString(), ncName, false ) )
211 {
212 isInConstituents = true;
213 break;
214 }
215 }
216 else
217 {
218 if( ncName.IsSameAs( b->AsString(), false ) )
219 {
220 isInConstituents = true;
221 break;
222 }
223 }
224 }
225
226 // Test effective net class name
227 const bool isFullName = LIBEVAL::VALUE::EqualTo( aCtx, b );
228
229 return !isInConstituents && !isFullName;
230 }
231
232 return LIBEVAL::VALUE::NotEqualTo( aCtx, b );
233 }
234
235protected:
237};
238
239
241{
242public:
244 LIBEVAL::VALUE( wxEmptyString ),
245 m_item( dynamic_cast<FOOTPRINT*>( aItem ) )
246 {};
247
248 const wxString& AsString() const override
249 {
250 if( !m_item )
252
253 if( const COMPONENT_CLASS* compClass = m_item->GetComponentClass() )
254 const_cast<PCBEXPR_COMPONENT_CLASS_VALUE*>( this )->Set( compClass->GetName() );
255
257 }
258
259 bool EqualTo( LIBEVAL::CONTEXT* aCtx, const VALUE* b ) const override
260 {
261 if( const PCBEXPR_COMPONENT_CLASS_VALUE* bValue = dynamic_cast<const PCBEXPR_COMPONENT_CLASS_VALUE*>( b ) )
262 {
263 if( !m_item || !bValue->m_item )
264 return LIBEVAL::VALUE::EqualTo( aCtx, b );
265
266 const COMPONENT_CLASS* aClass = m_item->GetComponentClass();
267 const COMPONENT_CLASS* bClass = bValue->m_item->GetComponentClass();
268
269 return *aClass == *bClass;
270 }
271
272 if( b->GetType() == LIBEVAL::VT_STRING )
273 {
274 // Test constituent component class names. The effective component class name
275 // (e.g. CLASS1,CLASS2,OTHER_CLASS) is tested in the fallthrough condition.
276 for( const COMPONENT_CLASS* cc : m_item->GetComponentClass()->GetConstituentClasses() )
277 {
278 const wxString& ccName = cc->GetName();
279
280 if( b->StringIsWildcard() )
281 {
282 if( WildCompareString( b->AsString(), ccName, false ) )
283 return true;
284 }
285 else
286 {
287 if( ccName.IsSameAs( b->AsString(), false ) )
288 return true;
289 }
290 }
291 }
292
293 return LIBEVAL::VALUE::EqualTo( aCtx, b );
294 }
295
296 bool NotEqualTo( LIBEVAL::CONTEXT* aCtx, const LIBEVAL::VALUE* b ) const override
297 {
298 if( const PCBEXPR_COMPONENT_CLASS_VALUE* bValue = dynamic_cast<const PCBEXPR_COMPONENT_CLASS_VALUE*>( b ) )
299 {
300 if( !m_item || !bValue->m_item )
301 return LIBEVAL::VALUE::NotEqualTo( aCtx, b );
302
303 const COMPONENT_CLASS* aClass = m_item->GetComponentClass();
304 const COMPONENT_CLASS* bClass = bValue->m_item->GetComponentClass();
305
306 return *aClass != *bClass;
307 }
308
309 if( b->GetType() == LIBEVAL::VT_STRING )
310 {
311 // Test constituent component class names
312 bool isInConstituents = false;
313
314 for( const COMPONENT_CLASS* cc : m_item->GetComponentClass()->GetConstituentClasses() )
315 {
316 const wxString& ccName = cc->GetName();
317
318 if( b->StringIsWildcard() )
319 {
320 if( WildCompareString( b->AsString(), ccName, false ) )
321 {
322 isInConstituents = true;
323 break;
324 }
325 }
326 else
327 {
328 if( ccName.IsSameAs( b->AsString(), false ) )
329 {
330 isInConstituents = true;
331 break;
332 }
333 }
334 }
335
336 // Test effective component class name
337 const bool isFullName = LIBEVAL::VALUE::EqualTo( aCtx, b );
338
339 return !isInConstituents && !isFullName;
340 }
341
342 return LIBEVAL::VALUE::NotEqualTo( aCtx, b );
343 }
344
345protected:
347};
348
349
351{
352public:
354 LIBEVAL::VALUE( wxEmptyString ),
355 m_item( aItem )
356 {};
357
358 const wxString& AsString() const override
359 {
360 const_cast<PCBEXPR_NET_VALUE*>( this )->Set( m_item->GetNetname() );
362 }
363
364 bool EqualTo( LIBEVAL::CONTEXT* aCtx, const VALUE* b ) const override
365 {
366 if( const PCBEXPR_NET_VALUE* bValue = dynamic_cast<const PCBEXPR_NET_VALUE*>( b ) )
367 return m_item->GetNetCode() == bValue->m_item->GetNetCode();
368 else
369 return LIBEVAL::VALUE::EqualTo( aCtx, b );
370 }
371
372 bool NotEqualTo( LIBEVAL::CONTEXT* aCtx, const LIBEVAL::VALUE* b ) const override
373 {
374 if( const PCBEXPR_NET_VALUE* bValue = dynamic_cast<const PCBEXPR_NET_VALUE*>( b ) )
375 return m_item->GetNetCode() != bValue->m_item->GetNetCode();
376 else
377 return LIBEVAL::VALUE::NotEqualTo( aCtx, b );
378 }
379
380protected:
382};
383
384
386{
387 PCBEXPR_CONTEXT* context = static_cast<PCBEXPR_CONTEXT*>( aCtx );
388
389 if( m_type == LIBEVAL::VT_NULL )
391
392 if( m_itemIndex == 2 )
393 return new PCBEXPR_LAYER_VALUE( context->GetLayer() );
394
395 BOARD_ITEM* item = GetObject( aCtx );
396
397 if( !item )
398 return new LIBEVAL::VALUE();
399
400 auto it = m_matchingTypes.find( TYPE_HASH( *item ) );
401
402 if( it == m_matchingTypes.end() )
403 {
404 // Don't force user to type "A.Type == 'via' && A.Via_Type == 'buried'" when the
405 // simpler "A.Via_Type == 'buried'" is perfectly clear. Instead, return an undefined
406 // value when the property doesn't appear on a particular object.
407
408 return new LIBEVAL::VALUE();
409 }
410 else
411 {
413 {
414 if( m_isOptional )
415 {
416 std::optional<int> val = item->Get<std::optional<int>>( it->second );
417
418 if( val.has_value() )
419 return new LIBEVAL::VALUE( static_cast<double>( val.value() ) );
420
422 }
423
424 return new LIBEVAL::VALUE( static_cast<double>( item->Get<int>( it->second ) ) );
425 }
427 {
428 if( m_isOptional )
429 {
430 std::optional<double> val = item->Get<std::optional<double>>( it->second );
431
432 if( val.has_value() )
433 return new LIBEVAL::VALUE( val.value() );
434
436 }
437
438 return new LIBEVAL::VALUE( item->Get<double>( it->second ) );
439 }
440 else
441 {
442 wxString str;
443
444 if( !m_isEnum )
445 {
446 str = item->Get<wxString>( it->second );
447
448 if( it->second->Name() == wxT( "Pin Type" ) )
449 return new PCBEXPR_PINTYPE_VALUE( str );
450
451 // If it quacks like a duck, it is a duck
452 double doubleVal;
453
455 return new LIBEVAL::VALUE( doubleVal );
456
457 return new LIBEVAL::VALUE( str );
458 }
459 else if( it->second->Name() == wxT( "Layer" )
460 || it->second->Name() == wxT( "Layer Top" )
461 || it->second->Name() == wxT( "Layer Bottom" ) )
462 {
463 const wxAny& any = item->Get( it->second );
464 PCB_LAYER_ID layer;
465
466 if( any.GetAs<PCB_LAYER_ID>( &layer ) )
467 return new PCBEXPR_LAYER_VALUE( layer );
468 else if( any.GetAs<wxString>( &str ) )
469 return new PCBEXPR_LAYER_VALUE( context->GetBoard()->GetLayerID( str ) );
470 }
471 else
472 {
473 const wxAny& any = item->Get( it->second );
474
475 if( any.GetAs<wxString>( &str ) )
476 return new LIBEVAL::VALUE( str );
477 }
478
479 return new LIBEVAL::VALUE();
480 }
481 }
482}
483
484
486{
487 BOARD_CONNECTED_ITEM* item = dynamic_cast<BOARD_CONNECTED_ITEM*>( GetObject( aCtx ) );
488
489 if( !item )
490 return new LIBEVAL::VALUE();
491
492 return new PCBEXPR_NETCLASS_VALUE( item );
493}
494
495
497{
498 BOARD_ITEM* item = dynamic_cast<BOARD_ITEM*>( GetObject( aCtx ) );
499
500 if( !item || item->Type() != PCB_FOOTPRINT_T )
501 return new LIBEVAL::VALUE();
502
503 return new PCBEXPR_COMPONENT_CLASS_VALUE( item );
504}
505
506
508{
509 BOARD_CONNECTED_ITEM* item = dynamic_cast<BOARD_CONNECTED_ITEM*>( GetObject( aCtx ) );
510
511 if( !item )
512 return new LIBEVAL::VALUE();
513
514 return new PCBEXPR_NET_VALUE( item );
515}
516
517
519{
520 BOARD_ITEM* item = GetObject( aCtx );
521
522 if( !item )
523 return new LIBEVAL::VALUE();
524
525 return new LIBEVAL::VALUE( ENUM_MAP<KICAD_T>::Instance().ToString( item->Type() ) );
526}
527
528
530{
532
533 return registry.Get( aName.Lower() );
534}
535
536
537std::unique_ptr<LIBEVAL::VAR_REF> PCBEXPR_UCODE::CreateVarRef( const wxString& aVar,
538 const wxString& aField )
539{
541 std::unique_ptr<PCBEXPR_VAR_REF> vref;
542
543 if( aVar.IsSameAs( wxT( "null" ), false ) )
544 {
545 vref = std::make_unique<PCBEXPR_VAR_REF>( 0 );
546 vref->SetType( LIBEVAL::VT_NULL );
547 return vref;
548 }
549
550 // Check for a couple of very common cases and compile them straight to "object code".
551
552 if( aField.CmpNoCase( wxT( "NetClass" ) ) == 0 )
553 {
554 if( aVar == wxT( "A" ) )
555 return std::make_unique<PCBEXPR_NETCLASS_REF>( 0 );
556 else if( aVar == wxT( "B" ) )
557 return std::make_unique<PCBEXPR_NETCLASS_REF>( 1 );
558 else
559 return nullptr;
560 }
561 else if( aField.CmpNoCase( wxT( "ComponentClass" ) ) == 0 )
562 {
563 if( aVar == wxT( "A" ) )
564 return std::make_unique<PCBEXPR_COMPONENT_CLASS_REF>( 0 );
565 else if( aVar == wxT( "B" ) )
566 return std::make_unique<PCBEXPR_COMPONENT_CLASS_REF>( 1 );
567 else
568 return nullptr;
569 }
570 else if( aField.CmpNoCase( wxT( "NetName" ) ) == 0 )
571 {
572 if( aVar == wxT( "A" ) )
573 return std::make_unique<PCBEXPR_NETNAME_REF>( 0 );
574 else if( aVar == wxT( "B" ) )
575 return std::make_unique<PCBEXPR_NETNAME_REF>( 1 );
576 else
577 return nullptr;
578 }
579 else if( aField.CmpNoCase( wxT( "Type" ) ) == 0 )
580 {
581 if( aVar == wxT( "A" ) )
582 return std::make_unique<PCBEXPR_TYPE_REF>( 0 );
583 else if( aVar == wxT( "B" ) )
584 return std::make_unique<PCBEXPR_TYPE_REF>( 1 );
585 else
586 return nullptr;
587 }
588
589 if( aVar == wxT( "A" ) || aVar == wxT( "AB" ) )
590 vref = std::make_unique<PCBEXPR_VAR_REF>( 0 );
591 else if( aVar == wxT( "B" ) )
592 vref = std::make_unique<PCBEXPR_VAR_REF>( 1 );
593 else if( aVar == wxT( "L" ) )
594 vref = std::make_unique<PCBEXPR_VAR_REF>( 2 );
595 else
596 return nullptr;
597
598 if( aField.length() == 0 ) // return reference to base object
599 return vref;
600
601 wxString field( aField );
602 field.Replace( wxT( "_" ), wxT( " " ) );
603
604 for( const PROPERTY_MANAGER::CLASS_INFO& cls : propMgr.GetAllClasses() )
605 {
606 if( propMgr.IsOfType( cls.type, TYPE_HASH( BOARD_ITEM ) ) )
607 {
608 PROPERTY_BASE* prop = propMgr.GetProperty( cls.type, field );
609
610 if( prop )
611 {
612 vref->AddAllowedClass( cls.type, prop );
613
614 if( prop->TypeHash() == TYPE_HASH( int ) )
615 {
616 vref->SetType( LIBEVAL::VT_NUMERIC );
617 }
618 else if( prop->TypeHash() == TYPE_HASH( std::optional<int> ) )
619 {
620 vref->SetType( LIBEVAL::VT_NUMERIC );
621 vref->SetIsOptional();
622 }
623 else if( prop->TypeHash() == TYPE_HASH( double ) )
624 {
625 vref->SetType( LIBEVAL::VT_NUMERIC_DOUBLE );
626 }
627 else if( prop->TypeHash() == TYPE_HASH( std::optional<double> ) )
628 {
629 vref->SetType( LIBEVAL::VT_NUMERIC_DOUBLE );
630 vref->SetIsOptional();
631 }
632 else if( prop->TypeHash() == TYPE_HASH( bool ) )
633 {
634 vref->SetType( LIBEVAL::VT_NUMERIC );
635 }
636 else if( prop->TypeHash() == TYPE_HASH( wxString ) )
637 {
638 vref->SetType( LIBEVAL::VT_STRING );
639 }
640 else if ( prop->HasChoices() )
641 { // it's an enum, we treat it as string
642 vref->SetType( LIBEVAL::VT_STRING );
643 vref->SetIsEnum( true );
644 }
645 else
646 {
647 wxString msg = wxString::Format( wxT( "PCBEXPR_UCODE::createVarRef: Unknown "
648 "property type %s from %s." ),
649 cls.name,
650 field );
651 wxFAIL_MSG( msg );
652 }
653 }
654 }
655 }
656
657 if( vref->GetType() == LIBEVAL::VT_UNDEFINED )
658 vref->SetType( LIBEVAL::VT_PARSE_ERROR );
659
660 return vref;
661}
662
663
665{
666 if( m_items[0] )
667 return m_items[0]->GetBoard();
668
669 return nullptr;
670}
671
672
673/* --------------------------------------------------------------------------------------------
674 * Unit Resolvers
675 */
676
677const std::vector<wxString>& PCBEXPR_UNIT_RESOLVER::GetSupportedUnits() const
678{
679 static const std::vector<wxString> pcbUnits = { wxT( "mil" ), wxT( "mm" ), wxT( "in" ),
680 wxT( "deg" ), wxT( "fs" ), wxT( "ps" ) };
681
682
683 return pcbUnits;
684}
685
686
688{
689 return _( "must be mm, in, mil, deg, fs, or ps" );
690}
691
692
693const std::vector<EDA_UNITS>& PCBEXPR_UNIT_RESOLVER::GetSupportedUnitsTypes() const
694{
695 static const std::vector<EDA_UNITS> pcbUnits = { EDA_UNITS::MILS, EDA_UNITS::MM, EDA_UNITS::INCH,
697
698 return pcbUnits;
699}
700
701
702double PCBEXPR_UNIT_RESOLVER::Convert( const wxString& aString, int unitId ) const
703{
704 double v = wxAtof( aString );
705
706 switch( unitId )
707 {
711 case 3: return v;
714 default: return v;
715 }
716};
717
718
719const std::vector<wxString>& PCBEXPR_UNITLESS_RESOLVER::GetSupportedUnits() const
720{
721 static const std::vector<wxString> emptyUnits;
722
723 return emptyUnits;
724}
725
726
727const std::vector<EDA_UNITS>& PCBEXPR_UNITLESS_RESOLVER::GetSupportedUnitsTypes() const
728{
729 static const std::vector<EDA_UNITS> emptyUnits;
730
731 return emptyUnits;
732}
733
734
735double PCBEXPR_UNITLESS_RESOLVER::Convert( const wxString& aString, int unitId ) const
736{
737 return wxAtof( aString );
738};
739
740
742{
743 m_unitResolver.reset( aUnitResolver );
744}
745
746
747/* --------------------------------------------------------------------------------------------
748 * PCB Expression Evaluator
749 */
750
752 m_result( 0 ),
753 m_units( EDA_UNITS::MM ),
754 m_compiler( aUnitResolver ),
755 m_ucode(),
757{
758}
759
760
764
765
766bool PCBEXPR_EVALUATOR::Evaluate( const wxString& aExpr )
767{
768 PCBEXPR_UCODE ucode;
769 PCBEXPR_CONTEXT preflightContext( NULL_CONSTRAINT, F_Cu );
770
771 if( !m_compiler.Compile( aExpr.ToUTF8().data(), &ucode, &preflightContext ) )
772 return false;
773
774 PCBEXPR_CONTEXT evaluationContext( NULL_CONSTRAINT, F_Cu );
775 LIBEVAL::VALUE* result = ucode.Run( &evaluationContext );
776
777 if( result->GetType() == LIBEVAL::VT_NUMERIC )
778 {
779 m_result = KiROUND( result->AsDouble() );
780 m_units = result->GetUnits();
781 }
782
783 return true;
784}
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:112
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:990
BASE_SET & set(size_t pos)
Definition base_set.h:116
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:79
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:317
PCB_LAYER_ID GetLayerID(const wxString &aLayerName) const
Return the ID of a layer.
Definition board.cpp:671
std::unordered_map< wxString, LSET > m_LayerExpressionCache
Definition board.h:1373
std::shared_mutex m_CachesMutex
Definition board.h:1367
A lightweight representation of a component class.
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
static ENUM_MAP< T > & Instance()
Definition property.h:699
wxAny Get(PROPERTY_BASE *aProperty) const
std::unique_ptr< UNIT_RESOLVER > m_unitResolver
VALUE * Run(CONTEXT *ctx)
void Set(double aValue)
virtual const wxString & AsString() const
bool StringIsWildcard() const
static VALUE * MakeNullValue()
virtual bool NotEqualTo(CONTEXT *aCtx, const VALUE *b) const
VAR_TYPE_T GetType() const
virtual bool EqualTo(CONTEXT *aCtx, const VALUE *b) const
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
bool Contains(PCB_LAYER_ID aLayer) const
See if the layer set contains a PCB layer.
Definition lset.h:63
A collection of nets and the parameters used to route or test these nets.
Definition netclass.h:45
LIBEVAL::FUNC_CALL_REF Get(const wxString &name)
static PCBEXPR_BUILTIN_FUNCTIONS & Instance()
PCBEXPR_COMPILER(LIBEVAL::UNIT_RESOLVER *aUnitResolver)
LIBEVAL::VALUE * GetValue(LIBEVAL::CONTEXT *aCtx) override
bool NotEqualTo(LIBEVAL::CONTEXT *aCtx, const LIBEVAL::VALUE *b) const override
const wxString & AsString() const override
PCBEXPR_COMPONENT_CLASS_VALUE(BOARD_ITEM *aItem)
bool EqualTo(LIBEVAL::CONTEXT *aCtx, const VALUE *b) const override
BOARD_ITEM * m_items[2]
BOARD * GetBoard() const
PCB_LAYER_ID GetLayer() const
BOARD_ITEM * GetItem(int index) const
LIBEVAL::ERROR_STATUS m_errorStatus
PCBEXPR_EVALUATOR(LIBEVAL::UNIT_RESOLVER *aUnitResolver)
PCBEXPR_COMPILER m_compiler
bool Evaluate(const wxString &aExpr)
PCBEXPR_LAYER_VALUE(PCB_LAYER_ID aLayer)
virtual bool EqualTo(LIBEVAL::CONTEXT *aCtx, const VALUE *b) const override
LIBEVAL::VALUE * GetValue(LIBEVAL::CONTEXT *aCtx) override
bool EqualTo(LIBEVAL::CONTEXT *aCtx, const VALUE *b) const override
BOARD_CONNECTED_ITEM * m_item
PCBEXPR_NETCLASS_VALUE(BOARD_CONNECTED_ITEM *aItem)
const wxString & AsString() const override
bool NotEqualTo(LIBEVAL::CONTEXT *aCtx, const LIBEVAL::VALUE *b) const override
LIBEVAL::VALUE * GetValue(LIBEVAL::CONTEXT *aCtx) override
bool EqualTo(LIBEVAL::CONTEXT *aCtx, const VALUE *b) const override
BOARD_CONNECTED_ITEM * m_item
PCBEXPR_NET_VALUE(BOARD_CONNECTED_ITEM *aItem)
bool NotEqualTo(LIBEVAL::CONTEXT *aCtx, const LIBEVAL::VALUE *b) const override
const wxString & AsString() const override
bool EqualTo(LIBEVAL::CONTEXT *aCtx, const VALUE *b) const override
PCBEXPR_PINTYPE_VALUE(const wxString &aPinTypeName)
LIBEVAL::VALUE * GetValue(LIBEVAL::CONTEXT *aCtx) override
virtual std::unique_ptr< LIBEVAL::VAR_REF > CreateVarRef(const wxString &aVar, const wxString &aField) override
virtual LIBEVAL::FUNC_CALL_REF CreateFuncCall(const wxString &aName) override
const std::vector< wxString > & GetSupportedUnits() const override
const std::vector< EDA_UNITS > & GetSupportedUnitsTypes() const override
double Convert(const wxString &aString, int unitId) const override
double Convert(const wxString &aString, int unitId) const override
const std::vector< EDA_UNITS > & GetSupportedUnitsTypes() const override
wxString GetSupportedUnitsMessage() const override
const std::vector< wxString > & GetSupportedUnits() const override
std::unordered_map< TYPE_ID, PROPERTY_BASE * > m_matchingTypes
LIBEVAL::VALUE * GetValue(LIBEVAL::CONTEXT *aCtx) override
LIBEVAL::VAR_TYPE_T m_type
BOARD_ITEM * GetObject(const LIBEVAL::CONTEXT *aCtx) const
virtual size_t TypeHash() const =0
Return type-id of the property type.
virtual bool HasChoices() const
Return true if this PROPERTY has a limited set of possible values.
Definition property.h:243
Provide class metadata.Helper macro to map type hashes to names.
CLASSES_INFO GetAllClasses()
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE * GetProperty(TYPE_ID aType, const wxString &aProperty) const
Return a property for a specific type.
bool IsOfType(TYPE_ID aDerived, TYPE_ID aBase) const
Return true if aDerived is inherited from aBase.
A type-safe container of any type.
Definition ki_any.h:93
@ NULL_CONSTRAINT
Definition drc_rule.h:48
#define _(s)
EDA_UNITS
Definition eda_units.h:48
wxString LayerName(int aLayer)
Returns the default display name for a given layer.
Definition layer_id.cpp:31
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:60
@ F_Cu
Definition layer_ids.h:64
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition lset.cpp:737
KICOMMON_API double DoubleValueFromString(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, const wxString &aTextValue, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Convert aTextValue to a double.
std::function< void(CONTEXT *, void *)> FUNC_CALL_REF
BOARD * GetBoard()
#define TYPE_HASH(x)
Definition property.h:73
bool WildCompareString(const wxString &pattern, const wxString &string_to_tst, bool case_sensitive)
Compare a string against wild card (* and ?) pattern using the usual rules.
wxString result
Test unit parsing edge cases and error handling.
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition typeinfo.h:86