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