| Fling Engine 0.00.1 Fling Engine is a game engine written in Vulkan

Singleton.hpp
Go to the documentation of this file.
1 #pragma once
2
3 #include "FlingExports.h"
4
5 namespace Fling
6 {
10 template <class T>
11 class Singleton
12 {
13 public:
14
15 static T& Get();
16
17 // Have separate virtual init and shutdown functions so that we
18 // can control the creation order
19
20 FLING_API virtual void Init() {}
21
22 FLING_API virtual void Shutdown() {}
23
24 protected:
25
31 explicit Singleton<T>() = default;
32
33 };
34
35 template<typename T>
36 T& Singleton<T>::Get()
37 {
38 static_assert(std::is_default_constructible<T>::value,
39 "T is required to be default constructible");
40
41 static T m_Instance;
42
43 return m_Instance;
44 }
45
46 } // namespace Fling
Fling::Singleton::Init
virtual FLING_API void Init()
Definition: Singleton.hpp:20
Fling::Singleton
Class that can have only one instance.
Definition: Singleton.hpp:11
Fling::Singleton::Shutdown
virtual FLING_API void Shutdown()
Definition: Singleton.hpp:22
FlingExports.h
Fling::Singleton::Get
static T & Get()
Definition: Singleton.hpp:36
Fling
Definition: Engine.h:29