KiCad PCB EDA Suite
footprint_filter.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) 2017 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 FOOTPRINT_FILTER_H
21 #define FOOTPRINT_FILTER_H
22 
23 #include <boost/iterator/iterator_facade.hpp>
24 #include <eda_pattern_match.h>
25 #include <footprint_info.h>
26 
27 
33 {
34 public:
41 
47 
51  void SetList( FOOTPRINT_LIST& aList );
52 
56  void ClearFilters();
57 
61  void FilterByLibrary( wxString const& aLibName );
62 
66  void FilterByPinCount( int aPinCount );
67 
71  void FilterByFootprintFilters( wxArrayString const& aFilters );
72 
77  void FilterByPattern( wxString const& aPattern );
78 
82  class ITERATOR
83  : public boost::iterator_facade<ITERATOR, FOOTPRINT_INFO, boost::forward_traversal_tag>
84  {
85  public:
86  ITERATOR();
87  ITERATOR( ITERATOR const& aOther );
88  ITERATOR( FOOTPRINT_FILTER& aFilter );
89 
90  private:
92  friend class FOOTPRINT_FILTER;
93 
94  void increment();
95  bool equal( ITERATOR const& aOther ) const;
96  FOOTPRINT_INFO& dereference() const;
97 
98  size_t m_pos;
100 
104  bool FootprintFilterMatch( FOOTPRINT_INFO& aItem );
105 
109  bool PinCountMatch( FOOTPRINT_INFO& aItem );
110  };
111 
115  ITERATOR begin();
116 
121  ITERATOR end();
122 
123 private:
128  enum FP_FILTER_T : int
129  {
135  };
136 
138 
139  wxString m_lib_name;
144 
145  std::vector<std::unique_ptr<EDA_PATTERN_MATCH>> m_footprint_filters;
146 };
147 
148 #endif // FOOTPRINT_FILTER_H
void SetList(FOOTPRINT_LIST &aList)
Set the list to filter.
void FilterByPattern(wxString const &aPattern)
Add a pattern to filter by name, including wildcards and optionally a colon-delimited library name...
void FilterByFootprintFilters(wxArrayString const &aFilters)
Set a list of footprint filters to filter by.
void ClearFilters()
Clear all filter criteria.
bool PinCountMatch(FOOTPRINT_INFO &aItem)
Check if the stored component matches an item by pin count.
void FilterByLibrary(wxString const &aLibName)
Add library name to filter criteria.
Abstract pattern-matching tool and implementations.
ITERATOR end()
Get an iterator to the end of the filtered view.
void FilterByPinCount(int aPinCount)
Set a pin count to filter by.
ITERATOR begin()
Get an iterator to the beginning of the filtered view.
std::vector< std::unique_ptr< EDA_PATTERN_MATCH > > m_footprint_filters
bool FootprintFilterMatch(FOOTPRINT_INFO &aItem)
Check if the stored component matches an item by footprint filter.
bool equal(ITERATOR const &aOther) const
Footprint display filter.
EDA_PATTERN_MATCH_WILDCARD m_filter
Holds a list of FOOTPRINT_INFO objects, along with a list of IO_ERRORs or PARSE_ERRORs that were thro...
FOOTPRINT_INFO & dereference() const
FOOTPRINT_LIST * m_list
friend class boost::iterator_core_access
FOOTPRINT_FILTER * m_filter
FOOTPRINT_FILTER()
Construct a filter without assigning a footprint list.
FP_FILTER_T
Filter setting constants.
Inner iterator class returned by begin() and end().