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
78 std::vector<BOARD_CONNECTED_ITEM*> ItemsById( const PNS::LOGGER::EVENT_ENTRY& evt );
80
81 std::vector<PNS::LOGGER::EVENT_ENTRY>& Events() { return m_events; }
82
83 void SetBoard( std::shared_ptr<BOARD> brd ) { m_board = brd; }
84 std::shared_ptr<BOARD> GetBoard() const { return m_board; }
85
87
88 const COMMIT_STATE& GetExpectedResult() const { return m_commitState; }
89
90 void SetExpectedResult( const COMMIT_STATE& aCommitState,
91 std::vector<std::unique_ptr<PNS::ITEM>> aParsedItems )
92 {
93 m_commitState = aCommitState;
94 m_parsed_items = std::move( aParsedItems );
95 }
96
97 PNS::ROUTER_MODE GetMode() const { return m_mode; }
98
99 void SetMode( PNS::ROUTER_MODE aMode ) { m_mode = aMode; }
100
101private:
102 bool parseCommonPnsProps( PNS::ITEM* aItem, const wxString& cmd, wxStringTokenizer& aTokens );
103
104 std::unique_ptr<PNS::SEGMENT> parsePnsSegmentFromString( wxStringTokenizer& aTokens );
105
106 std::unique_ptr<PNS::VIA> parsePnsViaFromString( wxStringTokenizer& aTokens );
107
108 std::unique_ptr<PNS::ITEM> parseItemFromString( wxStringTokenizer& aTokens );
109
110 std::shared_ptr<SHAPE> parseShape( SHAPE_TYPE expectedType, wxStringTokenizer& aTokens );
111
112private:
113 std::shared_ptr<SETTINGS_MANAGER> m_settingsMgr;
114 std::unique_ptr<PNS::ROUTING_SETTINGS> m_routerSettings;
115 std::vector<PNS::LOGGER::EVENT_ENTRY> m_events;
116 std::shared_ptr<BOARD> m_board;
118 std::vector<std::unique_ptr<PNS::ITEM>> m_parsed_items;
120};
121
122#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:90
void SetBoard(std::shared_ptr< BOARD > brd)
Definition: pns_log_file.h:83
bool Load(const wxFileName &logFileName, REPORTER *aRpt)
const COMMIT_STATE & GetExpectedResult() const
Definition: pns_log_file.h:88
bool SaveLog(const wxFileName &logFileName, REPORTER *aRpt)
PNS::ROUTER_MODE m_mode
Definition: pns_log_file.h:119
std::unique_ptr< PNS::SEGMENT > parsePnsSegmentFromString(wxStringTokenizer &aTokens)
std::shared_ptr< BOARD > m_board
Definition: pns_log_file.h:116
std::shared_ptr< SETTINGS_MANAGER > m_settingsMgr
Definition: pns_log_file.h:113
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:118
std::unique_ptr< PNS::ITEM > parseItemFromString(wxStringTokenizer &aTokens)
PNS::ROUTING_SETTINGS * GetRoutingSettings() const
Definition: pns_log_file.h:86
void SetMode(PNS::ROUTER_MODE aMode)
Definition: pns_log_file.h:99
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:117
PNS::ROUTER_MODE GetMode() const
Definition: pns_log_file.h:97
std::vector< PNS::LOGGER::EVENT_ENTRY > & Events()
Definition: pns_log_file.h:81
std::shared_ptr< BOARD > GetBoard() const
Definition: pns_log_file.h:84
std::vector< PNS::LOGGER::EVENT_ENTRY > m_events
Definition: pns_log_file.h:115
std::vector< BOARD_CONNECTED_ITEM * > ItemsById(const PNS::LOGGER::EVENT_ENTRY &evt)
std::unique_ptr< PNS::ROUTING_SETTINGS > m_routerSettings
Definition: pns_log_file.h:114
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:57
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