Wire Sysio
Wire Sysion 1.0.0
Loading...
Searching...
No Matches
catch_singletons.hpp
Go to the documentation of this file.
1
/*
2
* Created by Phil Nash on 15/6/2018.
3
*
4
* Distributed under the Boost Software License, Version 1.0. (See accompanying
5
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6
*/
7
#ifndef TWOBLUECUBES_CATCH_SINGLETONS_HPP_INCLUDED
8
#define TWOBLUECUBES_CATCH_SINGLETONS_HPP_INCLUDED
9
10
namespace
Catch
{
11
12
struct
ISingleton
{
13
virtual
~ISingleton
();
14
};
15
16
17
void
addSingleton
(
ISingleton
* singleton );
18
void
cleanupSingletons
();
19
20
21
template
<
typename
SingletonImplT,
typename
InterfaceT = SingletonImplT,
typename
MutableInterfaceT = InterfaceT>
22
class
Singleton
: SingletonImplT,
public
ISingleton
{
23
24
static
auto
getInternal() ->
Singleton
* {
25
static
Singleton
* s_instance =
nullptr
;
26
if
( !s_instance ) {
27
s_instance =
new
Singleton
;
28
addSingleton
( s_instance );
29
}
30
return
s_instance;
31
}
32
33
public
:
34
static
auto
get
() -> InterfaceT
const
& {
35
return
*getInternal();
36
}
37
static
auto
getMutable
() -> MutableInterfaceT& {
38
return
*getInternal();
39
}
40
};
41
42
}
// namespace Catch
43
44
#endif
// TWOBLUECUBES_CATCH_SINGLETONS_HPP_INCLUDED
Catch::Singleton
Definition
catch_singletons.hpp:22
Catch::Singleton::getMutable
static auto getMutable() -> MutableInterfaceT &
Definition
catch_singletons.hpp:37
Catch::Singleton::get
static auto get() -> InterfaceT const &
Definition
catch_singletons.hpp:34
Catch
Definition
231-Cfg-OutputStreams.cpp:32
Catch::addSingleton
void addSingleton(ISingleton *singleton)
Definition
catch_singletons.cpp:25
Catch::cleanupSingletons
void cleanupSingletons()
Definition
catch_singletons.cpp:28
Catch::ISingleton
Definition
catch_singletons.hpp:12
Catch::ISingleton::~ISingleton
virtual ~ISingleton()
Definition
catch_singletons.cpp:23
libraries
sys-vm
external
Catch2
include
internal
catch_singletons.hpp
Generated by
1.12.0