CSEngine
Loading...
Searching...
No Matches
CSE::MemoryMgr Class Reference
Inheritance diagram for CSE::MemoryMgr:
CSE::MemoryContainer CSE::CoreBase CSE::SContainerList< SObject * > CSE::SIContainer< S, T, M >

Public Member Functions

void ExterminateObjects (bool killAll=false)
 
void ReleaseObject (SObject *object, bool isForce=false)
 
void Init () override
 
- Public Member Functions inherited from CSE::MemoryContainer
void Register (SObject *object) override
 
void Remove (SObject *object) override
 
bool HasHash (const std::string &hash) const
 
void ChangeHash (const std::string &srcHash, const std::string &dstHash)
 
- Public Member Functions inherited from CSE::SContainerList< SObject * >
void Register (SObject * object) override
 
void Remove (SObject * object) override
 
SObjectGet (int index) const override
 
std::list< SObject * > GetAll () const override
 
int GetID (SObject * object) const override
 
int GetSize () const override
 
- Public Member Functions inherited from CSE::SIContainer< S, T, M >
virtual void Register (T object)=0
 
virtual void Remove (T object)=0
 
virtual T Get (M index) const =0
 
virtual M GetID (T object) const =0
 
- Public Member Functions inherited from CSE::CoreBase
virtual void Update (float elapsedTime)
 

Additional Inherited Members

- Protected Attributes inherited from CSE::MemoryContainer
std::set< std::string > m_hashContainer
 
- Protected Attributes inherited from CSE::SContainerList< SObject * >
std::list< SObject * > m_objects
 
int m_size
 

Detailed Description

Definition at line 8 of file MemoryMgr.h.

Member Function Documentation

◆ ExterminateObjects()

void MemoryMgr::ExterminateObjects ( bool  killAll = false)

Definition at line 31 of file MemoryMgr.cpp.

31 {
32
33 auto iter = m_objects.begin();
34 while (iter != m_objects.end()) {
35 auto object = *iter;
36 if (object == nullptr) {
37 ++iter;
38 continue;
39 }
40
41#ifdef _DEBUG
42 OutputDebugStringA("Auto Releasing Object : ");
43 OutputDebugStringA(typeid(*object).name());
44 OutputDebugStringA("...\n");
45#elif __ANDROID__
46 LOGE("Auto Releasing Object : UNKOWN...");
47#elif __linux__
48 std::cout << "Auto Releasing Object : " << typeid(*object).name() << "...\n";
49#endif
50 if (object->isUndestroyable && !killAll) {
51#ifdef WIN32
52 OutputDebugStringA("denied.\n");
53#elif __ANDROID__
54 LOGE("denied.\n");
55#endif
56 ++iter;
57 continue;
58 }
59
60 object->Exterminate();
61 iter = m_objects.erase(iter);
62 m_hashContainer.erase(object->GetHash());
63 SAFE_DELETE(object);
64#ifdef WIN32
65 OutputDebugStringA("deleted.\n");
66#elif __ANDROID__
67 LOGE("deleted.\n");
68#elif __linux__
69 std::cout << "deleted.\n";
70#endif
71 }
72
73 m_objects.erase(std::remove(m_objects.begin(), m_objects.end(), nullptr), m_objects.end());
74}

◆ Init()

void MemoryMgr::Init ( )
overridevirtual

Implements CSE::CoreBase.

Definition at line 111 of file MemoryMgr.cpp.

111 {
112
113}

◆ ReleaseObject()

void MemoryMgr::ReleaseObject ( SObject object,
bool  isForce = false 
)

Definition at line 77 of file MemoryMgr.cpp.

77 {
78 if (object == nullptr) return;
79
80 if (object->isUndestroyable && !isForce) {
81#ifdef WIN32
82 OutputDebugStringA("Releasing Object is denied.");
83#elif __ANDROID__
84 LOGE("Releasing Object is denied.");
85#endif
86 return;
87 }
88
89 auto iObj = std::find(m_objects.begin(), m_objects.end(), object);
90
91 if (iObj != m_objects.end()) {
92#ifdef _DEBUG
93 OutputDebugStringA("Releasing Object : ");
94 OutputDebugStringA(typeid(*object).name());
95 OutputDebugStringA("...\n");
96#elif __ANDROID__
97 LOGE("Releasing Object : UNKOWN...");
98#endif
99 object->Exterminate();
100 Remove(object);
101 SAFE_DELETE(object);
102
103#ifdef WIN32
104 OutputDebugStringA("deleted\n");
105#elif __ANDROID__
106 LOGE("deleted\n");
107#endif
108 }
109}

The documentation for this class was generated from the following files: