PhasicFlow
v0.1
www.cemf.ir
virtualConstructor.hpp
Go to the documentation of this file.
1
/*------------------------------- phasicFlow ---------------------------------
2
O C enter of
3
O O E ngineering and
4
O O M ultiscale modeling of
5
OOOOOOO F luid flow
6
------------------------------------------------------------------------------
7
Copyright (C): www.cemf.ir
8
email: hamid.r.norouzi AT gmail.com
9
------------------------------------------------------------------------------
10
Licence:
11
This file is part of phasicFlow code. It is a free software for simulating
12
granular and multiphase flows. You can redistribute it and/or modify it under
13
the terms of GNU General Public License v3 or any other later versions.
14
15
phasicFlow is distributed to help others in their research in the field of
16
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18
19
-----------------------------------------------------------------------------*/
20
21
#ifndef __virtualConstructor_hpp__
22
#define __virtualConstructor_hpp__
23
24
#include <functional>
25
26
#include "
types.hpp
"
27
#include "
error.hpp
"
28
#include "
Map.hpp
"
29
#include "
uniquePtr.hpp
"
30
31
#define create_vCtor(baseClass,selectorName,argList,args) \
32
\
33
typedef std::function< uniquePtr<baseClass> argList > selectorName##FunctionType; \
34
typedef wordMap<selectorName##FunctionType> selectorName##vCtorSelectorType; \
35
\
36
inline static selectorName##vCtorSelectorType selectorName##vCtorSelector_; \
37
\
38
\
39
template<typename dType> \
40
class create##selectorName##Callback \
41
{ \
42
public: \
43
create##selectorName##Callback () \
44
{ \
45
auto success = \
46
selectorName##vCtorSelector_.insertIf \
47
( \
48
word(dType::TYPENAME()), \
49
[&] argList -> uniquePtr<baseClass> \
50
{ \
51
return uniquePtr<baseClass> \
52
( \
53
new dType args \
54
); \
55
} \
56
); \
57
\
58
if( !success ) \
59
{ \
60
fatalErrorInFunction \
61
<< "Duplicate entry "<< dType::TYPENAME() \
62
<< " in virtual constructor table of "<< #baseClass \
63
<< " with selector name " << #selectorName <<endl; \
64
} \
65
\
66
} \
67
\
68
create##selectorName##Callback \
69
(const create##selectorName##Callback&)= delete; \
70
void operator= \
71
(const create##selectorName##Callback&)= delete; \
72
};
73
74
75
76
#define add_vCtor(baseClass, derivedClass, selectorName) \
77
\
78
inline static baseClass::create##selectorName##Callback<derivedClass> baseClass##derivedClass##selectorName##_;
79
80
81
82
#endif // __virtualConstructor_hpp__
types.hpp
Map.hpp
uniquePtr.hpp
error.hpp
src
phasicFlow
typeSelection
virtualConstructor.hpp
Generated by
1.8.17