KiCad PCB EDA Suite
PNS::ITEM_SET Class Reference

#include <pns_itemset.h>

Classes

struct  ENTRY
 

Public Types

typedef std::vector< ENTRYENTRIES
 

Public Member Functions

 ITEM_SET (ITEM *aInitialItem=nullptr, bool aBecomeOwner=false)
 
 ITEM_SET (const ITEM_SET &aOther)
 
 ~ITEM_SET ()
 
ITEM_SEToperator= (const ITEM_SET &aOther)
 
int Count (int aKindMask=-1) const
 
bool Empty () const
 
ENTRIESItems ()
 
const ENTRIESCItems () const
 
ITEM_SETFilterLayers (int aStart, int aEnd=-1, bool aInvert=false)
 
ITEM_SETFilterKinds (int aKindMask, bool aInvert=false)
 
ITEM_SETFilterNet (int aNet, bool aInvert=false)
 
ITEM_SETFilterMarker (int aMarker, bool aInvert=false)
 
ITEM_SETExcludeLayers (int aStart, int aEnd=-1)
 
ITEM_SETExcludeKinds (int aKindMask)
 
ITEM_SETExcludeNet (int aNet)
 
ITEM_SETExcludeItem (const ITEM *aItem)
 
int Size () const
 
void Add (const LINE &aLine)
 
void Prepend (const LINE &aLine)
 
ITEMoperator[] (size_t aIndex) const
 
ENTRIES::iterator begin ()
 
ENTRIES::iterator end ()
 
ENTRIES::const_iterator cbegin () const
 
ENTRIES::const_iterator cend () const
 
void Add (ITEM *aItem, bool aBecomeOwner=false)
 
void Prepend (ITEM *aItem, bool aBecomeOwner=false)
 
void Clear ()
 
bool Contains (ITEM *aItem) const
 
void Erase (ITEM *aItem)
 
template<class T >
T * FindByKind (ITEM::PnsKind kind, int index=0)
 

Private Attributes

ENTRIES m_items
 

Detailed Description

Definition at line 36 of file pns_itemset.h.

Member Typedef Documentation

◆ ENTRIES

typedef std::vector<ENTRY> PNS::ITEM_SET::ENTRIES

Definition at line 93 of file pns_itemset.h.

Constructor & Destructor Documentation

◆ ITEM_SET() [1/2]

PNS::ITEM_SET::ITEM_SET ( ITEM aInitialItem = nullptr,
bool  aBecomeOwner = false 
)
inline

Definition at line 95 of file pns_itemset.h.

96 {
97 if( aInitialItem )
98 m_items.emplace_back( ENTRY( aInitialItem, aBecomeOwner ) );
99 }
ENTRIES m_items
Definition: pns_itemset.h:228

References m_items.

◆ ITEM_SET() [2/2]

PNS::ITEM_SET::ITEM_SET ( const ITEM_SET aOther)
inline

Definition at line 101 of file pns_itemset.h.

102 {
103 m_items = aOther.m_items;
104 }

References m_items.

◆ ~ITEM_SET()

PNS::ITEM_SET::~ITEM_SET ( )

Definition at line 27 of file pns_itemset.cpp.

28{
29}

Member Function Documentation

◆ Add() [1/2]

◆ Add() [2/2]

void PNS::ITEM_SET::Add ( ITEM aItem,
bool  aBecomeOwner = false 
)
inline

Definition at line 178 of file pns_itemset.h.

179 {
180 m_items.emplace_back( ENTRY( aItem, aBecomeOwner ) );
181 }

References m_items.

◆ begin()

ENTRIES::iterator PNS::ITEM_SET::begin ( )
inline

Definition at line 173 of file pns_itemset.h.

173{ return m_items.begin(); }

References m_items.

◆ cbegin()

ENTRIES::const_iterator PNS::ITEM_SET::cbegin ( ) const
inline

Definition at line 175 of file pns_itemset.h.

175{ return m_items.cbegin(); }

References m_items.

◆ cend()

ENTRIES::const_iterator PNS::ITEM_SET::cend ( ) const
inline

Definition at line 176 of file pns_itemset.h.

176{ return m_items.cend(); }

References m_items.

◆ CItems()

◆ Clear()

◆ Contains()

bool PNS::ITEM_SET::Contains ( ITEM aItem) const
inline

Definition at line 193 of file pns_itemset.h.

194 {
195 const ENTRY ent( aItem );
196 return alg::contains( m_items, ent );
197 }
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:99

References alg::contains(), and m_items.

Referenced by PNS::JOINT::Link(), PNS::ROUTER::markViolations(), and PNS::COMPONENT_DRAGGER::Start().

◆ Count()

int PNS::ITEM_SET::Count ( int  aKindMask = -1) const
inline

Definition at line 114 of file pns_itemset.h.

115 {
116 int n = 0;
117
118 if( aKindMask == -1 || aKindMask == ITEM::ANY_T )
119 return static_cast<int>( m_items.size() );
120
121 for( ITEM* item : m_items )
122 {
123 if( item->Kind() & aKindMask )
124 n++;
125 }
126
127 return n;
128 }

References PNS::ITEM::ANY_T, and m_items.

Referenced by PNS::JOINT::IsLineCorner(), PNS::JOINT::IsNonFanoutVia(), PNS::JOINT::IsStitchingVia(), PNS::JOINT::IsTraceWidthChange(), PNS::JOINT::LinkCount(), and PNS::ROUTER::StartDragging().

◆ Empty()

bool PNS::ITEM_SET::Empty ( ) const
inline

◆ end()

ENTRIES::iterator PNS::ITEM_SET::end ( )
inline

Definition at line 174 of file pns_itemset.h.

174{ return m_items.end(); }

References m_items.

◆ Erase()

void PNS::ITEM_SET::Erase ( ITEM aItem)
inline

Definition at line 199 of file pns_itemset.h.

200 {
201 ENTRY ent( aItem );
202 ENTRIES::iterator f = std::find( m_items.begin(), m_items.end(), ent );
203
204 if( f != m_items.end() )
205 m_items.erase( f );
206 }

References m_items.

Referenced by PNS::JOINT::Unlink().

◆ ExcludeItem()

ITEM_SET & PNS::ITEM_SET::ExcludeItem ( const ITEM aItem)

Definition at line 116 of file pns_itemset.cpp.

117{
118 ENTRIES newItems;
119
120 for( const ENTRY& ent : m_items )
121 {
122 if( ent.item != aItem )
123 newItems.push_back( ent );
124 }
125
126 m_items = newItems;
127
128 return *this;
129}
std::vector< ENTRY > ENTRIES
Definition: pns_itemset.h:93

References m_items.

Referenced by PNS_KICAD_IFACE_BASE::inheritTrackWidth().

◆ ExcludeKinds()

ITEM_SET & PNS::ITEM_SET::ExcludeKinds ( int  aKindMask)
inline

Definition at line 148 of file pns_itemset.h.

149 {
150 return FilterKinds( aKindMask, true );
151 }
ITEM_SET & FilterKinds(int aKindMask, bool aInvert=false)
Definition: pns_itemset.cpp:68

References FilterKinds().

◆ ExcludeLayers()

ITEM_SET & PNS::ITEM_SET::ExcludeLayers ( int  aStart,
int  aEnd = -1 
)
inline

Definition at line 143 of file pns_itemset.h.

144 {
145 return FilterLayers( aStart, aEnd, true );
146 }
ITEM_SET & FilterLayers(int aStart, int aEnd=-1, bool aInvert=false)
Definition: pns_itemset.cpp:46

References FilterLayers().

◆ ExcludeNet()

ITEM_SET & PNS::ITEM_SET::ExcludeNet ( int  aNet)
inline

Definition at line 153 of file pns_itemset.h.

154 {
155 return FilterNet( aNet, true );
156 }
ITEM_SET & FilterNet(int aNet, bool aInvert=false)

References FilterNet().

◆ FilterKinds()

ITEM_SET & PNS::ITEM_SET::FilterKinds ( int  aKindMask,
bool  aInvert = false 
)

Definition at line 68 of file pns_itemset.cpp.

69{
70 ENTRIES newItems;
71
72 for( const ENTRY& ent : m_items )
73 {
74 if( ent.item->OfKind( aKindMask ) ^ aInvert )
75 newItems.push_back( ent );
76 }
77
78 m_items = newItems;
79
80 return *this;
81}

References m_items.

Referenced by ExcludeKinds(), and PNS_KICAD_IFACE_BASE::inheritTrackWidth().

◆ FilterLayers()

ITEM_SET & PNS::ITEM_SET::FilterLayers ( int  aStart,
int  aEnd = -1,
bool  aInvert = false 
)

Definition at line 46 of file pns_itemset.cpp.

47{
48 ENTRIES newItems;
50
51 if( aEnd < 0 )
52 l = LAYER_RANGE( aStart );
53 else
54 l = LAYER_RANGE( aStart, aEnd );
55
56 for( const ENTRY& ent : m_items )
57 {
58 if( ent.item->Layers().Overlaps( l ) ^ aInvert )
59 newItems.push_back( ent );
60 }
61
62 m_items = newItems;
63
64 return *this;
65}
Represent a contiguous set of PCB layers.
Definition: pns_layerset.h:32

References m_items.

Referenced by ExcludeLayers().

◆ FilterMarker()

ITEM_SET & PNS::ITEM_SET::FilterMarker ( int  aMarker,
bool  aInvert = false 
)

Definition at line 84 of file pns_itemset.cpp.

85{
86 ENTRIES newItems;
87
88 for( const ENTRY& ent : m_items )
89 {
90 if( ent.item->Marker() & aMarker )
91 newItems.push_back( ent );
92 }
93
94 m_items = newItems;
95
96 return *this;
97}

References m_items.

◆ FilterNet()

ITEM_SET & PNS::ITEM_SET::FilterNet ( int  aNet,
bool  aInvert = false 
)

Definition at line 100 of file pns_itemset.cpp.

101{
102 ENTRIES newItems;
103
104 for( const ENTRY& ent : m_items )
105 {
106 if( ( ent.item->Net() == aNet ) ^ aInvert )
107 newItems.push_back( ent );
108 }
109
110 m_items = newItems;
111
112 return *this;
113}

References m_items.

Referenced by ExcludeNet().

◆ FindByKind()

template<class T >
T * PNS::ITEM_SET::FindByKind ( ITEM::PnsKind  kind,
int  index = 0 
)
inline

Definition at line 209 of file pns_itemset.h.

210 {
211 int n = 0;
212
213 for( const ITEM* item : m_items )
214 {
215 if( item->OfKind( kind ) )
216 {
217 if( index == n )
218 return static_cast<T*>( item );
219 else
220 n++;
221 }
222 }
223
224 return nullptr;
225 }

References m_items.

◆ Items()

◆ operator=()

ITEM_SET & PNS::ITEM_SET::operator= ( const ITEM_SET aOther)
inline

Definition at line 108 of file pns_itemset.h.

109 {
110 m_items = aOther.m_items;
111 return *this;
112 }

References m_items.

◆ operator[]()

ITEM * PNS::ITEM_SET::operator[] ( size_t  aIndex) const
inline

Definition at line 168 of file pns_itemset.h.

169 {
170 return m_items[aIndex].item;
171 }

References m_items.

◆ Prepend() [1/2]

void PNS::ITEM_SET::Prepend ( const LINE aLine)

Definition at line 39 of file pns_itemset.cpp.

40{
41 LINE* copy = aLine.Clone();
42 m_items.emplace( m_items.begin(), ENTRY( copy, true ) );
43}

References PNS::LINE::Clone(), copy, and m_items.

Referenced by PNS::TOPOLOGY::followTrivialPath().

◆ Prepend() [2/2]

void PNS::ITEM_SET::Prepend ( ITEM aItem,
bool  aBecomeOwner = false 
)
inline

Definition at line 183 of file pns_itemset.h.

184 {
185 m_items.emplace( m_items.begin(), ENTRY( aItem, aBecomeOwner ) );
186 }

References m_items.

◆ Size()

Member Data Documentation

◆ m_items


The documentation for this class was generated from the following files: