-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnet.cpp
64 lines (51 loc) · 1.01 KB
/
net.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include "net.h"
std::istream &operator>> (std::istream &in, pin &p)
{
if (!(in >> p.index))
{
return in;
}
if(!(in >> p.position))
{
throw std::runtime_error("Invalid format for net, pin position not specified.");
}
return in;
}
std::istream &operator>> (std::istream &in, net &n)
{
n.pin_list.clear();
std::string prefix;
in >> prefix;
if(prefix != "Net")
{
in.setstate(std::ios_base::failbit);
return in;
}
in >> n.net_weight;
pin p;
while(in >> p)
{
n.pin_list.push_back(p);
}
in.clear();
return in;
}
std::ostream &operator<< (std::ostream &out, const pin &p)
{
out << p.index << " ";
out << p.position;
return out;
}
std::ostream &operator<< (std::ostream &out, const net &n)
{
out << n.net_weight << std::endl;
for(auto p: n.pin_list)
{
out << p << std::endl;
}
return out;
}
pos pin::get_pos(dimension dim) const
{
return position.coord(dim);
}