KiCad PCB EDA Suite
lib_collectors.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) 2011 Wayne Stambaugh <stambaughw@verizon.net>
5  * Copyright (C) 2011 KiCad Developers, see change_log.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #ifndef _LIB_COLLECTORS_H_
26 #define _LIB_COLLECTORS_H_
27 
28 
29 #include <class_collector.h>
30 #include <class_libentry.h>
31 
32 class LIB_COLLECTOR;
33 
35 {
36  int m_unit;
37  int m_convert;
38 
39  friend class LIB_COLLECTOR;
40 
41 public:
43  m_unit( 0 ),
44  m_convert( 0 ) {}
45 };
46 
47 
51 class LIB_COLLECTOR : public COLLECTOR
52 {
54 
55 public:
56 
60  static const KICAD_T AllItems[];
61 
65  static const KICAD_T EditableItems[];
66 
70  static const KICAD_T MovableItems[];
71 
75  static const KICAD_T RotatableItems[];
76 
80  static const KICAD_T AllItemsButPins[];
81 
86  {
87  SetScanTypes( aScanTypes );
88  }
89 
97  LIB_ITEM* operator[]( int aIndex ) const
98  {
99  if( (unsigned)aIndex < (unsigned)GetCount() )
100  return (LIB_ITEM*) m_List[ aIndex ];
101 
102  return NULL;
103  }
104 
115  SEARCH_RESULT Inspect( EDA_ITEM* aItem, void* aTestData ) override;
116 
128  void Collect( LIB_ITEMS_CONTAINER& aItem, const KICAD_T aFilterList[], const wxPoint& aPosition,
129  int aUnit = 0, int aConvert = 0 );
130 };
131 
132 
133 #endif // _LIB_COLLECTORS_H_
LIB_ITEM * operator[](int aIndex) const
Operator [] overloads COLLECTOR::operator[](int) to return a LIB_ITEM* instead of an EDA_ITEM* type...
int GetCount() const
Function GetCount returns the number of objects in the list.
Class LIB_COLLECTOR.
void SetScanTypes(const KICAD_T *scanTypes)
Function SetScanTypes records the list of KICAD_T types to consider for collection by the Inspect() f...
LIB_COLLECTOR(const KICAD_T *aScanTypes=LIB_COLLECTOR::AllItems)
Constructor LIB_COLLECTOR.
static const KICAD_T AllItemsButPins[]
A scan list for all schematic items except pins.
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
static const KICAD_T EditableItems[]
A scan list for all editable schematic items.
Class LIB_ITEM is the base class for drawable items used by schematic library components.
Definition: lib_draw_item.h:67
static const KICAD_T RotatableItems[]
A scan list for all rotatable schematic items.
static const KICAD_T AllItems[]
A scan list for all schematic items.
COLLECTOR class definition.
Class LIB_ITEM definition.
static const KICAD_T MovableItems[]
A scan list for all movable schematic items.
void Collect(LIB_ITEMS_CONTAINER &aItem, const KICAD_T aFilterList[], const wxPoint &aPosition, int aUnit=0, int aConvert=0)
Function Collect scans a SCH_ITEM using this class's Inspector method, which does the collection...
LIB_COLLECTOR_DATA m_data
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:165
Class COLLECTOR is an abstract class that will find and hold all the objects according to an inspecti...
SEARCH_RESULT
Definition: base_struct.h:82
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
SEARCH_RESULT Inspect(EDA_ITEM *aItem, void *aTestData) override
Function Inspect is the examining function within the INSPECTOR which is passed to the Iterate functi...