-
Notifications
You must be signed in to change notification settings - Fork 0
/
Link.cpp
48 lines (40 loc) · 933 Bytes
/
Link.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
#include "Link.h"
#include "Node.h"
namespace tngl {
LinkBase::LinkBase(Node* _owner, Flags _flags, std::string const& _regex)
: flags(_flags)
, regexStr(_regex)
, owner(_owner)
{
if (regexStr == "") {
// default to a match all in other cases
regexStr = ".*";
}
regex = std::regex(regexStr);
owner->addLink(this);
}
LinkBase::LinkBase(LinkBase&& other) noexcept {
*this = std::move(other);
}
LinkBase& LinkBase::operator=(LinkBase&& other) noexcept
{
if (owner) {
owner->removeLink(this);
}
owner = other.owner;
flags = other.flags;
regexStr = std::move(other.regexStr);
regex = std::move(other.regex);
if (owner) {
owner->addLink(this);
other.owner->removeLink(&other);
other.owner = nullptr;
}
return *this;
}
LinkBase::~LinkBase() {
if (owner) {
owner->removeLink(this);
}
}
}