2019-01-11 22:03:45 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018 KiCad Developers, see change_log.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef DRC_PROVIDER__H
|
|
|
|
#define DRC_PROVIDER__H
|
|
|
|
|
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_marker_pcb.h>
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2020-01-10 14:31:00 +00:00
|
|
|
* that represents a DRC "provider" which runs some
|
2019-01-11 22:03:45 +00:00
|
|
|
* DRC functions over a #BOARD and spits out #PCB_MARKERs as needed.
|
|
|
|
*/
|
|
|
|
class DRC_PROVIDER
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* A callable that can handle a single generated PCB_MARKER
|
|
|
|
*/
|
|
|
|
using MARKER_HANDLER = std::function<void( MARKER_PCB* )>;
|
|
|
|
|
|
|
|
// This class can be handled by base pointer
|
|
|
|
virtual ~DRC_PROVIDER()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Runs this provider against the given PCB with
|
|
|
|
* configured options (if any).
|
|
|
|
*
|
|
|
|
* Note: Board is non-const, as some DRC functions modify the board
|
|
|
|
* (e.g. zone fill or polygon coalescing)
|
|
|
|
*/
|
2020-02-28 00:05:40 +00:00
|
|
|
virtual bool RunDRC( EDA_UNITS aUnits, BOARD& aBoard ) const = 0;
|
2019-01-11 22:03:45 +00:00
|
|
|
|
|
|
|
protected:
|
2020-02-28 00:05:40 +00:00
|
|
|
DRC_PROVIDER( MARKER_HANDLER aMarkerHandler ) :
|
|
|
|
m_marker_handler( std::move( aMarkerHandler ) )
|
|
|
|
{
|
|
|
|
}
|
2019-01-11 22:03:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Pass a given marker to the marker handler
|
|
|
|
*/
|
2020-02-28 00:05:40 +00:00
|
|
|
void HandleMarker( std::unique_ptr<MARKER_PCB> aMarker ) const
|
|
|
|
{
|
|
|
|
// The marker hander currently takes a raw pointer,
|
|
|
|
// but it also assumes ownership
|
|
|
|
m_marker_handler( aMarker.release() );
|
|
|
|
}
|
2019-01-11 22:03:45 +00:00
|
|
|
|
|
|
|
|
2020-02-28 00:05:40 +00:00
|
|
|
private:
|
2019-01-11 22:03:45 +00:00
|
|
|
/// The handler for any generated markers
|
|
|
|
MARKER_HANDLER m_marker_handler;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // DRC_PROVIDER__H
|