Kinoko
A reimplementation of Mario Kart Wii's physics engine in C++
Toggle main menu visibility
Loading...
Searching...
No Matches
ScopeLock.hh
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
EGG::ExpHeap
*heap = EGG::Heap::dynamicCastToExp(EGG::Heap::getCurrentHeap());
19
ASSERT(heap);
20
GroupID prevID =
static_cast<
GroupID
>
(heap->getGroupID());
21
22
if
(prevID != GroupID::None) {
23
WARN(
"Overwriting non-default group ID! Replacing %d with %d"
, prevID, newID);
24
}
25
26
heap->setGroupID(
static_cast<
u16
>
(newID));
27
}
28
29
~ScopeLock
() {
30
EGG::ExpHeap
*heap = EGG::Heap::dynamicCastToExp(EGG::Heap::getCurrentHeap());
31
ASSERT(heap);
32
heap->setGroupID(
static_cast<
u16
>
(GroupID::None));
33
}
34
};
35
36
}
// namespace Kinoko
Common.hh
This header houses common data types such as our integral types and enums.
Kinoko::EGG::ExpHeap
High-level implementation of a memory heap for managing dynamic memory allocation....
Definition
ExpHeap.hh:15
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
include
ScopeLock.hh
Made by
Malleo
. Logo by
vabold
. Website generated by
Doxygen
1.17.0