blob: 45765cb8e30d740ede09249ba47618a20a8cbb29 (
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
86
87
88
89
90
91
|
// 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()
{
for (std::size_t i=0; i < size(); i++)
{
base_factory_t *p = value_at(i);
pfree(p);
}
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 NULL; // appease code analysis
}
#endif
void factory_list_t::error(const pstring &s)
{
m_setup.log().fatal("{1}", s);
}
device_t *factory_list_t::new_device_by_name(const pstring &name)
{
base_factory_t *f = factory_by_name(name);
return f->Create();
}
base_factory_t * factory_list_t::factory_by_name(const pstring &name)
{
if (contains(name))
return (*this)[name];
else
{
m_setup.log().fatal("Class {1} not found!\n", name);
return NULL; // appease code analysis
}
}
}
|