blob: cd351e89c9c87bdd1628bfa222490527806deb1d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
// license:GPL-2.0+
// copyright-holders:Couriersud
/***************************************************************************
nl_factory.c
Discrete netlist implementation.
****************************************************************************/
#include "nl_factory.h"
#include "nl_setup.h"
namespace netlist
{
// ----------------------------------------------------------------------------------------
// net_device_t_base_factory
// ----------------------------------------------------------------------------------------
ATTR_COLD const pstring_vector_t base_factory_t::term_param_list()
{
if (m_def_param.startsWith("+"))
return pstring_vector_t(m_def_param.substr(1), ",");
else
return pstring_vector_t();
}
ATTR_COLD const pstring_vector_t base_factory_t::def_params()
{
if (m_def_param.startsWith("+") || m_def_param.equals("-"))
return pstring_vector_t();
else
return pstring_vector_t(m_def_param, ",");
}
factory_list_t::factory_list_t( setup_t &setup)
: m_setup(setup)
{
}
factory_list_t::~factory_list_t()
{
clear();
}
#if 0
device_t *factory_list_t::new_device_by_classname(const pstring &classname) const
{
for (std::size_t i=0; i < m_list.size(); i++)
{
base_factory_t *p = m_list[i];
if (p->classname() == classname)
{
device_t *ret = p->Create();
return ret;
}
p++;
}
return nullptr; // appease code analysis
}
#endif
void factory_list_t::error(const pstring &s)
{
m_setup.log().fatal("{1}", s);
}
powned_ptr<device_t> factory_list_t::new_device_by_name(const pstring &devname, netlist_t &anetlist, const pstring &name)
{
base_factory_t *f = factory_by_name(devname);
return f->Create(anetlist, name);
}
base_factory_t * factory_list_t::factory_by_name(const pstring &devname)
{
for (auto & e : *this)
if (e->name() == devname)
return e.get();
m_setup.log().fatal("Class {1} not found!\n", devname);
return nullptr; // appease code analysis
}
}
|