KiCad PCB EDA Suite
VECTOR_DRC_ITEMS_PROVIDER Class Reference

VECTOR_DRC_ITEMS_PROVIDER is an implementation of the interface named DRC_ITEMS_PROVIDER which uses a vector of pointers to DRC_ITEMs to fulfill the interface. More...

#include <drc_provider.h>

Inheritance diagram for VECTOR_DRC_ITEMS_PROVIDER:
RC_ITEMS_PROVIDER RATSNEST_DRC_ITEMS_PROVIDER

Public Member Functions

 VECTOR_DRC_ITEMS_PROVIDER (PCB_BASE_FRAME *aFrame, std::vector< DRC_ITEM * > *aList)
 
void SetSeverities (int aSeverities) override
 
int GetCount (int aSeverity=-1) override
 
DRC_ITEMGetItem (int aIndex) override
 Function GetItem retrieves a RC_ITEM by index. More...
 
void DeleteItem (int aIndex, bool aDeep) override
 Function DeleteItem removes (and optionally deletes) the indexed item from the list. More...
 
void DeleteAllItems () override
 Function DeleteAllItems removes and deletes all the items in the list. More...
 

Private Attributes

PCB_BASE_FRAMEm_frame
 
std::vector< DRC_ITEM * > * m_sourceVector
 
int m_severities
 
std::vector< DRC_ITEM * > m_filteredVector
 

Detailed Description

VECTOR_DRC_ITEMS_PROVIDER is an implementation of the interface named DRC_ITEMS_PROVIDER which uses a vector of pointers to DRC_ITEMs to fulfill the interface.

No ownership is taken of the vector.

Definition at line 176 of file drc_provider.h.

Constructor & Destructor Documentation

◆ VECTOR_DRC_ITEMS_PROVIDER()

VECTOR_DRC_ITEMS_PROVIDER::VECTOR_DRC_ITEMS_PROVIDER ( PCB_BASE_FRAME aFrame,
std::vector< DRC_ITEM * > *  aList 
)
inline

Definition at line 186 of file drc_provider.h.

186  :
187  m_frame( aFrame ),
188  m_sourceVector( aList ),
189  m_severities( 0 )
190  {
191  }
std::vector< DRC_ITEM * > * m_sourceVector
Definition: drc_provider.h:179
PCB_BASE_FRAME * m_frame
Definition: drc_provider.h:178

Member Function Documentation

◆ DeleteAllItems()

void VECTOR_DRC_ITEMS_PROVIDER::DeleteAllItems ( )
inlineoverridevirtual

Function DeleteAllItems removes and deletes all the items in the list.

Implements RC_ITEMS_PROVIDER.

Definition at line 255 of file drc_provider.h.

256  {
257  if( m_sourceVector )
258  {
259  for( DRC_ITEM* item : *m_sourceVector )
260  delete item;
261 
262  m_sourceVector->clear();
263  }
264 
265  m_filteredVector.clear(); // no ownership of DRC_ITEM pointers
266  }
std::vector< DRC_ITEM * > m_filteredVector
Definition: drc_provider.h:182
std::vector< DRC_ITEM * > * m_sourceVector
Definition: drc_provider.h:179

References m_filteredVector, and m_sourceVector.

◆ DeleteItem()

void VECTOR_DRC_ITEMS_PROVIDER::DeleteItem ( int  aIndex,
bool  aDeep 
)
inlineoverridevirtual

Function DeleteItem removes (and optionally deletes) the indexed item from the list.

Parameters
aDeepIf true, the source item should be deleted as well as its entry in the list.

Implements RC_ITEMS_PROVIDER.

Definition at line 236 of file drc_provider.h.

237  {
238  DRC_ITEM* item = m_filteredVector[aIndex];
239  m_filteredVector.erase( m_filteredVector.begin() + aIndex );
240 
241  if( aDeep )
242  {
243  for( size_t i = 0; i < m_sourceVector->size(); ++i )
244  {
245  if( m_sourceVector->at( i ) == item )
246  {
247  delete item;
248  m_sourceVector->erase( m_sourceVector->begin() + i );
249  break;
250  }
251  }
252  }
253  }
std::vector< DRC_ITEM * > m_filteredVector
Definition: drc_provider.h:182
std::vector< DRC_ITEM * > * m_sourceVector
Definition: drc_provider.h:179

References m_filteredVector, and m_sourceVector.

◆ GetCount()

int VECTOR_DRC_ITEMS_PROVIDER::GetCount ( int  aSeverity = -1)
inlineoverridevirtual

Implements RC_ITEMS_PROVIDER.

Definition at line 211 of file drc_provider.h.

212  {
213  if( aSeverity < 0 )
214  return m_filteredVector.size();
215 
216  int count = 0;
218 
219  if( m_sourceVector )
220  {
221  for( DRC_ITEM* item : *m_sourceVector )
222  {
223  if( bds.GetSeverity( item->GetErrorCode() ) == aSeverity )
224  count++;
225  }
226  }
227 
228  return count;
229  }
std::vector< DRC_ITEM * > m_filteredVector
Definition: drc_provider.h:182
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:551
std::vector< DRC_ITEM * > * m_sourceVector
Definition: drc_provider.h:179
PCB_BASE_FRAME * m_frame
Definition: drc_provider.h:178
BOARD * GetBoard() const
int GetSeverity(int aDRCErrorCode)
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.

References PCB_BASE_FRAME::GetBoard(), BOARD::GetDesignSettings(), BOARD_DESIGN_SETTINGS::GetSeverity(), m_filteredVector, m_frame, and m_sourceVector.

◆ GetItem()

DRC_ITEM* VECTOR_DRC_ITEMS_PROVIDER::GetItem ( int  aIndex)
inlineoverridevirtual

Function GetItem retrieves a RC_ITEM by index.

Implements RC_ITEMS_PROVIDER.

Definition at line 231 of file drc_provider.h.

232  {
233  return (m_filteredVector)[aIndex];
234  }
std::vector< DRC_ITEM * > m_filteredVector
Definition: drc_provider.h:182

References m_filteredVector.

◆ SetSeverities()

void VECTOR_DRC_ITEMS_PROVIDER::SetSeverities ( int  aSeverities)
inlineoverridevirtual

Implements RC_ITEMS_PROVIDER.

Definition at line 193 of file drc_provider.h.

194  {
195  m_severities = aSeverities;
196 
198 
199  m_filteredVector.clear();
200 
201  if( m_sourceVector )
202  {
203  for( DRC_ITEM* item : *m_sourceVector )
204  {
205  if( bds.GetSeverity( item->GetErrorCode() ) & aSeverities )
206  m_filteredVector.push_back( item );
207  }
208  }
209  }
std::vector< DRC_ITEM * > m_filteredVector
Definition: drc_provider.h:182
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:551
std::vector< DRC_ITEM * > * m_sourceVector
Definition: drc_provider.h:179
PCB_BASE_FRAME * m_frame
Definition: drc_provider.h:178
BOARD * GetBoard() const
int GetSeverity(int aDRCErrorCode)
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.

References PCB_BASE_FRAME::GetBoard(), BOARD::GetDesignSettings(), BOARD_DESIGN_SETTINGS::GetSeverity(), m_filteredVector, m_frame, m_severities, and m_sourceVector.

Member Data Documentation

◆ m_filteredVector

std::vector<DRC_ITEM*> VECTOR_DRC_ITEMS_PROVIDER::m_filteredVector
private

Definition at line 182 of file drc_provider.h.

Referenced by DeleteAllItems(), DeleteItem(), GetCount(), GetItem(), and SetSeverities().

◆ m_frame

PCB_BASE_FRAME* VECTOR_DRC_ITEMS_PROVIDER::m_frame
private

Definition at line 178 of file drc_provider.h.

Referenced by GetCount(), and SetSeverities().

◆ m_severities

int VECTOR_DRC_ITEMS_PROVIDER::m_severities
private

Definition at line 181 of file drc_provider.h.

Referenced by SetSeverities().

◆ m_sourceVector

std::vector<DRC_ITEM*>* VECTOR_DRC_ITEMS_PROVIDER::m_sourceVector
private

Definition at line 179 of file drc_provider.h.

Referenced by DeleteAllItems(), DeleteItem(), GetCount(), and SetSeverities().


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