-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVMObject.cpp
More file actions
46 lines (39 loc) · 870 Bytes
/
Copy pathVMObject.cpp
File metadata and controls
46 lines (39 loc) · 870 Bytes
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
#include "VMObject.h"
int VMObject::GetFatherID() const
{ return father->SM_Id; }
int VMObject::GetFatherTureID() const
{
return father->true_id;
}
VMObject::VMObject(const VirtualMachine& _VMProperty, int _vm_id, SMObject* _father) : VMProperty(_VMProperty), VM_ID(_vm_id)
{
if (_father)
{
_father->AddChild(this);
}
father = _father;
nodeType = VM_NodeType::Unknow;
}
VMObject::~VMObject()
{
if (father)
father->RemoveChild(this);
}
bool VMObject::SetFather(SMObject* _father)
{
if (father)
return false; //已经有父亲了
return _father->AddChild(this);
}
bool VMObject::ChangeFather(SMObject* _newfather)
{
if (father)
father->RemoveChild(this);
return _newfather->AddChild(this);
}
bool VMObject::LeaveFather()
{
if (!father)
return false; //本来就是孤儿
return father->RemoveChild(this);
}