22 #ifndef __PNS_ITEMSET_H
23 #define __PNS_ITEMSET_H
44 ENTRY( ITEM* aItem,
bool aOwned =
false ) :
49 ENTRY(
const ENTRY& aOther )
54 item = aOther.item->Clone();
65 bool operator== (
const ENTRY& b )
const
67 return item == b.item;
70 bool operator< (
const ENTRY& b )
const
75 ENTRY& operator= (
const ENTRY& aOther )
80 item = aOther.item->Clone();
87 operator ITEM* ()
const
96 typedef std::vector<ENTRY> ENTRIES;
98 ITEM_SET( ITEM* aInitialItem = NULL,
bool aBecomeOwner =
false )
102 m_items.push_back( ENTRY( aInitialItem, aBecomeOwner ) );
106 ITEM_SET(
const ITEM_SET& aOther )
108 m_items = aOther.m_items;
113 ITEM_SET& operator=(
const ITEM_SET& aOther )
115 m_items = aOther.m_items;
119 int Count(
int aKindMask = -1 )
const
123 if( aKindMask == -1 || aKindMask == ITEM::ANY_T )
124 return m_items.size();
126 for( ITEM* item : m_items )
128 if( item->Kind() & aKindMask )
137 return m_items.empty();
140 ENTRIES& Items() {
return m_items; }
141 const ENTRIES& CItems()
const {
return m_items; }
143 ITEM_SET& FilterLayers(
int aStart,
int aEnd = -1,
bool aInvert =
false );
144 ITEM_SET& FilterKinds(
int aKindMask,
bool aInvert =
false );
145 ITEM_SET& FilterNet(
int aNet,
bool aInvert =
false );
146 ITEM_SET& FilterMarker(
int aMarker,
bool aInvert =
false );
148 ITEM_SET& ExcludeLayers(
int aStart,
int aEnd = -1 )
150 return FilterLayers( aStart, aEnd,
true );
153 ITEM_SET& ExcludeKinds(
int aKindMask )
155 return FilterKinds( aKindMask,
true );
158 ITEM_SET& ExcludeNet(
int aNet )
160 return FilterNet( aNet,
true );
163 ITEM_SET& ExcludeItem(
const ITEM* aItem );
167 return m_items.size();
170 void Add(
const LINE& aLine );
171 void Prepend(
const LINE& aLine );
173 ITEM* operator[] (
int index )
const
175 return m_items[index].item;
178 void Add( ITEM* aItem,
bool aBecomeOwner =
false )
180 m_items.push_back( ENTRY( aItem, aBecomeOwner ) );
183 void Prepend( ITEM* aItem,
bool aBecomeOwner =
false )
185 m_items.insert( m_items.begin(), ENTRY( aItem, aBecomeOwner ) );
193 bool Contains( ITEM* aItem )
const
195 const ENTRY ent( aItem );
196 return std::find( m_items.begin(), m_items.end(), ent ) != m_items.end();
199 void Erase( ITEM* aItem )
202 ENTRIES::iterator f = std::find( m_items.begin(), m_items.end(), ent );
204 if( f != m_items.end() )
213 for(
const ITEM* item : m_items )
215 if( item->OfKind( kind ) )
218 return static_cast<T*
>( item );