-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMChunk.h
48 lines (39 loc) · 901 Bytes
/
MChunk.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef MChunk_h__
#define MChunk_h__
#include "Chunk.h"
template <class Meat>
class MChunk {
public:
MChunk (Chunk<Meat> *_chunk) {
this->chunk = _chunk;
this->chunk->Use ();
}
MChunk (const MChunk<Meat>& _other) {
this->chunk = _other.chunk;
this->chunk->Use ();
}
MChunk& operator= (const MChunk<Meat>& _other) {
this->chunk = _other.chunk;
this->chunk->Use ();
return *this;
}
~MChunk() {
if (this->chunk != nullptr) {
this->chunk->DisUse ();
}
}
MChunk () {
this->chunk = nullptr;
}
inline Chunk<Meat> *GetChunk () { return this->chunk; }
inline void SetChunk (Chunk<Meat> *_chunk) {
if (this->chunk != nullptr) {
this->chunk->DisUse ();
}
this->chunk = _chunk;
this->chunk->Use ();
}
private:
Chunk<Meat> *chunk; // The chunk that is managed by this ManagedChunk
};
#endif // MChunk_h__