KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sim_library.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_LIBRARY_H
26#define SIM_LIBRARY_H
27
28#include <sim/sim_model.h>
29#include <reporter.h>
30
31
33{
34public:
35 static constexpr auto LIBRARY_FIELD = "Sim.Library";
36 static constexpr auto NAME_FIELD = "Sim.Name";
37
38 struct MODEL
39 {
40 std::string name;
42 };
43
44 virtual ~SIM_LIBRARY() = default;
45 SIM_LIBRARY() = default;
46
57 static std::unique_ptr<SIM_LIBRARY>
58 Create( const wxString& aFilePath, bool aForceFullParse, REPORTER& aReporter,
59 std::function<wxString( const wxString&, const wxString& )>* aResolver );
60
68 virtual void ReadFile( const wxString& aFilePath, REPORTER& aReporter ) = 0;
69
70 SIM_MODEL* FindModel( const std::string& aModelName ) const;
71
72 std::vector<MODEL> GetModels() const;
73
74 std::string GetFilePath() const { return m_filePath; }
75
76protected:
77 std::vector<std::string> m_modelNames;
78 std::vector<std::unique_ptr<SIM_MODEL>> m_models;
79
80 std::function<wxString( const wxString&, const wxString& )>* m_pathResolver;
81
82 std::string m_filePath;
83};
84
85
86
87#endif // SIM_LIBRARY_H
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:71
std::vector< MODEL > GetModels() const
Definition: sim_library.cpp:70
std::function< wxString(const wxString &, const wxString &)> * m_pathResolver
Definition: sim_library.h:80
virtual void ReadFile(const wxString &aFilePath, REPORTER &aReporter)=0
Read library from a source file.
Definition: sim_library.cpp:50
static std::unique_ptr< SIM_LIBRARY > Create(const wxString &aFilePath, bool aForceFullParse, REPORTER &aReporter, std::function< wxString(const wxString &, const wxString &)> *aResolver)
Read library from a source file (e.g.
Definition: sim_library.cpp:33
static constexpr auto LIBRARY_FIELD
Definition: sim_library.h:35
virtual ~SIM_LIBRARY()=default
std::vector< std::string > m_modelNames
Definition: sim_library.h:77
SIM_MODEL * FindModel(const std::string &aModelName) const
Definition: sim_library.cpp:56
std::string GetFilePath() const
Definition: sim_library.h:74
std::vector< std::unique_ptr< SIM_MODEL > > m_models
Definition: sim_library.h:78
SIM_LIBRARY()=default
std::string m_filePath
Definition: sim_library.h:82
static constexpr auto NAME_FIELD
Definition: sim_library.h:36
SIM_MODEL & model
Definition: sim_library.h:41
std::string name
Definition: sim_library.h:40