KiCad PCB EDA Suite
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 (C) 2022-2023 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 <memory>
29#include <map>
30#include <vector>
31#include <string>
32
33#include <sim/sim_library.h>
34#include <sim/sim_model.h>
35
36class PROJECT;
37class SCH_SYMBOL;
38
39
41{
42public:
43 SIM_LIB_MGR( const PROJECT* aPrj, REPORTER* aReporter = nullptr );
44 virtual ~SIM_LIB_MGR() = default;
45
46 void SetReporter( REPORTER* aReporter ) { m_reporter = aReporter; }
47
48 void Clear();
49
50 void SetLibrary( const wxString& aLibraryPath );
51
52 SIM_MODEL& CreateModel( SIM_MODEL::TYPE aType, const std::vector<LIB_PIN*>& aPins );
53
54 SIM_MODEL& CreateModel( const SIM_MODEL* aBaseModel, const std::vector<LIB_PIN*>& aPins );
55
56 template <typename T>
57 SIM_MODEL& CreateModel( const SIM_MODEL* aBaseModel, const std::vector<LIB_PIN*>& aPins,
58 const std::vector<T>& aFields );
59
60 // TODO: The argument can be made const.
61 SIM_LIBRARY::MODEL CreateModel( const SCH_SHEET_PATH* aSheetPath, SCH_SYMBOL& aSymbol );
62
63 template <typename T>
64 SIM_LIBRARY::MODEL CreateModel( const std::vector<T>& aFields,
65 const std::vector<LIB_PIN*>& aPins, bool aResolved );
66
67 template <typename T>
68 SIM_LIBRARY::MODEL CreateModel( const wxString& aLibraryPath,
69 const std::string& aBaseModelName,
70 const std::vector<T>& aFields,
71 const std::vector<LIB_PIN*>& aPins );
72
73 void SetModel( int aIndex, std::unique_ptr<SIM_MODEL> aModel );
74
75 std::map<wxString, std::reference_wrapper<const SIM_LIBRARY>> GetLibraries() const;
76 std::vector<std::reference_wrapper<SIM_MODEL>> GetModels() const;
77
78 static wxString ResolveLibraryPath( const wxString& aLibraryPath, const PROJECT* aProject );
79
80 std::string ResolveEmbeddedLibraryPath( const std::string& aLibPath,
81 const std::string& aRelativeLib );
82
83private:
86 std::map<wxString, std::unique_ptr<SIM_LIBRARY>> m_libraries;
87 std::vector<std::unique_ptr<SIM_MODEL>> m_models;
88};
89
90
91#endif // SIM_LIB_MGR_H
Container for project specific data.
Definition: project.h:64
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:81
std::string ResolveEmbeddedLibraryPath(const std::string &aLibPath, const std::string &aRelativeLib)
Definition: sim_lib_mgr.cpp:91
void SetModel(int aIndex, std::unique_ptr< SIM_MODEL > aModel)
const PROJECT * m_project
Definition: sim_lib_mgr.h:84
void SetLibrary(const wxString &aLibraryPath)
SIM_LIB_MGR(const PROJECT *aPrj, REPORTER *aReporter=nullptr)
Definition: sim_lib_mgr.cpp:42
std::vector< std::unique_ptr< SIM_MODEL > > m_models
Definition: sim_lib_mgr.h:87
virtual ~SIM_LIB_MGR()=default
void SetReporter(REPORTER *aReporter)
Definition: sim_lib_mgr.h:46
static wxString ResolveLibraryPath(const wxString &aLibraryPath, const PROJECT *aProject)
Definition: sim_lib_mgr.cpp:56
std::map< wxString, std::reference_wrapper< const SIM_LIBRARY > > GetLibraries() const
std::vector< std::reference_wrapper< SIM_MODEL > > GetModels() const
SIM_MODEL & CreateModel(SIM_MODEL::TYPE aType, const std::vector< LIB_PIN * > &aPins)
REPORTER * m_reporter
Definition: sim_lib_mgr.h:85
void Clear()
Definition: sim_lib_mgr.cpp:49
std::map< wxString, std::unique_ptr< SIM_LIBRARY > > m_libraries
Definition: sim_lib_mgr.h:86
SIM_MODEL::TYPE TYPE
Definition: sim_model.cpp:54