KiCad PCB EDA Suite
Loading...
Searching...
No Matches
fab_sections.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 FAB_SECTIONS_H
21#define FAB_SECTIONS_H
22
23#include <bitset>
24#include <initializer_list>
25#include <optional>
26#include <wx/string.h>
27
29
30namespace FAB
31{
32
61
64
72
74class SECTION_SET : public std::bitset<static_cast<size_t>( SECTION::COUNT )>
75{
76public:
77 using BASE = std::bitset<static_cast<size_t>( SECTION::COUNT )>;
78
79 SECTION_SET() = default;
80
81 // The inherited bitset operators return BASE and this converts the result back
82 SECTION_SET( const BASE& aBits ) : BASE( aBits ) {}
83
84 SECTION_SET( std::initializer_list<SECTION> aSections )
85 {
86 for( SECTION section : aSections )
87 Set( section );
88 }
89
90 bool Contains( SECTION aSection ) const { return test( static_cast<size_t>( aSection ) ); }
91
92 SECTION_SET& Set( SECTION aSection, bool aOn = true )
93 {
94 set( static_cast<size_t>( aSection ), aOn );
95 return *this;
96 }
97};
98
100char SectionKeyChar( SECTION aSection );
101
103std::optional<SECTION> SectionFromKeyChar( char aKey );
104
106SECTION_RULE SectionRule( MODE aMode, SECTION aSection );
107
109SECTION_SET RequiredSections( MODE aMode );
110
112SECTION_SET OptionalSections( MODE aMode );
113
115SECTION_SET RecommendedOptionalSections( MODE aMode );
116
118SECTION_SET UnsupportedSections();
119
125SECTION_SET LegacySections();
126
128bool NeedsCadData( const SECTION_SET& aSet );
129
131wxString SectionKeyString( const SECTION_SET& aSet );
132
134bool SectionSetFromKeyString( const wxString& aKey, SECTION_SET& aResult );
135
137wxString ModeToken( MODE aMode );
138
140std::optional<MODE> ModeFromToken( const wxString& aToken );
141
142} // namespace FAB
143
144#endif
SECTION_SET & Set(SECTION aSection, bool aOn=true)
SECTION_SET(std::initializer_list< SECTION > aSections)
std::bitset< static_cast< size_t >(SECTION::COUNT)> BASE
bool Contains(SECTION aSection) const
SECTION_SET()=default
SECTION_SET(const BASE &aBits)
DATA_SET
Columns of the IPC-2581C function mode table, Table 4 p 80.
std::optional< SECTION > SectionFromKeyChar(char aKey)
Return the schema section for a Table 4 key character.
JOB_EXPORT_PCB_FAB::DATA_SET MODE
Columns of Table 4 The job owns the enum so that every layer shares one type.
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_RULE
Table 4 cell values N O and Y.
SECTION
Schema sections of the IPC-2581C function mode table, Table 4 p 80.
SECTION_SET RequiredSections(MODE aMode)
Schema sections that Table 4 marks Y for aMode.
bool SectionSetFromKeyString(const wxString &aKey, SECTION_SET &aResult)
Read a sectionKey attribute value Return false for an unknown character.
SECTION_SET OptionalSections(MODE aMode)
Schema sections that Table 4 marks O for aMode.
SECTION_SET RecommendedOptionalSections(MODE aMode)
Optional schema sections that aMode selects by default.
SECTION_SET UnsupportedSections()
Schema sections that no KiCad board supplies.
std::optional< MODE > ModeFromToken(const wxString &aToken)
Read a Table 4 function mode token in upper case or in lower case.
wxString ModeToken(MODE aMode)
Table 4 function mode token such as FABRICATION.
SECTION_SET LegacySections()
Schema sections of the content that KiCad wrote before the function modes.
bool NeedsCadData(const SECTION_SET &aSet)
True if an included schema section needs an Ecad/CadData element.
char SectionKeyChar(SECTION aSection)
Return the Table 4 key character for aSection.