Kinoko
v0.6
A reimplementation of Mario Kart Wii's physics engine in C++
Toggle main menu visibility
Loading...
Searching...
No Matches
ScopeLock.hh
Go to the documentation of this file.
1
#pragma once
2
3
#include <
Common.hh
>
4
5
#include <
egg/core/ExpHeap.hh
>
6
7
namespace
Kinoko
{
8
9
template
<
typename
T>
10
class
ScopeLock
;
11
12
template
<>
13
class
ScopeLock
<
GroupID
> {
14
public
:
17
ScopeLock
(
GroupID
newID) {
18
#ifdef BUILD_DEBUG
19
EGG::ExpHeap
*heap =
EGG::Heap::dynamicCastToExp
(
EGG::Heap::getCurrentHeap
());
20
ASSERT
(heap);
21
GroupID
prevID =
static_cast<
GroupID
>
(heap->
getGroupID
());
22
23
if
(prevID !=
GroupID::None
) {
24
WARN
(
"Overwriting non-default group ID! Replacing %d with %d"
, prevID, newID);
25
}
26
27
heap->
setGroupID
(
static_cast<
u16
>
(newID));
28
#endif
29
}
30
31
~ScopeLock
() {
32
#ifdef BUILD_DEBUG
33
EGG::ExpHeap
*heap =
EGG::Heap::dynamicCastToExp
(
EGG::Heap::getCurrentHeap
());
34
ASSERT
(heap);
35
heap->
setGroupID
(
static_cast<
u16
>
(
GroupID::None
));
36
#endif
37
}
38
};
39
40
}
// namespace Kinoko
Common.hh
This header houses common data types such as our integral types and enums.
ASSERT
#define ASSERT(e)
Definition
Logger.hh:25
WARN
#define WARN(m,...)
Definition
Logger.hh:33
Kinoko::EGG::ExpHeap
High-level implementation of a memory heap for managing dynamic memory allocation....
Definition
egg/core/ExpHeap.hh:15
Kinoko::EGG::ExpHeap::getGroupID
u16 getGroupID() const
Definition
egg/core/ExpHeap.cc:115
Kinoko::EGG::ExpHeap::setGroupID
void setGroupID(u16 groupID)
Definition
egg/core/ExpHeap.cc:111
Kinoko::EGG::Heap::getCurrentHeap
static Heap * getCurrentHeap()
Definition
Heap.hh:115
Kinoko::EGG::Heap::dynamicCastToExp
static ExpHeap * dynamicCastToExp(Heap *heap)
Definition
Heap.hh:107
Kinoko::ScopeLock< GroupID >::~ScopeLock
~ScopeLock()
Definition
ScopeLock.hh:31
Kinoko::ScopeLock< GroupID >::ScopeLock
ScopeLock(GroupID newID)
Temporarily changes the group ID of a given heap to better track memory allocation.
Definition
ScopeLock.hh:17
Kinoko::ScopeLock
Definition
ScopeLock.hh:10
ExpHeap.hh
Kinoko
Definition
abstract/Archive.cc:5
Kinoko::GroupID
GroupID
Definition
Common.hh:165
Kinoko::GroupID::None
@ None
Definition
Common.hh:166
Kinoko::u16
uint16_t u16
Definition
Memory.hh:17
include
ScopeLock.hh
Made by
Malleo
. Logo by
vabold
. Website generated by
Doxygen
1.18.0