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, you may find one here:
19 * https://www.gnu.org/licenses/gpl-3.0.html
20 * or you may search the http://www.gnu.org website for the version 3 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#ifndef SIM_LIB_MGR_H
26#define SIM_LIB_MGR_H
27
28#include <map>
29#include <vector>
30
31#include <sim/sim_library.h>
32#include <sim/sim_model.h>
33
34class EMBEDDED_FILES;
35class PROJECT;
36class SCH_SYMBOL;
37
38
40{
41public:
42 SIM_LIB_MGR( const PROJECT* aPrj );
43 virtual ~SIM_LIB_MGR() = default;
44
46
47 void Clear();
48
49 void SetFilesStack( std::vector<EMBEDDED_FILES*> aFilesStack )
50 {
51 m_embeddedFilesStack = std::move( aFilesStack );
52 }
53
54 void SetLibrary( const wxString& aLibraryPath, REPORTER& aReporter );
55
56 SIM_MODEL& CreateModel( SIM_MODEL::TYPE aType, const std::vector<SCH_PIN*>& aPins,
57 REPORTER& aReporter );
58
59 SIM_MODEL& CreateModel( const SIM_MODEL* aBaseModel, const std::vector<SCH_PIN*>& aPins,
60 REPORTER& aReporter );
61
62 SIM_MODEL& CreateModel( const SIM_MODEL* aBaseModel, const std::vector<SCH_PIN*>& aPins,
63 const std::vector<SCH_FIELD>& aFields, bool aResolve, int aDepth,
64 REPORTER& aReporter );
65
66 // TODO: The argument can be made const.
67 SIM_LIBRARY::MODEL CreateModel( const SCH_SHEET_PATH* aSheetPath, SCH_SYMBOL& aSymbol,
68 bool aResolve, int aDepth, REPORTER& aReporter );
69
70 SIM_LIBRARY::MODEL CreateModel( const std::vector<SCH_FIELD>& aFields, bool aResolve, int aDepth,
71 const std::vector<SCH_PIN*>& aPins, REPORTER& aReporter );
72
73 SIM_LIBRARY::MODEL CreateModel( const wxString& aLibraryPath, const std::string& aBaseModelName,
74 const std::vector<SCH_FIELD>& aFields, bool aResolve, int aDepth,
75 const std::vector<SCH_PIN*>& aPins, REPORTER& aReporter );
76
77 void SetModel( int aIndex, std::unique_ptr<SIM_MODEL> aModel );
78
79 std::map<wxString, std::reference_wrapper<const SIM_LIBRARY>> GetLibraries() const;
80 std::vector<std::reference_wrapper<SIM_MODEL>> GetModels() const;
81
82 wxString ResolveLibraryPath( const wxString& aLibraryPath, REPORTER& aReporter );
83 wxString ResolveEmbeddedLibraryPath( const wxString& aLibPath, const wxString& aRelativeLib,
84 REPORTER& aReporter );
85
86private:
87 std::vector<EMBEDDED_FILES*> m_embeddedFilesStack;
90 std::map<wxString, std::unique_ptr<SIM_LIBRARY>> m_libraries;
91 std::vector<std::unique_ptr<SIM_MODEL>> m_models;
92};
93
94
95#endif // SIM_LIB_MGR_H
Container for project specific data.
Definition: project.h:65
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:73
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:75
void SetModel(int aIndex, std::unique_ptr< SIM_MODEL > aModel)
wxString ResolveLibraryPath(const wxString &aLibraryPath, REPORTER &aReporter)
Definition: sim_lib_mgr.cpp:58
const PROJECT * m_project
Definition: sim_lib_mgr.h:88
std::vector< EMBEDDED_FILES * > m_embeddedFilesStack
Definition: sim_lib_mgr.h:87
bool m_forceFullParse
Definition: sim_lib_mgr.h:89
SIM_MODEL & CreateModel(SIM_MODEL::TYPE aType, const std::vector< SCH_PIN * > &aPins, REPORTER &aReporter)
std::vector< std::unique_ptr< SIM_MODEL > > m_models
Definition: sim_lib_mgr.h:91
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 Clear()
Definition: sim_lib_mgr.cpp:51
void SetLibrary(const wxString &aLibraryPath, REPORTER &aReporter)
void SetForceFullParse()
Definition: sim_lib_mgr.h:45
std::map< wxString, std::unique_ptr< SIM_LIBRARY > > m_libraries
Definition: sim_lib_mgr.h:90
void SetFilesStack(std::vector< EMBEDDED_FILES * > aFilesStack)
Definition: sim_lib_mgr.h:49