Nebula
Loading...
Searching...
No Matches
osxsingleton.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) 2010 Radon Labs GmbH (C) 2013-2018 Individual contributors, see AUTHORS file

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(!Singleton.isvalid()); Singleton.set(this);
 
#define __ConstructInterfaceSingleton   n_assert(0 == Singleton); Singleton = this;
 
#define __DestructSingleton   n_assert(Singleton.isvalid()); Singleton.set(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(!Singleton.isvalid()); Singleton.set(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 type * Instance() { n_assert(!Singleton.isvalid()); return Singleton.get(); }; \
static bool HasInstance() { return Singleton.isvalid(); }; \
private:
GCC doesn't implement the __thread modifier on OSX.
Definition posixthreadlocalptr.h:28

◆ __DestructInterfaceSingleton

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

◆ __DestructSingleton

#define __DestructSingleton   n_assert(Singleton.isvalid()); Singleton.set(0);

◆ __ImplementInterfaceSingleton

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

◆ __ImplementSingleton

#define __ImplementSingleton ( type)
Value: