Nebula
Loading...
Searching...
No Matches
win32singleton.h File Reference

Detailed Description

Provides helper macros to implement singleton objects:

  • __DeclareSingleton put this into class declaration
  • __ImplementSingleton put this into the implemention file
  • __ConstructSingleton put this into the constructor
  • __DestructSingleton put this into the destructor

Get a pointer to a singleton object using the static Instance() method:

Core::Server* coreServer = Core::Server::Instance();

#include "core/types.h"

Go to the source code of this file.

Macros

#define __DeclareSingleton(type)
 
#define __DeclareInterfaceSingleton(type)
 
#define __ImplementSingleton(type)
 
#define __ImplementInterfaceSingleton(type)
 
#define __ConstructSingleton    n_assert(nullptr == Singleton); Singleton = this;
 
#define __ConstructInterfaceSingleton    n_assert(nullptr == Singleton); Singleton = this;
 
#define __DestructSingleton    n_assert(Singleton); Singleton = nullptr;
 
#define __DestructInterfaceSingleton    n_assert(Singleton); Singleton = nullptr;
 

Macro Definition Documentation

◆ __ConstructInterfaceSingleton

#define __ConstructInterfaceSingleton    n_assert(nullptr == Singleton); Singleton = this;

◆ __ConstructSingleton

#define __ConstructSingleton    n_assert(nullptr == Singleton); Singleton = this;

◆ __DeclareInterfaceSingleton

#define __DeclareInterfaceSingleton ( type)
Value:
public: \
static type * Singleton; \
static type * Instance() { n_assert(nullptr != Singleton); return Singleton; }; \
static bool HasInstance() { return nullptr != Singleton; }; \
private:
Implements a system specific Singleton.
#define n_assert(exp)
Definition debug.h:50

◆ __DeclareSingleton

#define __DeclareSingleton ( type)
Value:
public: \
thread_local static type * Singleton; \
static type * Instance() { n_assert(nullptr != Singleton); return Singleton; }; \
static bool HasInstance() { return nullptr != Singleton; }; \
private:

◆ __DestructInterfaceSingleton

#define __DestructInterfaceSingleton    n_assert(Singleton); Singleton = nullptr;

◆ __DestructSingleton

#define __DestructSingleton    n_assert(Singleton); Singleton = nullptr;

◆ __ImplementInterfaceSingleton

#define __ImplementInterfaceSingleton ( type)
Value:
type * type::Singleton = nullptr;

◆ __ImplementSingleton

#define __ImplementSingleton ( type)
Value:
thread_local type * type::Singleton = nullptr;