1 | |
2 | #include "EdgeHolder.h" |
3 | |
4 | namespace msdfgen { |
5 | |
6 | void EdgeHolder::swap(EdgeHolder &a, EdgeHolder &b) { |
7 | EdgeSegment *tmp = a.edgeSegment; |
8 | a.edgeSegment = b.edgeSegment; |
9 | b.edgeSegment = tmp; |
10 | } |
11 | |
12 | EdgeHolder::EdgeHolder() : edgeSegment(NULL) { } |
13 | |
14 | EdgeHolder::EdgeHolder(EdgeSegment *segment) : edgeSegment(segment) { } |
15 | |
16 | EdgeHolder::EdgeHolder(Point2 p0, Point2 p1, EdgeColor edgeColor) : edgeSegment(new LinearSegment(p0, p1, edgeColor)) { } |
17 | |
18 | EdgeHolder::EdgeHolder(Point2 p0, Point2 p1, Point2 p2, EdgeColor edgeColor) : edgeSegment(new QuadraticSegment(p0, p1, p2, edgeColor)) { } |
19 | |
20 | EdgeHolder::EdgeHolder(Point2 p0, Point2 p1, Point2 p2, Point2 p3, EdgeColor edgeColor) : edgeSegment(new CubicSegment(p0, p1, p2, p3, edgeColor)) { } |
21 | |
22 | EdgeHolder::EdgeHolder(const EdgeHolder &orig) : edgeSegment(orig.edgeSegment ? orig.edgeSegment->clone() : NULL) { } |
23 | |
24 | #ifdef MSDFGEN_USE_CPP11 |
25 | EdgeHolder::EdgeHolder(EdgeHolder &&orig) : edgeSegment(orig.edgeSegment) { |
26 | orig.edgeSegment = NULL; |
27 | } |
28 | #endif |
29 | |
30 | EdgeHolder::~EdgeHolder() { |
31 | delete edgeSegment; |
32 | } |
33 | |
34 | EdgeHolder & EdgeHolder::operator=(const EdgeHolder &orig) { |
35 | if (this != &orig) { |
36 | delete edgeSegment; |
37 | edgeSegment = orig.edgeSegment ? orig.edgeSegment->clone() : NULL; |
38 | } |
39 | return *this; |
40 | } |
41 | |
42 | #ifdef MSDFGEN_USE_CPP11 |
43 | EdgeHolder & EdgeHolder::operator=(EdgeHolder &&orig) { |
44 | if (this != &orig) { |
45 | delete edgeSegment; |
46 | edgeSegment = orig.edgeSegment; |
47 | orig.edgeSegment = NULL; |
48 | } |
49 | return *this; |
50 | } |
51 | #endif |
52 | |
53 | EdgeSegment & EdgeHolder::operator*() { |
54 | return *edgeSegment; |
55 | } |
56 | |
57 | const EdgeSegment & EdgeHolder::operator*() const { |
58 | return *edgeSegment; |
59 | } |
60 | |
61 | EdgeSegment * EdgeHolder::operator->() { |
62 | return edgeSegment; |
63 | } |
64 | |
65 | const EdgeSegment * EdgeHolder::operator->() const { |
66 | return edgeSegment; |
67 | } |
68 | |
69 | EdgeHolder::operator EdgeSegment *() { |
70 | return edgeSegment; |
71 | } |
72 | |
73 | EdgeHolder::operator const EdgeSegment *() const { |
74 | return edgeSegment; |
75 | } |
76 | |
77 | } |
78 | |