KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sim_lib_mgr.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) 2022 Mikolaj Wielgus
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#pragma once
22
23#include <map>
24#include <vector>
25
26#include <sim/sim_library.h>
27#include <sim/sim_model.h>
28
29class EMBEDDED_FILES;
30class PROJECT;
31class SCH_SYMBOL;
32
33
35{
36public:
37 SIM_LIB_MGR( const PROJECT* aPrj );
38 virtual ~SIM_LIB_MGR() = default;
39
41
42 void Clear();
43
44 void SetFilesStack( std::vector<EMBEDDED_FILES*> aFilesStack )
45 {
46 m_embeddedFilesStack = std::move( aFilesStack );
47 }
48
49 void SetLibrary( const wxString& aLibraryPath, REPORTER& aReporter );
50
51 SIM_MODEL& CreateModel( SIM_MODEL::TYPE aType, const std::vector<SCH_PIN*>& aPins,
52 REPORTER& aReporter );
53
54 SIM_MODEL& CreateModel( const SIM_MODEL* aBaseModel, const std::vector<SCH_PIN*>& aPins,
55 REPORTER& aReporter );
56
57 SIM_MODEL& CreateModel( const SIM_MODEL* aBaseModel, const std::vector<SCH_PIN*>& aPins,
58 const std::vector<SCH_FIELD>& aFields, bool aResolve, int aDepth,
59 REPORTER& aReporter );
60
61 // TODO: The argument can be made const.
62 // aMergedSimPins is an optional merged Sim.Pins string from all units of a multi-unit symbol.
63 // If provided (non-empty), it will be used instead of the symbol's Sim.Pins field.
64 SIM_LIBRARY::MODEL CreateModel( const SCH_SHEET_PATH* aSheetPath, SCH_SYMBOL& aSymbol,
65 bool aResolve, int aDepth, const wxString& aVariantName,
66 REPORTER& aReporter, const wxString& aMergedSimPins = wxEmptyString );
67
68 SIM_LIBRARY::MODEL CreateModel( const std::vector<SCH_FIELD>& aFields, bool aResolve, int aDepth,
69 const std::vector<SCH_PIN*>& aPins, REPORTER& aReporter );
70
71 SIM_LIBRARY::MODEL CreateModel( const wxString& aLibraryPath, const std::string& aBaseModelName,
72 const std::vector<SCH_FIELD>& aFields, bool aResolve, int aDepth,
73 const std::vector<SCH_PIN*>& aPins, REPORTER& aReporter );
74
75 void SetModel( int aIndex, std::unique_ptr<SIM_MODEL> aModel );
76
77 std::map<wxString, std::reference_wrapper<const SIM_LIBRARY>> GetLibraries() const;
78 std::vector<std::reference_wrapper<SIM_MODEL>> GetModels() const;
79
80 wxString ResolveLibraryPath( const wxString& aLibraryPath, REPORTER& aReporter );
81 wxString ResolveEmbeddedLibraryPath( const wxString& aLibPath, const wxString& aRelativeLib,
82 REPORTER& aReporter );
83
84private:
85 std::vector<EMBEDDED_FILES*> m_embeddedFilesStack; // no ownership
86 const PROJECT* m_project; // no ownership
88 std::map<wxString, std::unique_ptr<SIM_LIBRARY>> m_libraries;
89 std::vector<std::unique_ptr<SIM_MODEL>> m_models;
90};
91
Container for project specific data.
Definition project.h:62
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:71
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Schematic symbol object.
Definition sch_symbol.h:69
void SetModel(int aIndex, std::unique_ptr< SIM_MODEL > aModel)
wxString ResolveLibraryPath(const wxString &aLibraryPath, REPORTER &aReporter)
const PROJECT * m_project
Definition sim_lib_mgr.h:86
std::vector< EMBEDDED_FILES * > m_embeddedFilesStack
Definition sim_lib_mgr.h:85
bool m_forceFullParse
Definition sim_lib_mgr.h:87
SIM_MODEL & CreateModel(SIM_MODEL::TYPE aType, const std::vector< SCH_PIN * > &aPins, REPORTER &aReporter)
SIM_LIB_MGR(const PROJECT *aPrj)
std::vector< std::unique_ptr< SIM_MODEL > > m_models
Definition sim_lib_mgr.h:89
virtual ~SIM_LIB_MGR()=default
std::map< wxString, std::reference_wrapper< const SIM_LIBRARY > > GetLibraries() const
wxString ResolveEmbeddedLibraryPath(const wxString &aLibPath, const wxString &aRelativeLib, REPORTER &aReporter)
std::vector< std::reference_wrapper< SIM_MODEL > > GetModels() const
void SetLibrary(const wxString &aLibraryPath, REPORTER &aReporter)
void SetForceFullParse()
Definition sim_lib_mgr.h:40
std::map< wxString, std::unique_ptr< SIM_LIBRARY > > m_libraries
Definition sim_lib_mgr.h:88
void SetFilesStack(std::vector< EMBEDDED_FILES * > aFilesStack)
Definition sim_lib_mgr.h:44