KiCad PCB EDA Suite
cleanup_item.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #ifndef CLEANUP_ITEM_H
25 #define CLEANUP_ITEM_H
26 
27 #include <drc/drc_item.h>
28 
29 class PCB_BASE_FRAME;
30 
31 
47 };
48 
49 class CLEANUP_ITEM : public RC_ITEM
50 {
51 public:
52  CLEANUP_ITEM( int aErrorCode );
53 
57  wxString GetErrorText( int aErrorCode = -1, bool aTranslate = true ) const;
58 
59 private:
60  wxString m_errorMessage;
61 };
62 
63 
70 {
71 public:
72  VECTOR_CLEANUP_ITEMS_PROVIDER( std::vector<std::shared_ptr<CLEANUP_ITEM> >* aList ) :
73  m_sourceVector( aList )
74  {
75  }
76 
77  void SetSeverities( int aSeverities ) override
78  {
79  }
80 
81  int GetCount( int aSeverity = -1 ) const override
82  {
83  return m_sourceVector->size();
84  }
85 
86  std::shared_ptr<RC_ITEM> GetItem( int aIndex ) const override
87  {
88  return m_sourceVector->at( aIndex );
89  }
90 
91  std::shared_ptr<CLEANUP_ITEM> GetCleanupItem( int aIndex )
92  {
93  return m_sourceVector->at( aIndex );
94  }
95 
96 
97  void DeleteItem( int aIndex, bool aDeep ) override
98  {
99  if( aDeep )
100  {
101  auto item = m_sourceVector->at( aIndex );
102  m_sourceVector->erase( m_sourceVector->begin() + aIndex );
103  }
104  }
105 
106  void DeleteAllItems( bool aIncludeExclusions, bool aDeep ) override
107  {
108  if( aDeep )
109  {
110  m_sourceVector->clear();
111  }
112  }
113 
114 private:
115  std::vector<std::shared_ptr<CLEANUP_ITEM> >* m_sourceVector; // owns its CLEANUP_ITEMs
116 };
117 
118 
119 
120 #endif // CLEANUP_ITEM_H
CLEANUP_ITEM(int aErrorCode)
A holder for a rule check item, DRC in Pcbnew or ERC in Eeschema.
Definition: rc_item.h:74
VECTOR_CLEANUP_ITEMS_PROVIDER(std::vector< std::shared_ptr< CLEANUP_ITEM > > *aList)
Definition: cleanup_item.h:72
int GetCount(int aSeverity=-1) const override
Definition: cleanup_item.h:81
void DeleteAllItems(bool aIncludeExclusions, bool aDeep) override
Definition: cleanup_item.h:106
void DeleteItem(int aIndex, bool aDeep) override
Remove (and optionally deletes) the indexed item from the list.
Definition: cleanup_item.h:97
Provide an abstract interface of a RC_ITEM* list manager.
Definition: rc_item.h:45
wxString GetErrorText() const
Definition: rc_item.h:145
std::shared_ptr< RC_ITEM > GetItem(int aIndex) const override
Retrieve a RC_ITEM by index.
Definition: cleanup_item.h:86
std::vector< std::shared_ptr< CLEANUP_ITEM > > * m_sourceVector
Definition: cleanup_item.h:115
An implementation of the interface named RC_ITEMS_PROVIDER which uses a vector of pointers to CLEANUP...
Definition: cleanup_item.h:69
void SetSeverities(int aSeverities) override
Definition: cleanup_item.h:77
std::shared_ptr< CLEANUP_ITEM > GetCleanupItem(int aIndex)
Definition: cleanup_item.h:91
CLEANUP_RC_CODE
Definition: cleanup_item.h:32
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
wxString m_errorMessage
Definition: cleanup_item.h:60