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 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#ifndef SIM_LIBRARY_H
22#define SIM_LIBRARY_H
23
24#include <sim/sim_model.h>
25#include <reporter.h>
26
27
29{
30public:
31 static constexpr auto LIBRARY_FIELD = "Sim.Library";
32 static constexpr auto NAME_FIELD = "Sim.Name";
33
34 struct MODEL
35 {
36 std::string name;
38 };
39
40 virtual ~SIM_LIBRARY() = default;
41 SIM_LIBRARY() = default;
42
53 static std::unique_ptr<SIM_LIBRARY>
54 Create( const wxString& aFilePath, bool aForceFullParse, REPORTER& aReporter,
55 const std::function<wxString( const wxString&, const wxString& )>& aResolver );
56
64 virtual void ReadFile( const wxString& aFilePath, REPORTER& aReporter ) = 0;
65
66 SIM_MODEL* FindModel( const std::string& aModelName ) const;
67
68 std::vector<MODEL> GetModels() const;
69
70 std::string GetFilePath() const { return m_filePath; }
71
72protected:
73 std::vector<std::string> m_modelNames;
74 std::vector<std::unique_ptr<SIM_MODEL>> m_models;
75
76 std::function<wxString( const wxString&, const wxString& )> m_pathResolver;
77
78 std::string m_filePath;
79};
80
81
82
83#endif // SIM_LIBRARY_H
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:71
std::vector< MODEL > GetModels() const
static std::unique_ptr< SIM_LIBRARY > Create(const wxString &aFilePath, bool aForceFullParse, REPORTER &aReporter, const std::function< wxString(const wxString &, const wxString &)> &aResolver)
Read library from a source file (e.g.
virtual void ReadFile(const wxString &aFilePath, REPORTER &aReporter)=0
Read library from a source file.
static constexpr auto LIBRARY_FIELD
Definition sim_library.h:31
virtual ~SIM_LIBRARY()=default
std::vector< std::string > m_modelNames
Definition sim_library.h:73
SIM_MODEL * FindModel(const std::string &aModelName) const
std::string GetFilePath() const
Definition sim_library.h:70
std::vector< std::unique_ptr< SIM_MODEL > > m_models
Definition sim_library.h:74
std::function< wxString(const wxString &, const wxString &)> m_pathResolver
Definition sim_library.h:76
SIM_LIBRARY()=default
std::string m_filePath
Definition sim_library.h:78
static constexpr auto NAME_FIELD
Definition sim_library.h:32
SIM_MODEL & model
Definition sim_library.h:37
std::string name
Definition sim_library.h:36