KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pns_log_file.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-2023 KiCad Developers.
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
25// WARNING - this Tom's crappy PNS hack tool code. Please don't complain about its quality
26// (unless you want to improve it).
27
28#ifndef __PNS_LOG_FILE_H
29#define __PNS_LOG_FILE_H
30
31#include <memory>
32#include <vector>
33#include <set>
34
35#include <wx/filename.h>
36
37#include <kiid.h>
38#include <math/vector2d.h>
39
40#include <router/pns_logger.h>
41#include <router/pns_router.h>
42#include <router/pns_item.h>
44
45#include <pcbnew/board.h>
47
49
51{
52public:
55
57 {
59 COMMIT_STATE( const COMMIT_STATE& aOther ) :
61 m_heads( aOther.m_heads )
62 {
63 }
64
65 std::set<KIID> m_removedIds;
66 std::vector<PNS::ITEM*> m_addedItems;
67 std::vector<PNS::ITEM*> m_heads;
68
69 bool Compare( const COMMIT_STATE& aOther );
70 };
71
72 // Saves a P&S event log only (e.g. after fixing a bug and wanting a new "golden" commit state)
73 bool SaveLog( const wxFileName& logFileName, REPORTER* aRpt );
74
75 // Loads a P&S event log and the associated board file. These two always go together.
76 bool Load( const wxFileName& logFileName, REPORTER* aRpt );
77
79
80 std::vector<PNS::LOGGER::EVENT_ENTRY>& Events() { return m_events; }
81
82 void SetBoard( std::shared_ptr<BOARD> brd ) { m_board = brd; }
83 std::shared_ptr<BOARD> GetBoard() const { return m_board; }
84
86
87 const COMMIT_STATE& GetExpectedResult() const { return m_commitState; }
88
89 void SetExpectedResult( const COMMIT_STATE& aCommitState,
90 std::vector<std::unique_ptr<PNS::ITEM>> aParsedItems )
91 {
92 m_commitState = aCommitState;
93 m_parsed_items = std::move( aParsedItems );
94 }
95
96 PNS::ROUTER_MODE GetMode() const { return m_mode; }
97
98 void SetMode( PNS::ROUTER_MODE aMode ) { m_mode = aMode; }
99
100private:
101 bool parseCommonPnsProps( PNS::ITEM* aItem, const wxString& cmd, wxStringTokenizer& aTokens );
102
103 std::unique_ptr<PNS::SEGMENT> parsePnsSegmentFromString( wxStringTokenizer& aTokens );
104
105 std::unique_ptr<PNS::VIA> parsePnsViaFromString( wxStringTokenizer& aTokens );
106
107 std::unique_ptr<PNS::ITEM> parseItemFromString( wxStringTokenizer& aTokens );
108
109 std::shared_ptr<SHAPE> parseShape( SHAPE_TYPE expectedType, wxStringTokenizer& aTokens );
110
111private:
112 std::shared_ptr<SETTINGS_MANAGER> m_settingsMgr;
113 std::unique_ptr<PNS::ROUTING_SETTINGS> m_routerSettings;
114 std::vector<PNS::LOGGER::EVENT_ENTRY> m_events;
115 std::shared_ptr<BOARD> m_board;
117 std::vector<std::unique_ptr<PNS::ITEM>> m_parsed_items;
119};
120
121#endif
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
Base class for PNS router board items.
Definition: pns_item.h:97
Contain all persistent settings of the router, such as the mode, optimization effort,...
BOARD_CONNECTED_ITEM * ItemById(const PNS::LOGGER::EVENT_ENTRY &evt)
void SetExpectedResult(const COMMIT_STATE &aCommitState, std::vector< std::unique_ptr< PNS::ITEM > > aParsedItems)
Definition: pns_log_file.h:89
void SetBoard(std::shared_ptr< BOARD > brd)
Definition: pns_log_file.h:82
bool Load(const wxFileName &logFileName, REPORTER *aRpt)
const COMMIT_STATE & GetExpectedResult() const
Definition: pns_log_file.h:87
bool SaveLog(const wxFileName &logFileName, REPORTER *aRpt)
PNS::ROUTER_MODE m_mode
Definition: pns_log_file.h:118
std::unique_ptr< PNS::SEGMENT > parsePnsSegmentFromString(wxStringTokenizer &aTokens)
std::shared_ptr< BOARD > m_board
Definition: pns_log_file.h:115
std::shared_ptr< SETTINGS_MANAGER > m_settingsMgr
Definition: pns_log_file.h:112
std::shared_ptr< SHAPE > parseShape(SHAPE_TYPE expectedType, wxStringTokenizer &aTokens)
std::vector< std::unique_ptr< PNS::ITEM > > m_parsed_items
Definition: pns_log_file.h:117
std::unique_ptr< PNS::ITEM > parseItemFromString(wxStringTokenizer &aTokens)
PNS::ROUTING_SETTINGS * GetRoutingSettings() const
Definition: pns_log_file.h:85
void SetMode(PNS::ROUTER_MODE aMode)
Definition: pns_log_file.h:98
std::unique_ptr< PNS::VIA > parsePnsViaFromString(wxStringTokenizer &aTokens)
bool parseCommonPnsProps(PNS::ITEM *aItem, const wxString &cmd, wxStringTokenizer &aTokens)
COMMIT_STATE m_commitState
Definition: pns_log_file.h:116
PNS::ROUTER_MODE GetMode() const
Definition: pns_log_file.h:96
std::vector< PNS::LOGGER::EVENT_ENTRY > & Events()
Definition: pns_log_file.h:80
std::shared_ptr< BOARD > GetBoard() const
Definition: pns_log_file.h:83
std::vector< PNS::LOGGER::EVENT_ENTRY > m_events
Definition: pns_log_file.h:114
std::unique_ptr< PNS::ROUTING_SETTINGS > m_routerSettings
Definition: pns_log_file.h:113
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:72
ROUTER_MODE
Definition: pns_router.h:62
SHAPE_TYPE
Lists all supported shapes.
Definition: shape.h:46
Definition: pns_logger.h:56
std::set< KIID > m_removedIds
Definition: pns_log_file.h:65
COMMIT_STATE(const COMMIT_STATE &aOther)
Definition: pns_log_file.h:59
bool Compare(const COMMIT_STATE &aOther)
std::vector< PNS::ITEM * > m_addedItems
Definition: pns_log_file.h:66
std::vector< PNS::ITEM * > m_heads
Definition: pns_log_file.h:67