Drive Engine
1.0.0
Plateforme de reconstruction 3D
Main Page
Classes
Files
File List
ImplementationUtilities.h
1
// Copyright (c) 2015. All rights reserved to DriveEngine Team.
2
3
#pragma once
4
#include "MemoryManagement.h"
5
6
#define _STRIP_ARG(x)
7
#define _KEEP_ARG(x) x
8
#define _STRIP_ARGUMENT_TYPE(x) _STRIP_ARG x
9
#define _KEEP_ARGUMENT_TYPE(x) _KEEP_ARG x
10
11
#define _COUNT_ARGS_SEQ(_1,_2,_3,_4,_5,_6,_7,_8,N,...) N
12
#define _COUNT_ARGS_SEQ_MSVC(x) _COUNT_ARGS_SEQ x
13
#define _COUNT_ARGS(...) _COUNT_ARGS_SEQ_MSVC((__VA_ARGS__, 8, 7, 6, 5, 4, 3, 2, 1))
14
15
#define _CONCAT_IN(x, y) x ## y
16
#define _CONCAT_IN_MSVC(x) _CONCAT_IN x
17
#define _CONCAT(x, y) _CONCAT_IN_MSVC((x, y))
18
19
#define _FORMAT_ARGS_MSVC(m, x) m x
20
#define _FORMAT_ARGS(macro, ...) _FORMAT_ARGS_MSVC(_CONCAT(_FORMAT_ARGS_, _COUNT_ARGS(__VA_ARGS__)), (macro, __VA_ARGS__))
21
#define _FORMAT_ARGS_1(m, x1) m(x1)
22
#define _FORMAT_ARGS_2(m, x1, x2) m(x1), m(x2)
23
#define _FORMAT_ARGS_3(m, x1, x2, x3) m(x1), m(x2), m(x3)
24
#define _FORMAT_ARGS_4(m, x1, x2, x3, x4) m(x1), m(x2), m(x3), m(x4)
25
#define _FORMAT_ARGS_5(m, x1, x2, x3, x4, x5) m(x1), m(x2), m(x3), m(x4), m(x5)
26
#define _FORMAT_ARGS_6(m, x1, x2, x3, x4, x5, x6) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6)
27
#define _FORMAT_ARGS_7(m, x1, x2, x3, x4, x5, x6, x7) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7)
28
#define _FORMAT_ARGS_8(m, x1, x2, x3, x4, x5, x6, x7, x8) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8)
29
30
31
#define DEFAULT_CONSTRUCTOR(interfaceName, className) \
32
interfaceName* className::Create() \
33
{\
34
interfaceName* instance = new className(); \
35
::AddReference(instance); \
36
return instance; \
37
}\
38
\
39
className::className()
40
41
42
#define CONSTRUCTOR(interfaceName, className, ...) \
43
interfaceName* className::Create(_FORMAT_ARGS(_KEEP_ARGUMENT_TYPE, __VA_ARGS__)) \
44
{\
45
interfaceName* instance = new className(_FORMAT_ARGS(_STRIP_ARGUMENT_TYPE, __VA_ARGS__)); \
46
::AddReference(instance); \
47
return instance; \
48
}\
49
\
50
className::className(_FORMAT_ARGS(_KEEP_ARGUMENT_TYPE, __VA_ARGS__))
51
52
53
#define CONSTRUCTOR_INNER(interfaceName, parentClassName, className, ...) \
54
interfaceName* parentClassName::className::Create(_FORMAT_ARGS(_KEEP_ARGUMENT_TYPE, __VA_ARGS__)) \
55
{\
56
interfaceName* instance = new className(_FORMAT_ARGS(_STRIP_ARGUMENT_TYPE, __VA_ARGS__)); \
57
::AddReference(instance); \
58
return instance; \
59
}\
60
\
61
parentClassName::className::className(_FORMAT_ARGS(_KEEP_ARGUMENT_TYPE, __VA_ARGS__))
62
63
64
#define CONSTRUCTOR_H(interfaceName, className, ...) \
65
public:\
66
static interfaceName* Create(##__VA_ARGS__); \
67
private:\
68
className(##__VA_ARGS__);
69
70
71
#define DESTRUCTOR(className) \
72
void className::Delete() const \
73
{\
74
if (::IsReferenceExist(this))\
75
{\
76
::DeleteReference(this);\
77
}\
78
else\
79
{\
80
delete this; \
81
}\
82
}\
83
\
84
className::~className()
85
86
87
#define DESTRUCTOR_INNER(parentClassName, className) \
88
void parentClassName::className::Delete() const \
89
{\
90
if (::IsReferenceExist(this))\
91
{\
92
::DeleteReference(this);\
93
}\
94
else\
95
{\
96
delete this; \
97
}\
98
}\
99
\
100
parentClassName::className::~className()
101
102
103
#define DESTRUCTOR_H(className) \
104
public:\
105
virtual void Delete() const; \
106
protected:\
107
virtual ~className();
108
109
110
#define SP(interfaceName, smartPointerName, pointerReference) \
111
std::shared_ptr<interfaceName> smartPointerName(pointerReference, std::mem_fn(&IExportable::Delete));
Framework
Public
ImplementationUtilities
ImplementationUtilities.h
Generated by
1.8.10