Ult3D
Implementation of "Ultimate 3D Game Engine Design & Architecture" by Allan Sherrod
Loading...
Searching...
No Matches
Handle.h
Go to the documentation of this file.
1#ifndef ULT_HANDLE_H_INCLUDED
2#define ULT_HANDLE_H_INCLUDED
3
4namespace Ult
5{
6
11template<typename T>
12class Handle
13{
14public:
15
16 static constexpr int NULL_HANDLE = -1;
17
22 mIndex(NULL_HANDLE)
23 {}
24
28 void Initialize(const int index) { mIndex = index; }
32 void Nullify() { mIndex = NULL_HANDLE; }
36 int GetIndex() const { return mIndex; }
40 bool IsNull() const { return mIndex <= NULL_HANDLE; }
41
45 bool operator==(const Handle<T>& handle) {
46 return mIndex == handle.mIndex;
47 }
48
49private:
50 int mIndex;
51};
52
53} // namespace Ult
54
55#endif // ULT_HANDLE_H_INCLUDED
56
bool IsNull() const
Definition Handle.h:40
bool operator==(const Handle< T > &handle)
Definition Handle.h:45
static constexpr int NULL_HANDLE
Definition Handle.h:16
void Initialize(const int index)
Definition Handle.h:28
void Nullify()
Definition Handle.h:32
Handle()
Definition Handle.h:21
int GetIndex() const
Definition Handle.h:36
Definition Archive.h:13