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 m_items.

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

Definition at line 106 of file pns_itemset.h.

References m_items.

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

Definition at line 27 of file pns_itemset.cpp.

28 {
29 }

Member Function Documentation

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

Definition at line 175 of file pns_itemset.h.

References m_items.

176  {
177  m_items.push_back( ENTRY( aItem, aBecomeOwner ) );
178  }
ENTRIES m_items
Definition: pns_itemset.h:226
void PNS::ITEM_SET::Clear ( )
inline
bool PNS::ITEM_SET::Contains ( ITEM aItem) const
inline

Definition at line 190 of file pns_itemset.h.

References m_items.

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

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

Definition at line 119 of file pns_itemset.h.

References m_items.

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

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

Definition at line 132 of file pns_itemset.h.

References m_items.

133  {
134  return m_items.empty();
135  }
ENTRIES m_items
Definition: pns_itemset.h:226
void PNS::ITEM_SET::Erase ( ITEM aItem)
inline

Definition at line 196 of file pns_itemset.h.

References m_items.

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

197  {
198  ENTRY ent( aItem );
199  ENTRIES::iterator f = std::find( m_items.begin(), m_items.end(), ent );
200 
201  if( f != m_items.end() )
202  m_items.erase( f );
203  }
ENTRIES m_items
Definition: pns_itemset.h:226
ITEM_SET & PNS::ITEM_SET::ExcludeItem ( const ITEM aItem)

Definition at line 124 of file pns_itemset.cpp.

References m_items.

Referenced by 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:226
ITEM_SET& PNS::ITEM_SET::ExcludeKinds ( int  aKindMask)
inline

Definition at line 150 of file pns_itemset.h.

References FilterKinds().

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

References FilterLayers().

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

References FilterNet().

156  {
157  return FilterNet( aNet, true );
158  }
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 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:226
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 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:226
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.

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:226
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 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:226
template<class T >
T* PNS::ITEM_SET::FindByKind ( ITEM::PnsKind  kind,
int  index = 0 
)
inline

Definition at line 206 of file pns_itemset.h.

References m_items.

207  {
208  int n = 0;
209 
210  for( const ITEM* item : m_items )
211  {
212  if( item->OfKind( kind ) )
213  {
214  if( index == n )
215  return static_cast<T*>( item );
216  else
217  n++;
218  }
219  }
220 
221  return NULL;
222  }
T
enum T contains all this lexer's tokens.
ENTRIES m_items
Definition: pns_itemset.h:226
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:226
ITEM* PNS::ITEM_SET::operator[] ( int  index) const
inline

Definition at line 170 of file pns_itemset.h.

References m_items.

171  {
172  return m_items[index].item;
173  }
ENTRIES m_items
Definition: pns_itemset.h:226
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().

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

Definition at line 180 of file pns_itemset.h.

References m_items.

181  {
182  m_items.insert( m_items.begin(), ENTRY( aItem, aBecomeOwner ) );
183  }
ENTRIES m_items
Definition: pns_itemset.h:226
int PNS::ITEM_SET::Size ( ) const
inline

Definition at line 162 of file pns_itemset.h.

References m_items.

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

163  {
164  return m_items.size();
165  }
ENTRIES m_items
Definition: pns_itemset.h:226

Member Data Documentation


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