Nebula
Loading...
Searching...
No Matches
posixsingleton.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();

(C) 2007 Radon Labs GmbH (C) 2013-2018 Individual contributors, see AUTHORS file

#include "core/types.h"

Go to the source code of this file.

Macros

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

Macro Definition Documentation

◆ __ConstructInterfaceSingleton

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

◆ __ConstructSingleton

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

◆ __DeclareInterfaceSingleton

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

◆ __DeclareSingleton

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

◆ __DestructInterfaceSingleton

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

◆ __DestructSingleton

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

◆ __ImplementInterfaceSingleton

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

◆ __ImplementSingleton

#define __ImplementSingleton ( type)
Value:
ThreadLocal type * type::Singleton = 0;

◆ CORE_POSIXSINGLETON_H

#define CORE_POSIXSINGLETON_H