LkEngine 0.1.2
 
Loading...
Searching...
No Matches
ObjectPtrHelpers.h
1/******************************************************************
2 * ObjectPtrHelpers.h
3 *
4 *******************************************************************/
5
6#pragma once
7
8#define LK_OBJECTPTR_CUSTOM_EQUALITY_OP 1
9
10#define LK_DEBUG_LOG_LIVE_REFERENCES 0 /* Log whenever a reference is added/removed. */
11#define LK_DEBUG_LOG_OBJECTPTR 0 /* Log TObjectPtr constructors and destructor calls. */
12#define LK_DEBUG_OBJECTPTR_PARANOID 0 /* Validate the LObject pointer on all TObjectPtr access calls. */
13
14#if LK_DEBUG_OBJECTPTR_PARANOID
15# define LK_PTR_ASSERT(...) LK_CORE_ASSERT(__VA_ARGS__)
16#else
17# define LK_PTR_ASSERT(...)
18#endif
19
20#if LK_DEBUG_LOG_OBJECTPTR
21# define LK_DEBUG_PTR_LOG(...) \
22 if (ObjectPtr) \
23 { \
24 if (const LClass* ClassInfo = ObjectPtr->GetClass(); ClassInfo != nullptr) \
25 { \
26 LK_PRINTLN("[TObjectPtr::{}] {}", ClassInfo->GetName(), __VA_ARGS__); \
27 } \
28 else \
29 { \
30 LK_PRINTLN("[TObjectPtr::LObject] {}", __VA_ARGS__); \
31 } \
32 } \
33 else \
34 { \
35 LK_PRINTLN("[TObjectPtr] {}", __VA_ARGS__); \
36 }
37#else
38# define LK_DEBUG_PTR_LOG(...)
39#endif