KiCad PCB EDA Suite
Loading...
Searching...
No Matches
lset.h
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) 2024 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef LSET_H
21#define LSET_H
22
23#include <layer_ids.h>
24#include <base_set.h>
25
26class LSEQ;
27
35{
36public:
37
38 // The constructor flavors are carefully chosen to prevent LSET( int ) from compiling.
39 // That excludes "LSET s = 0;" and excludes "LSET s = -1;", etc.
40 // LSET s = 0; needs to be removed from the code, this accomplishes that.
41 // Remember LSET( PCB_LAYER_ID(0) ) sets bit 0, so "LSET s = 0;" is illegal
42 // to prevent that surprise. Therefore LSET's constructor suite is significantly
43 // different than the base class from which it is derived.
44
45 // Other member functions (non-constructor functions) are identical to the base
46 // class's and therefore are re-used from the base class.
47
51 LSET() :
52 BASE_SET(PCB_LAYER_ID_COUNT) // all bits are set to zero in BASE_SET()
53 {
54 }
55
56 LSET( const BASE_SET& aOther ) :
57 BASE_SET( aOther )
58 {
59 }
60
61 LSET( PCB_LAYER_ID aLayer ) :
63 {
64 set( aLayer );
65 }
66
67 LSET( std::initializer_list<PCB_LAYER_ID> aList );
68
69 LSET( const LSEQ& aSeq );
70
71 LSET( unsigned long __val ) = delete;
72
79 bool Contains( PCB_LAYER_ID aLayer )
80 {
81 try
82 {
83 return test( aLayer );
84 }
85 catch( std::out_of_range& )
86 {
87 return false;
88 }
89 }
90
94 static const wxChar* Name( PCB_LAYER_ID aLayerId );
95
100 static LSET InternalCuMask();
101
105 static LSET FrontAssembly();
106
110 static LSET BackAssembly();
111
115 static LSET AllCuMask( int aCuLayerCount = MAX_CU_LAYERS );
116
120 static LSET ExternalCuMask();
121
125 static LSET AllNonCuMask();
126
127 static LSET AllLayersMask();
128
132 static LSET FrontTechMask();
133
138 static LSET FrontBoardTechMask();
139
143 static LSET BackTechMask();
144
149 static LSET BackBoardTechMask();
150
154 static LSET AllTechMask();
155
159 static LSET AllBoardTechMask();
160
164 static LSET FrontMask();
165
169 static LSET BackMask();
170
171 static LSET SideSpecificMask();
172
173 static LSET UserMask();
174
179 static LSET PhysicalLayersMask();
180
184 static LSET UserDefinedLayers();
185
191 static LSET ForbiddenFootprintLayers();
192
198 LSEQ CuStack() const;
199
205 LSEQ Technicals( LSET aSubToOmit = LSET() ) const;
206
208 LSEQ Users() const;
209
211 LSEQ TechAndUserUIOrder() const;
212
213 LSEQ UIOrder() const;
214
222 LSEQ Seq( const PCB_LAYER_ID* aWishListSequence, unsigned aCount ) const;
223
224 LSEQ Seq( const LSEQ& aSequence ) const;
225
232 LSEQ Seq() const;
233
241 LSEQ SeqStackupTop2Bottom( PCB_LAYER_ID aSelectedLayer = UNDEFINED_LAYER ) const;
242
247 LSEQ SeqStackupForPlotting() const;
248
252 void RunOnLayers( const std::function<void( PCB_LAYER_ID )>& aFunction ) const
253 {
254 for( size_t ii = 0; ii < size(); ++ii )
255 {
256 if( test( ii ) )
257 aFunction( PCB_LAYER_ID( ii ) );
258 }
259 }
260
264 std::string FmtHex() const;
265
273 int ParseHex( const char* aStart, int aCount );
274
278 std::string FmtBin() const;
279
284 PCB_LAYER_ID ExtractLayer() const;
285
286
296 LSET& Flip( int aCopperLayersCount = 0 );
297
298};
299#endif // LSET_H
BASE_SET & set(size_t pos=std::numeric_limits< size_t >::max(), bool value=true)
Definition: base_set.h:61
size_t size() const
Definition: base_set.h:108
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition: lseq.h:47
LSET is a set of PCB_LAYER_IDs.
Definition: lset.h:35
LSET(PCB_LAYER_ID aLayer)
Definition: lset.h:61
LSET(unsigned long __val)=delete
LSET(const BASE_SET &aOther)
Definition: lset.h:56
bool Contains(PCB_LAYER_ID aLayer)
See if the layer set contains a PCB layer.
Definition: lset.h:79
void RunOnLayers(const std::function< void(PCB_LAYER_ID)> &aFunction) const
Execute a function on each layer of the LSET.
Definition: lset.h:252
LSET()
Create an empty (cleared) set.
Definition: lset.h:51
#define KICOMMON_API
Definition: kicommon.h:28
#define MAX_CU_LAYERS
Definition: layer_ids.h:142
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ UNDEFINED_LAYER
Definition: layer_ids.h:61
@ PCB_LAYER_ID_COUNT
Definition: layer_ids.h:137
void Flip(T &aValue)