ezconfig
Create C++ Objects from Yaml and Json
Loading...
Searching...
No Matches
global.hpp File Reference

Utilities to define and maintain a global instance. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define EZ_GLOBAL_DECLARE(...)
 Declare a template specialization of gInstance.
 
#define EZ_GLOBAL_DEFINE(...)
 Define a template specialization of gInstance that returns the global instance.
 
#define EZ_GLOBAL_INSTANCE(...)
 Retrieve the global instance for a type.
 

Functions

template<typename T >
T & ezconfig::gInstance ()
 Getter for global instances.
 

Detailed Description

Utilities to define and maintain a global instance.

Definition in file global.hpp.

Macro Definition Documentation

◆ EZ_GLOBAL_DECLARE

#define EZ_GLOBAL_DECLARE ( ...)
Value:
template<> \
__VA_ARGS__ & ::ezconfig::gInstance<__VA_ARGS__>()

Declare a template specialization of gInstance.

Use this in the '.hpp' file to declare a global instance getter for the class.

Note
Must be used outside of namespaces.

Definition at line 29 of file global.hpp.

◆ EZ_GLOBAL_DEFINE

#define EZ_GLOBAL_DEFINE ( ...)
Value:
template<> \
__VA_ARGS__ & ::ezconfig::gInstance<__VA_ARGS__>() \
{ \
static __VA_ARGS__ global_instance{}; \
return global_instance; \
} \
static_assert(true)

Define a template specialization of gInstance that returns the global instance.

Use this in the '.cpp' file to define a unique global instance for the class.

Note
Must be used outside of namespaces.

Definition at line 40 of file global.hpp.

◆ EZ_GLOBAL_INSTANCE

#define EZ_GLOBAL_INSTANCE ( ...)
Value:
::ezconfig::gInstance<__VA_ARGS__>()

Retrieve the global instance for a type.

Definition at line 52 of file global.hpp.

Function Documentation

◆ gInstance()

template<typename T >
T & ezconfig::gInstance ( )

Getter for global instances.

Use the macros below to declare and define global instance getters.