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=NULL, 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 39 of file pns_itemset.h.

Member Typedef Documentation

◆ ENTRIES

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

Definition at line 96 of file pns_itemset.h.

Constructor & Destructor Documentation

◆ ITEM_SET() [1/2]

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

Definition at line 98 of file pns_itemset.h.

99  {
100  if( aInitialItem )
101  m_items.emplace_back( ENTRY( aInitialItem, aBecomeOwner ) );
102  }
ENTRIES m_items
Definition: pns_itemset.h:231

References m_items.

◆ ITEM_SET() [2/2]

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

Definition at line 104 of file pns_itemset.h.

105  {
106  m_items = aOther.m_items;
107  }
ENTRIES m_items
Definition: pns_itemset.h:231

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 181 of file pns_itemset.h.

182  {
183  m_items.emplace_back( ENTRY( aItem, aBecomeOwner ) );
184  }
ENTRIES m_items
Definition: pns_itemset.h:231

References m_items.

◆ begin()

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

Definition at line 176 of file pns_itemset.h.

176 { return m_items.begin(); }
ENTRIES m_items
Definition: pns_itemset.h:231

References m_items.

◆ cbegin()

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

Definition at line 178 of file pns_itemset.h.

178 { return m_items.cbegin(); }
ENTRIES m_items
Definition: pns_itemset.h:231

References m_items.

◆ cend()

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

Definition at line 179 of file pns_itemset.h.

179 { return m_items.cend(); }
ENTRIES m_items
Definition: pns_itemset.h:231

References m_items.

◆ CItems()

◆ Clear()

◆ Contains()

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

Definition at line 196 of file pns_itemset.h.

197  {
198  const ENTRY ent( aItem );
199  return alg::contains( m_items, ent );
200  }
ENTRIES m_items
Definition: pns_itemset.h:231
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:81

References alg::contains(), and m_items.

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

◆ Count()

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

Definition at line 117 of file pns_itemset.h.

118  {
119  int n = 0;
120 
121  if( aKindMask == -1 || aKindMask == ITEM::ANY_T )
122  return static_cast<int>( m_items.size() );
123 
124  for( ITEM* item : m_items )
125  {
126  if( item->Kind() & aKindMask )
127  n++;
128  }
129 
130  return n;
131  }
ENTRIES m_items
Definition: pns_itemset.h:231

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

Definition at line 133 of file pns_itemset.h.

134  {
135  return m_items.empty();
136  }
ENTRIES m_items
Definition: pns_itemset.h:231

References m_items.

Referenced by PNS::DRAGGER::dragViaMarkObstacles(), PNS::DRAGGER::dragViaWalkaround(), PNS::DRAGGER::Start(), and PNS::ROUTER::StartDragging().

◆ end()

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

Definition at line 177 of file pns_itemset.h.

177 { return m_items.end(); }
ENTRIES m_items
Definition: pns_itemset.h:231

References m_items.

◆ Erase()

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

Definition at line 202 of file pns_itemset.h.

203  {
204  ENTRY ent( aItem );
205  ENTRIES::iterator f = std::find( m_items.begin(), m_items.end(), ent );
206 
207  if( f != m_items.end() )
208  m_items.erase( f );
209  }
ENTRIES m_items
Definition: pns_itemset.h:231

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:96
ENTRIES m_items
Definition: pns_itemset.h:231

References m_items.

Referenced by PNS_KICAD_IFACE_BASE::inheritTrackWidth().

◆ ExcludeKinds()

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

Definition at line 151 of file pns_itemset.h.

152  {
153  return FilterKinds( aKindMask, true );
154  }
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 146 of file pns_itemset.h.

147  {
148  return FilterLayers( aStart, aEnd, true );
149  }
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 156 of file pns_itemset.h.

157  {
158  return FilterNet( aNet, true );
159  }
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 }
std::vector< ENTRY > ENTRIES
Definition: pns_itemset.h:96
ENTRIES m_items
Definition: pns_itemset.h:231

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;
49  LAYER_RANGE l;
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 }
std::vector< ENTRY > ENTRIES
Definition: pns_itemset.h:96
ENTRIES m_items
Definition: pns_itemset.h:231
Represent a contiguous set of PCB layers.
Definition: pns_layerset.h:31

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 }
std::vector< ENTRY > ENTRIES
Definition: pns_itemset.h:96
ENTRIES m_items
Definition: pns_itemset.h:231

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 }
std::vector< ENTRY > ENTRIES
Definition: pns_itemset.h:96
ENTRIES m_items
Definition: pns_itemset.h:231

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 212 of file pns_itemset.h.

213  {
214  int n = 0;
215 
216  for( const ITEM* item : m_items )
217  {
218  if( item->OfKind( kind ) )
219  {
220  if( index == n )
221  return static_cast<T*>( item );
222  else
223  n++;
224  }
225  }
226 
227  return NULL;
228  }
ENTRIES m_items
Definition: pns_itemset.h:231
#define NULL

References m_items, and NULL.

◆ Items()

◆ operator=()

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

Definition at line 111 of file pns_itemset.h.

112  {
113  m_items = aOther.m_items;
114  return *this;
115  }
ENTRIES m_items
Definition: pns_itemset.h:231

References m_items.

◆ operator[]()

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

Definition at line 171 of file pns_itemset.h.

172  {
173  return m_items[aIndex].item;
174  }
ENTRIES m_items
Definition: pns_itemset.h:231

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 }
ENTRIES m_items
Definition: pns_itemset.h:231

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 186 of file pns_itemset.h.

187  {
188  m_items.emplace( m_items.begin(), ENTRY( aItem, aBecomeOwner ) );
189  }
ENTRIES m_items
Definition: pns_itemset.h:231

References m_items.

◆ Size()

int PNS::ITEM_SET::Size ( ) const
inline

Member Data Documentation

◆ m_items


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