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 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 private:
52  wxString m_errorMessage;
53 
54 public:
55  CLEANUP_ITEM( int aErrorCode );
56 
61  wxString GetErrorText( int aErrorCode = -1, bool aTranslate = true ) const;
62 };
63 
64 
72 {
73  std::vector<std::shared_ptr<CLEANUP_ITEM> >* m_sourceVector; // owns its CLEANUP_ITEMs
74 
75 public:
76 
77  VECTOR_CLEANUP_ITEMS_PROVIDER( std::vector<std::shared_ptr<CLEANUP_ITEM> >* aList ) :
78  m_sourceVector( aList )
79  {
80  }
81 
82  void SetSeverities( int aSeverities ) override
83  {
84  }
85 
86  int GetCount( int aSeverity = -1 ) override
87  {
88  return m_sourceVector->size();
89  }
90 
91  std::shared_ptr<RC_ITEM> GetItem( int aIndex ) override
92  {
93  return m_sourceVector->at( aIndex );
94  }
95 
96  std::shared_ptr<CLEANUP_ITEM> GetCleanupItem( int aIndex )
97  {
98  return m_sourceVector->at( aIndex );
99  }
100 
101 
102  void DeleteItem( int aIndex, bool aDeep ) override
103  {
104  if( aDeep )
105  {
106  auto item = m_sourceVector->at( aIndex );
107  m_sourceVector->erase( m_sourceVector->begin() + aIndex );
108  }
109  }
110 
111  void DeleteAllItems( bool aIncludeExclusions, bool aDeep ) override
112  {
113  if( aDeep )
114  {
115  m_sourceVector->clear();
116  }
117  }
118 };
119 
120 
121 
122 #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:72
VECTOR_CLEANUP_ITEMS_PROVIDER(std::vector< std::shared_ptr< CLEANUP_ITEM > > *aList)
Definition: cleanup_item.h:77
int GetCount(int aSeverity=-1) override
Definition: cleanup_item.h:86
void DeleteAllItems(bool aIncludeExclusions, bool aDeep) override
Definition: cleanup_item.h:111
void DeleteItem(int aIndex, bool aDeep) override
Remove (and optionally deletes) the indexed item from the list.
Definition: cleanup_item.h:102
Provide an abstract interface of a RC_ITEM* list manager.
Definition: rc_item.h:43
wxString GetErrorText() const
Definition: rc_item.h:160
std::vector< std::shared_ptr< CLEANUP_ITEM > > * m_sourceVector
Definition: cleanup_item.h:73
VECTOR_CLEANUP_ITEMS_PROVIDER is an implementation of the interface named RC_ITEMS_PROVIDER which use...
Definition: cleanup_item.h:71
std::shared_ptr< RC_ITEM > GetItem(int aIndex) override
Retrieve a RC_ITEM by index.
Definition: cleanup_item.h:91
void SetSeverities(int aSeverities) override
Definition: cleanup_item.h:82
std::shared_ptr< CLEANUP_ITEM > GetCleanupItem(int aIndex)
Definition: cleanup_item.h:96
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:52