Leviathan  0.8.0.0
Leviathan game engine
Leviathan::ThisPointerTypeChecker< T > Class Template Reference

This can check the "this" pointer that the class' constructor was called on it. More...

#include <DebugObjectTracker.h>

Static Public Member Functions

static void NotifyConstructed (T *object)
 
static void NotifyDestructed (T *object)
 
static void CheckThis (T *object)
 

Detailed Description

template<class T>
class Leviathan::ThisPointerTypeChecker< T >

This can check the "this" pointer that the class' constructor was called on it.

This should be able to catch cases were wrong type of pointer is passed to an object

Quick usage for copy-paste:

ThisPointerTypeChecker<std::remove_pointer_t<decltype(this)>>::NotifyConstructed(this); ThisPointerTypeChecker<std::remove_pointer_t<decltype(this)>>::NotifyDestructed(this); ThisPointerTypeChecker<std::remove_pointer_t<decltype(this)>>::CheckThis(this);

Definition at line 22 of file DebugObjectTracker.h.

Member Function Documentation

◆ CheckThis()

template<class T >
static void Leviathan::ThisPointerTypeChecker< T >::CheckThis ( T *  object)
inlinestatic

Definition at line 34 of file DebugObjectTracker.h.

35  {
36  const auto found = ConstructedObjectsOfType.find(object);
37 
38  if(found == ConstructedObjectsOfType.end() || found->second == false) {
39  LOG_ERROR("ThisPointerTypeChecker: problem detected, pointer is wrong: " +
41  DEBUG_BREAK;
42  }
43  }
#define LOG_ERROR(x)
Definition: Define.h:84
static std::string ToHexadecimalString(const T &val)
Definition: Convert.h:93

◆ NotifyConstructed()

template<class T >
static void Leviathan::ThisPointerTypeChecker< T >::NotifyConstructed ( T *  object)
inlinestatic

Definition at line 24 of file DebugObjectTracker.h.

25  {
26  ConstructedObjectsOfType[object] = true;
27  }

◆ NotifyDestructed()

template<class T >
static void Leviathan::ThisPointerTypeChecker< T >::NotifyDestructed ( T *  object)
inlinestatic

Definition at line 29 of file DebugObjectTracker.h.

30  {
31  ConstructedObjectsOfType[object] = false;
32  }

The documentation for this class was generated from the following file: