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_results_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< std::shared_ptr< DRC_ITEM > > *aList)
 
void SetSeverities (int aSeverities) override
 
int GetCount (int aSeverity=-1) override
 
std::shared_ptr< RC_ITEMGetItem (int aIndex) override
 Retrieve a RC_ITEM by index. More...
 
void DeleteItem (int aIndex, bool aDeep) override
 Remove (and optionally deletes) the indexed item from the list. More...
 
void DeleteAllItems (bool aIncludeExclusions, bool aDeep) override
 

Private Attributes

PCB_BASE_FRAMEm_frame
 
std::vector< std::shared_ptr< DRC_ITEM > > * m_sourceVector
 
int m_severities
 
std::vector< std::shared_ptr< 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 135 of file drc_results_provider.h.

Constructor & Destructor Documentation

◆ VECTOR_DRC_ITEMS_PROVIDER()

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

Definition at line 145 of file drc_results_provider.h.

145  :
146  m_frame( aFrame ),
147  m_sourceVector( aList ),
148  m_severities( 0 )
149  {
150  }
std::vector< std::shared_ptr< DRC_ITEM > > * m_sourceVector

Member Function Documentation

◆ DeleteAllItems()

void VECTOR_DRC_ITEMS_PROVIDER::DeleteAllItems ( bool  aIncludeExclusions,
bool  aDeep 
)
inlineoverridevirtual

Implements RC_ITEMS_PROVIDER.

Definition at line 213 of file drc_results_provider.h.

214  {
215  if( aDeep )
216  {
217  m_sourceVector->clear();
218  }
219 
220  m_filteredVector.clear(); // no ownership of DRC_ITEM pointers
221  }
std::vector< std::shared_ptr< DRC_ITEM > > m_filteredVector
std::vector< std::shared_ptr< DRC_ITEM > > * m_sourceVector

References m_filteredVector, and m_sourceVector.

◆ DeleteItem()

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

Remove (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 195 of file drc_results_provider.h.

196  {
197  auto item = m_filteredVector[aIndex];
198  m_filteredVector.erase( m_filteredVector.begin() + aIndex );
199 
200  if( aDeep )
201  {
202  for( size_t i = 0; i < m_sourceVector->size(); ++i )
203  {
204  if( m_sourceVector->at( i ) == item )
205  {
206  m_sourceVector->erase( m_sourceVector->begin() + i );
207  break;
208  }
209  }
210  }
211  }
std::vector< std::shared_ptr< DRC_ITEM > > m_filteredVector
std::vector< std::shared_ptr< DRC_ITEM > > * m_sourceVector

References m_filteredVector, and m_sourceVector.

◆ GetCount()

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

Implements RC_ITEMS_PROVIDER.

Definition at line 170 of file drc_results_provider.h.

171  {
172  if( aSeverity < 0 )
173  return m_filteredVector.size();
174 
175  int count = 0;
177 
178  if( m_sourceVector )
179  {
180  for( auto item : *m_sourceVector )
181  {
182  if( bds.GetSeverity( item->GetErrorCode() ) == aSeverity )
183  count++;
184  }
185  }
186 
187  return count;
188  }
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: class_board.h:558
std::vector< std::shared_ptr< DRC_ITEM > > m_filteredVector
std::vector< std::shared_ptr< DRC_ITEM > > * m_sourceVector
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()

std::shared_ptr<RC_ITEM> VECTOR_DRC_ITEMS_PROVIDER::GetItem ( int  aIndex)
inlineoverridevirtual

Retrieve a RC_ITEM by index.

Implements RC_ITEMS_PROVIDER.

Definition at line 190 of file drc_results_provider.h.

191  {
192  return (m_filteredVector)[aIndex];
193  }
std::vector< std::shared_ptr< DRC_ITEM > > m_filteredVector

References m_filteredVector.

◆ SetSeverities()

void VECTOR_DRC_ITEMS_PROVIDER::SetSeverities ( int  aSeverities)
inlineoverridevirtual

Implements RC_ITEMS_PROVIDER.

Definition at line 152 of file drc_results_provider.h.

153  {
154  m_severities = aSeverities;
155 
157 
158  m_filteredVector.clear();
159 
160  if( m_sourceVector )
161  {
162  for( auto item : *m_sourceVector )
163  {
164  if( bds.GetSeverity( item->GetErrorCode() ) & aSeverities )
165  m_filteredVector.push_back( item );
166  }
167  }
168  }
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: class_board.h:558
std::vector< std::shared_ptr< DRC_ITEM > > m_filteredVector
std::vector< std::shared_ptr< DRC_ITEM > > * m_sourceVector
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<std::shared_ptr<DRC_ITEM> > VECTOR_DRC_ITEMS_PROVIDER::m_filteredVector
private

Definition at line 141 of file drc_results_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 137 of file drc_results_provider.h.

Referenced by GetCount(), and SetSeverities().

◆ m_severities

int VECTOR_DRC_ITEMS_PROVIDER::m_severities
private

Definition at line 140 of file drc_results_provider.h.

Referenced by SetSeverities().

◆ m_sourceVector

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

Definition at line 138 of file drc_results_provider.h.

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


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