-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathi_smart_object.cpp
More file actions
51 lines (41 loc) · 1020 Bytes
/
i_smart_object.cpp
File metadata and controls
51 lines (41 loc) · 1020 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
47
48
49
#include "i_smart_object.h"
#include <iostream>
ISmartObject::ISmartObject()
: hasCheckedByCollection_(false)
{
#ifdef GC_LOG
std::cout << "register object: " << this << std::endl;
#endif
GarbageCollection::getInstance().registerObject_(this);
}
ISmartObject::~ISmartObject()
{
#ifdef GC_LOG
std::cout << "unregister object: " << this << std::endl;
#endif
GarbageCollection::getInstance().deleteObjectFromCollection_(this);
}
void * ISmartObject::operator new(size_t size)
{
return GarbageCollection::getInstance().allocate_(size);
}
void * ISmartObject::operator new [](size_t size)
{
return GarbageCollection::getInstance().allocate_(size);
}
//void ISmartObject::operator delete(void * data)
//{
// //need to throw exception
//}
bool ISmartObject::hasCheckedByCollection() const
{
return hasCheckedByCollection_;
}
void ISmartObject::markAsChecked()
{
hasCheckedByCollection_ = true;
}
void ISmartObject::markAsUnChecked()
{
hasCheckedByCollection_ = false;
}