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 ()
 
const 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[] (int index) 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

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

Definition at line 96 of file pns_itemset.h.

Constructor & Destructor Documentation

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

Definition at line 98 of file pns_itemset.h.

References PNS::ITEM_SET::ENTRY::ENTRY(), and m_items.

99  {
100  if( aInitialItem )
101  {
102  m_items.push_back( ENTRY( aInitialItem, aBecomeOwner ) );
103  }
104  }
ENTRIES m_items
Definition: pns_itemset.h:229
PNS::ITEM_SET::ITEM_SET ( const ITEM_SET aOther)
inline

Definition at line 106 of file pns_itemset.h.

References m_items, and ~ITEM_SET().

107  {
108  m_items = aOther.m_items;
109  }
ENTRIES m_items
Definition: pns_itemset.h:229
PNS::ITEM_SET::~ITEM_SET ( )

Definition at line 27 of file pns_itemset.cpp.

Referenced by ITEM_SET().

28 {
29 }

Member Function Documentation

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

Definition at line 178 of file pns_itemset.h.

References PNS::ITEM_SET::ENTRY::ENTRY(), and m_items.

179  {
180  m_items.push_back( ENTRY( aItem, aBecomeOwner ) );
181  }
ENTRIES m_items
Definition: pns_itemset.h:229
void PNS::ITEM_SET::Clear ( )
inline
bool PNS::ITEM_SET::Contains ( ITEM aItem) const
inline

Definition at line 193 of file pns_itemset.h.

References m_items.

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

194  {
195  const ENTRY ent( aItem );
196  return std::find( m_items.begin(), m_items.end(), ent ) != m_items.end();
197  }
ENTRIES m_items
Definition: pns_itemset.h:229
int PNS::ITEM_SET::Count ( int  aKindMask = -1) const
inline

Definition at line 119 of file pns_itemset.h.

References PNS::ITEM::ANY_T, PNS::ITEM_SET::ENTRY::item, PNS::ITEM::Kind(), and m_items.

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

120  {
121  int n = 0;
122 
123  if( aKindMask == -1 || aKindMask == ITEM::ANY_T )
124  return m_items.size();
125 
126  for( ITEM* item : m_items )
127  {
128  if( item->Kind() & aKindMask )
129  n++;
130  }
131 
132  return n;
133  }
ENTRIES m_items
Definition: pns_itemset.h:229
bool PNS::ITEM_SET::Empty ( ) const
inline

Definition at line 135 of file pns_itemset.h.

References m_items.

136  {
137  return m_items.empty();
138  }
ENTRIES m_items
Definition: pns_itemset.h:229
void PNS::ITEM_SET::Erase ( ITEM aItem)
inline

Definition at line 199 of file pns_itemset.h.

References m_items.

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

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  }
ENTRIES m_items
Definition: pns_itemset.h:229
ITEM_SET & PNS::ITEM_SET::ExcludeItem ( const ITEM aItem)

Definition at line 124 of file pns_itemset.cpp.

References m_items.

Referenced by ExcludeNet(), and PNS::SIZES_SETTINGS::inheritTrackWidth().

125 {
126  ENTRIES newItems;
127 
128  for( const ENTRY& ent : m_items )
129  {
130  if( ent.item != aItem )
131 
132  newItems.push_back( ent );
133  }
134 
135  m_items = newItems;
136 
137  return *this;
138 }
std::vector< ENTRY > ENTRIES
Definition: pns_itemset.h:96
ENTRIES m_items
Definition: pns_itemset.h:229
ITEM_SET& PNS::ITEM_SET::ExcludeKinds ( int  aKindMask)
inline

Definition at line 153 of file pns_itemset.h.

References FilterKinds().

154  {
155  return FilterKinds( aKindMask, true );
156  }
ITEM_SET & FilterKinds(int aKindMask, bool aInvert=false)
Definition: pns_itemset.cpp:70
ITEM_SET& PNS::ITEM_SET::ExcludeLayers ( int  aStart,
int  aEnd = -1 
)
inline

Definition at line 148 of file pns_itemset.h.

References FilterLayers().

149  {
150  return FilterLayers( aStart, aEnd, true );
151  }
ITEM_SET & FilterLayers(int aStart, int aEnd=-1, bool aInvert=false)
Definition: pns_itemset.cpp:46
ITEM_SET& PNS::ITEM_SET::ExcludeNet ( int  aNet)
inline

Definition at line 158 of file pns_itemset.h.

References ExcludeItem(), and FilterNet().

159  {
160  return FilterNet( aNet, true );
161  }
ITEM_SET & FilterNet(int aNet, bool aInvert=false)
ITEM_SET & PNS::ITEM_SET::FilterKinds ( int  aKindMask,
bool  aInvert = false 
)

Definition at line 70 of file pns_itemset.cpp.

References m_items.

Referenced by CItems(), ExcludeKinds(), and PNS::SIZES_SETTINGS::inheritTrackWidth().

71 {
72  ENTRIES newItems;
73 
74  for( const ENTRY& ent : m_items )
75  {
76  if( ent.item->OfKind( aKindMask ) ^ aInvert )
77  {
78  newItems.push_back( ent );
79  }
80  }
81 
82  m_items = newItems;
83 
84  return *this;
85 }
std::vector< ENTRY > ENTRIES
Definition: pns_itemset.h:96
ENTRIES m_items
Definition: pns_itemset.h:229
ITEM_SET & PNS::ITEM_SET::FilterLayers ( int  aStart,
int  aEnd = -1,
bool  aInvert = false 
)

Definition at line 46 of file pns_itemset.cpp.

References m_items.

Referenced by CItems(), and ExcludeLayers().

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  {
60  newItems.push_back( ent );
61  }
62  }
63 
64  m_items = newItems;
65 
66  return *this;
67 }
std::vector< ENTRY > ENTRIES
Definition: pns_itemset.h:96
ENTRIES m_items
Definition: pns_itemset.h:229
Class LAYER_RANGE.
Definition: pns_layerset.h:32
ITEM_SET & PNS::ITEM_SET::FilterMarker ( int  aMarker,
bool  aInvert = false 
)

Definition at line 88 of file pns_itemset.cpp.

References m_items.

Referenced by CItems().

89 {
90  ENTRIES newItems;
91 
92  for( const ENTRY& ent : m_items )
93  {
94  if( ent.item->Marker() & aMarker )
95  {
96  newItems.push_back( ent );
97  }
98  }
99 
100  m_items = newItems;
101 
102  return *this;
103 }
std::vector< ENTRY > ENTRIES
Definition: pns_itemset.h:96
ENTRIES m_items
Definition: pns_itemset.h:229
ITEM_SET & PNS::ITEM_SET::FilterNet ( int  aNet,
bool  aInvert = false 
)

Definition at line 106 of file pns_itemset.cpp.

References m_items.

Referenced by CItems(), and ExcludeNet().

107 {
108  ENTRIES newItems;
109 
110  for( const ENTRY& ent : m_items )
111  {
112  if( ( ent.item->Net() == aNet ) ^ aInvert )
113  {
114  newItems.push_back( ent );
115  }
116  }
117 
118  m_items = newItems;
119 
120  return *this;
121 }
std::vector< ENTRY > ENTRIES
Definition: pns_itemset.h:96
ENTRIES m_items
Definition: pns_itemset.h:229
template<class T >
T* PNS::ITEM_SET::FindByKind ( ITEM::PnsKind  kind,
int  index = 0 
)
inline

Definition at line 209 of file pns_itemset.h.

References PNS::ITEM_SET::ENTRY::item, m_items, and PNS::ITEM::OfKind().

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 NULL;
225  }
ENTRIES m_items
Definition: pns_itemset.h:229
const ITEM_SET& PNS::ITEM_SET::operator= ( const ITEM_SET aOther)
inline

Definition at line 113 of file pns_itemset.h.

References m_items.

114  {
115  m_items = aOther.m_items;
116  return *this;
117  }
ENTRIES m_items
Definition: pns_itemset.h:229
ITEM* PNS::ITEM_SET::operator[] ( int  index) const
inline

Definition at line 173 of file pns_itemset.h.

References m_items.

174  {
175  return m_items[index].item;
176  }
ENTRIES m_items
Definition: pns_itemset.h:229
void PNS::ITEM_SET::Prepend ( const LINE aLine)

Definition at line 39 of file pns_itemset.cpp.

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

Referenced by PNS::TOPOLOGY::followTrivialPath(), and Size().

40 {
41  LINE* copy = aLine.Clone();
42  m_items.insert( m_items.begin(), ENTRY( copy, true ) );
43 }
ENTRIES m_items
Definition: pns_itemset.h:229
void PNS::ITEM_SET::Prepend ( ITEM aItem,
bool  aBecomeOwner = false 
)
inline

Definition at line 183 of file pns_itemset.h.

References PNS::ITEM_SET::ENTRY::ENTRY(), and m_items.

184  {
185  m_items.insert( m_items.begin(), ENTRY( aItem, aBecomeOwner ) );
186  }
ENTRIES m_items
Definition: pns_itemset.h:229
int PNS::ITEM_SET::Size ( ) const
inline

Definition at line 165 of file pns_itemset.h.

References Add(), m_items, and Prepend().

Referenced by PNS::JOINT::IsLineCorner(), PNS::JOINT::IsNonFanoutVia(), PNS::JOINT::IsTraceWidthChange(), and PNS::JOINT::Unlink().

166  {
167  return m_items.size();
168  }
ENTRIES m_items
Definition: pns_itemset.h:229

Member Data Documentation


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