A reimplementation of Mario Kart Wii's physics engine in C++
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
7namespace Kinoko {
8
9template <typename T>
11
12template <>
14public:
18#ifdef BUILD_DEBUG
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
32#ifdef BUILD_DEBUG
34 ASSERT(heap);
35 heap->setGroupID(static_cast<u16>(GroupID::None));
36#endif
37 }
38};
39
40} // namespace Kinoko
This header houses common data types such as our integral types and enums.
#define ASSERT(e)
Definition Logger.hh:25
#define WARN(m,...)
Definition Logger.hh:33
High-level implementation of a memory heap for managing dynamic memory allocation....
void setGroupID(u16 groupID)
static Heap * getCurrentHeap()
Definition Heap.hh:115
static ExpHeap * dynamicCastToExp(Heap *heap)
Definition Heap.hh:107
ScopeLock(GroupID newID)
Temporarily changes the group ID of a given heap to better track memory allocation.
Definition ScopeLock.hh:17
uint16_t u16
Definition Memory.hh:17