KiCad PCB EDA Suite
Loading...
Searching...
No Matches
conn_netchain_input.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * 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, see <https://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include <sch_sheet_path.h>
23#include <memory_resource>
24#include <vector>
25#include <unordered_map>
26#include <wx/string.h>
27
28class SCH_ITEM;
29
30namespace SCH_CONNECTIVITY
31{
34{
35 struct NET
36 {
37 wxString name;
38 wxString key;
39 };
40
41 struct SHEET
42 {
43 SHEET( const SCH_SHEET_PATH& aPath, std::pmr::memory_resource* aStorage ) :
44 path( aPath ), nets( aStorage )
45 {
46 }
47
49 std::pmr::unordered_map<const SCH_ITEM*, NET> nets;
50
51 const NET* Find( const SCH_ITEM* aItem ) const
52 {
53 const auto item = nets.find( aItem );
54 return item == nets.end() ? nullptr : &item->second;
55 }
56
57 const wxString& Key( const SCH_ITEM* aItem ) const
58 {
59 static const wxString missing;
60 const NET* net = Find( aItem );
61 return net ? net->key : missing;
62 }
63 };
64
65 // The maps must destroy their strings before their shared allocation storage is released.
66 std::pmr::monotonic_buffer_resource storage;
67 std::vector<SHEET> sheets;
68};
69}
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:165
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
const wxString & Key(const SCH_ITEM *aItem) const
const NET * Find(const SCH_ITEM *aItem) const
std::pmr::unordered_map< const SCH_ITEM *, NET > nets
SHEET(const SCH_SHEET_PATH &aPath, std::pmr::memory_resource *aStorage)
Immediate-use netchain input; shared-screen items are qualified by their instance.
std::pmr::monotonic_buffer_resource storage