/* * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2020-2023 KiCad Developers. * * 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 */ // WARNING - this Tom's crappy PNS hack tool code. Please don't complain about its quality // (unless you want to improve it). #ifndef __PNS_LOG_FILE_H #define __PNS_LOG_FILE_H #include #include #include #include #include #include #include #include #include #include #include #include #include class PNS_LOG_FILE { public: PNS_LOG_FILE(); ~PNS_LOG_FILE() {} struct COMMIT_STATE { COMMIT_STATE(){}; COMMIT_STATE( const COMMIT_STATE& aOther ) : m_removedIds( aOther.m_removedIds ), m_addedItems( aOther.m_addedItems ), m_heads( aOther.m_heads ) { } std::set m_removedIds; std::vector m_addedItems; std::vector m_heads; bool Compare( const COMMIT_STATE& aOther ); }; // Saves a P&S event log only (e.g. after fixing a bug and wanting a new "golden" commit state) bool SaveLog( const wxFileName& logFileName, REPORTER* aRpt ); // Loads a P&S event log and the associated board file. These two always go together. bool Load( const wxFileName& logFileName, REPORTER* aRpt ); BOARD_CONNECTED_ITEM* ItemById( const PNS::LOGGER::EVENT_ENTRY& evt ); std::vector& Events() { return m_events; } void SetBoard( std::shared_ptr brd ) { m_board = brd; } std::shared_ptr GetBoard() const { return m_board; } PNS::ROUTING_SETTINGS* GetRoutingSettings() const { return m_routerSettings.get(); } const COMMIT_STATE& GetExpectedResult() const { return m_commitState; } void SetExpectedResult( const COMMIT_STATE& aCommitState, std::vector> aParsedItems ) { m_commitState = aCommitState; m_parsed_items = std::move( aParsedItems ); } PNS::ROUTER_MODE GetMode() const { return m_mode; } void SetMode( PNS::ROUTER_MODE aMode ) { m_mode = aMode; } private: bool parseCommonPnsProps( PNS::ITEM* aItem, const wxString& cmd, wxStringTokenizer& aTokens ); std::unique_ptr parsePnsSegmentFromString( wxStringTokenizer& aTokens ); std::unique_ptr parsePnsViaFromString( wxStringTokenizer& aTokens ); std::unique_ptr parseItemFromString( wxStringTokenizer& aTokens ); std::shared_ptr parseShape( SHAPE_TYPE expectedType, wxStringTokenizer& aTokens ); private: std::shared_ptr m_settingsMgr; std::unique_ptr m_routerSettings; std::vector m_events; std::shared_ptr m_board; COMMIT_STATE m_commitState; std::vector> m_parsed_items; PNS::ROUTER_MODE m_mode; }; #endif