JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
Singleton< T > Class Template Reference

Inherit from this class to create a singleton that will be destroyed when your games exits. More...

#include <jngl/Singleton.hpp>

Public Member Functions

 Singleton (const Singleton &)=delete
 
Singletonoperator= (const Singleton &)=delete
 
 Singleton (Singleton &&)=delete
 
Singletonoperator= (Singleton &&)=delete
 

Static Public Member Functions

static T & handle ()
 Creates the Singleton if needed. More...
 
static T * handleIfAlive () noexcept
 Doesn't create the Singleton, may return nullptr. More...
 

Detailed Description

template<class T>
class jngl::Singleton< T >

Inherit from this class to create a singleton that will be destroyed when your games exits.

You should use this instead of global / static variables, because some platforms (Android) don't destroy the process on exit and instead re-enter the main function.

class Foo : public jngl::Singleton<Foo>
// ...
}
// somewhere else:
Foo::handle().bar();
Inherit from this class to create a singleton that will be destroyed when your games exits.
Definition: Singleton.hpp:23

Definition at line 23 of file Singleton.hpp.

Member Function Documentation

◆ handle()

static T & handle ( )
inlinestatic

Creates the Singleton if needed.

Definition at line 32 of file Singleton.hpp.

◆ handleIfAlive()

static T * handleIfAlive ( )
inlinestaticnoexcept

Doesn't create the Singleton, may return nullptr.

Definition at line 44 of file Singleton.hpp.


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