A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
ScopeLock.hh
1#pragma once
2
3#include <Common.hh>
4
5#include <egg/core/ExpHeap.hh>
6
7namespace Kinoko {
8
9template <typename T>
11
12template <>
13class ScopeLock<GroupID> {
14public:
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
This header houses common data types such as our integral types and enums.
High-level implementation of a memory heap for managing dynamic memory allocation....
Definition ExpHeap.hh:15
ScopeLock(GroupID newID)
Temporarily changes the group ID of a given heap to better track memory allocation.
Definition ScopeLock.hh:17