-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtopology.cpp
41 lines (41 loc) · 1.03 KB
/
topology.cpp
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
#include "topology.h"
void topology:: setID(string ID)
{
id = ID;
}
string topology::getID()
{
return id;
}
component* topology::insertComponent(string& ID, string& TYPE, double& DEFAULT, double& MIN, double& MAX, map<string, string>& NETLIST)
{
component* newComponent;
if (TYPE == "resistor")
newComponent = new resistor(ID, TYPE, DEFAULT, MIN, MAX, NETLIST);
else
newComponent = new mosfet(ID, TYPE, DEFAULT, MIN, MAX, NETLIST);
components.push_back(newComponent);
return newComponent;
}
vector<component*> topology::getComponents()
{
return components;
}
vector<component*> topology::getComponentsWithNetlistId(string Node)
{
vector<component*> collectedComponents;
for (component* comp : components)
if (comp->hasNetlistNode(Node))
collectedComponents.push_back(comp);
return collectedComponents;
}
bool topology::hasThatId(string ID)
{
return id == ID;
}
topology::~topology()
{
for (component* comp : components)
delete comp;
components.clear();
}