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 ) :
60 m_removedIds( aOther.m_removedIds ),
62 {
63
64 }
65
66 std::set<KIID> m_removedIds;
67 std::vector<PNS::ITEM*> m_addedItems;
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 PNS::ROUTER_MODE GetMode() const { return m_mode; }
90
91private:
92 bool parseCommonPnsProps( PNS::ITEM* aItem, const wxString& cmd, wxStringTokenizer& aTokens );
93
94 PNS::SEGMENT* parsePnsSegmentFromString( wxStringTokenizer& aTokens );
95
96 PNS::VIA* parsePnsViaFromString( wxStringTokenizer& aTokens );
97
98 PNS::ITEM* parseItemFromString( wxStringTokenizer& aTokens );
99
100private:
101 std::shared_ptr<SETTINGS_MANAGER> m_settingsMgr;
102 std::unique_ptr<PNS::ROUTING_SETTINGS> m_routerSettings;
103 std::vector<PNS::LOGGER::EVENT_ENTRY> m_events;
104 std::shared_ptr<BOARD> m_board;
107};
108
109#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)
PNS::ITEM * parseItemFromString(wxStringTokenizer &aTokens)
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::SEGMENT * parsePnsSegmentFromString(wxStringTokenizer &aTokens)
PNS::ROUTER_MODE m_mode
Definition: pns_log_file.h:106
std::shared_ptr< BOARD > m_board
Definition: pns_log_file.h:104
std::shared_ptr< SETTINGS_MANAGER > m_settingsMgr
Definition: pns_log_file.h:101
PNS::VIA * parsePnsViaFromString(wxStringTokenizer &aTokens)
PNS::ROUTING_SETTINGS * GetRoutingSettings() const
Definition: pns_log_file.h:85
bool parseCommonPnsProps(PNS::ITEM *aItem, const wxString &cmd, wxStringTokenizer &aTokens)
COMMIT_STATE m_commitState
Definition: pns_log_file.h:105
PNS::ROUTER_MODE GetMode() const
Definition: pns_log_file.h:89
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:103
std::unique_ptr< PNS::ROUTING_SETTINGS > m_routerSettings
Definition: pns_log_file.h:102
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:71
ROUTER_MODE
Definition: pns_router.h:62
Definition: pns_logger.h:56
std::set< KIID > m_removedIds
Definition: pns_log_file.h:66
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:67