-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabort_handler.h
51 lines (42 loc) · 881 Bytes
/
abort_handler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#pragma once
#include <cstdlib>
namespace AbortHandler
{
struct IAborter
{
virtual void Abort() const = 0;
};
struct Aborter final : public IAborter
{
void Abort() const override
{
//std::cout << "abort" << std::endl;
//std::abort();
}
};
struct MockAborter final : public IAborter
{
void Abort() const override
{
//std::cout << "mock_abort" << std::endl;
//std::abort();
}
};
namespace Handlers
{
constexpr static const Aborter DefaultAbortHandler;
constexpr static const MockAborter DefaultMockAbortHandler;
}
namespace
{
static const IAborter* currentAbortHandler = &Handlers::DefaultAbortHandler;
}
inline static void SetAbortHandler(const IAborter& abortHandler)
{
currentAbortHandler = &abortHandler;
}
inline static void Abort(const IAborter& abortHandler = *currentAbortHandler)
{
abortHandler.Abort();
}
}