KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ipc2581_function_mode.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 The 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
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef IPC2581_FUNCTION_MODE_H
21#define IPC2581_FUNCTION_MODE_H
22
23#include <bitset>
24#include <initializer_list>
25#include <optional>
26#include <vector>
27
28#include <layer_ids.h>
29#include <wx/string.h>
30
31namespace IPC2581
32{
33
62
77
85
87enum class REVISION
88{
91};
92
111
113class SECTION_SET : public std::bitset<static_cast<size_t>( SECTION::COUNT )>
114{
115public:
116 using BASE = std::bitset<static_cast<size_t>( SECTION::COUNT )>;
117
118 SECTION_SET() = default;
119
120 // The inherited bitset operators return BASE and this converts the result back
121 SECTION_SET( const BASE& aBits ) : BASE( aBits ) {}
122
123 SECTION_SET( std::initializer_list<SECTION> aSections )
124 {
125 for( SECTION section : aSections )
126 Set( section );
127 }
128
129 bool Contains( SECTION aSection ) const { return test( static_cast<size_t>( aSection ) ); }
130
131 SECTION_SET& Set( SECTION aSection, bool aOn = true )
132 {
133 set( static_cast<size_t>( aSection ), aOn );
134 return *this;
135 }
136};
137
139class SUPPRESS_SET : public std::bitset<static_cast<size_t>( SUPPRESS::COUNT )>
140{
141public:
142 bool Contains( SUPPRESS aWhat ) const { return test( static_cast<size_t>( aWhat ) ); }
143
144 SUPPRESS_SET& Set( SUPPRESS aWhat, bool aOn = true )
145 {
146 set( static_cast<size_t>( aWhat ), aOn );
147 return *this;
148 }
149};
150
153{
154 std::optional<SECTION> m_section;
155 std::optional<SECTION> m_requires;
156 wxString m_message;
157};
158
160{
163 std::vector<CONFLICT> m_conflicts;
164
165 bool Ok() const { return m_conflicts.empty(); }
166};
167
169char SectionKeyChar( SECTION aSection );
170
172std::optional<SECTION> SectionFromKeyChar( char aKey );
173
175SECTION_RULE SectionRule( MODE aMode, SECTION aSection );
176
178SECTION_SET RequiredSections( MODE aMode );
179
181SECTION_SET OptionalSections( MODE aMode );
182
184SECTION_SET RecommendedOptionalSections( MODE aMode );
185
187SECTION_SET UnsupportedSections();
188
194SECTION_SET LegacySections();
195
197bool NeedsCadData( const SECTION_SET& aSet );
198
200wxString SectionKeyString( const SECTION_SET& aSet );
201
203bool SectionSetFromKeyString( const wxString& aKey, SECTION_SET& aResult );
204
206wxString ModeToken( MODE aMode );
207
209std::optional<MODE> ModeFromToken( const wxString& aToken );
210
216bool ModeSupported( MODE aMode, REVISION aRevision );
217
219std::optional<SECTION> SectionForBoardLayer( PCB_LAYER_ID aLayer );
220
226std::optional<SECTION> SectionForLayerFunction( const wxString& aLayerFunction,
227 const wxString& aSide = wxEmptyString );
228
236RESOLVE_RESULT ResolveSections( REVISION aRevision, MODE aMode, const SECTION_SET& aRequested );
237
238} // namespace IPC2581
239
240#endif // IPC2581_FUNCTION_MODE_H
#define REVISION
Definition 3d_plugin.h:36
Set of schema sections.
bool Contains(SECTION aSection) const
std::bitset< static_cast< size_t >(SECTION::COUNT)> BASE
SECTION_SET(std::initializer_list< SECTION > aSections)
SECTION_SET & Set(SECTION aSection, bool aOn=true)
SECTION_SET(const BASE &aBits)
Set of removed attributes.
bool Contains(SUPPRESS aWhat) const
SUPPRESS_SET & Set(SUPPRESS aWhat, bool aOn=true)
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
MODE
Columns of Table 4.
SECTION_SET RecommendedOptionalSections(MODE aMode)
Optional schema sections that aMode selects by default.
wxString ModeToken(MODE aMode)
Table 4 function mode token such as FABRICATION.
SECTION_SET UnsupportedSections()
Schema sections that no KiCad board supplies.
bool SectionSetFromKeyString(const wxString &aKey, SECTION_SET &aResult)
Read a sectionKey attribute value Return false for an unknown character.
std::optional< SECTION > SectionFromKeyChar(char aKey)
Return the schema section for a Table 4 key character.
SECTION_SET RequiredSections(MODE aMode)
Schema sections that Table 4 marks Y for aMode.
SECTION_SET LegacySections()
Schema sections of the content that KiCad wrote before the function modes.
SECTION_RULE
Table 4 cell values N O and Y.
SECTION
Schema sections of the IPC-2581C function mode table, Table 4 p 80.
RESOLVE_RESULT ResolveSections(REVISION aRevision, MODE aMode, const SECTION_SET &aRequested)
Compare aRequested with Table 4 and give the attributes to remove and the conflicts.
char SectionKeyChar(SECTION aSection)
Return the Table 4 key character for aSection.
REVISION
Schema revision The two revisions declare different identity constraints.
std::optional< SECTION > SectionForLayerFunction(const wxString &aLayerFunction, const wxString &aSide)
Schema section that holds the layers with aLayerFunction.
bool NeedsCadData(const SECTION_SET &aSet)
True if an included schema section needs an Ecad/CadData element.
bool ModeSupported(MODE aMode, REVISION)
True if KiCad can write aMode for aRevision.
SUPPRESS
Optional attributes to remove when their schema section is absent.
@ PINREF_COMPONENTREF
Pad/PinRef@componentRef and LogicalNet/PinRef@componentRef.
@ BOM_HEADER_STEPREF
Bom/BomHeader/StepRef.
@ COMPONENT_REFDES
Component@refDes.
@ PAD_PADSTACKDEFREF
Pad@padstackDefRef, and the PadStackDef elements themselves.
@ COMPONENT_PACKAGEREF
Component@packageRef.
@ BOM_REFDES_PACKAGEREF
Bom/BomItem/RefDes@packageRef.
@ BOM_REFDES
Bom/BomItem/RefDes and all its attributes.
@ BOM_REFDES_LAYERREF
Bom/BomItem/RefDes@layerRef.
wxString SectionKeyString(const SECTION_SET &aSet)
Give aSet as a sectionKey attribute value.
SECTION_RULE SectionRule(MODE aMode, SECTION aSection)
Return the Table 4 cell for aMode and aSection.
SECTION_SET OptionalSections(MODE aMode)
Schema sections that Table 4 marks O for aMode.
std::optional< MODE > ModeFromToken(const wxString &aToken)
Read a Table 4 function mode token in upper case or in lower case.
std::optional< SECTION > SectionForBoardLayer(PCB_LAYER_ID aLayer)
Schema section that holds the artwork of aLayer.
A requested combination that no legal file can hold.
std::optional< SECTION > m_section
std::optional< SECTION > m_requires
std::vector< CONFLICT > m_conflicts