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