Assignments
Assignments
Toggle main menu visibility
Main Page
Namespaces
Namespace List
Namespace Members
All
_
b
c
d
e
f
g
i
j
k
m
n
o
p
q
r
s
t
u
w
Functions
_
b
c
d
e
f
g
j
m
n
o
r
s
t
u
w
Variables
Typedefs
Enumerator
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Typedefs
Enumerations
Enumerator
Related Symbols
o
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
y
Functions
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
w
y
Variables
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
Typedefs
_
b
c
d
e
f
g
h
i
j
l
m
p
r
s
u
v
w
Enumerations
Enumerator
h
j
m
o
Macros
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
factory.h
Go to the documentation of this file.
1
#ifndef FACTORY_INCLUDED
2
#define FACTORY_INCLUDED
3
4
#include <type_traits>
5
6
namespace
Util
7
{
10
template
<
typename
BaseType >
11
class
BaseFactory
12
{
14
std::vector< BaseType * >
_baseTypes
;
15
17
virtual
BaseType *
_create
(
void
) = 0;
18
19
public
:
21
virtual
~BaseFactory
(
void
){
for
(
int
i=0 ; i<
_baseTypes
.size() ; i++ )
delete
_baseTypes
[i]; }
22
24
BaseType *
create
(
void
)
25
{
26
BaseType *baseType =
_create
();
27
_baseTypes
.push_back( baseType );
28
return
baseType;
29
}
24
BaseType *
create
(
void
) {
…
}
30
32
template
<
typename
DerivedType >
33
BaseType *
create
(
void
)
34
{
35
static_assert
( std::is_base_of< BaseType , DerivedType >::value ,
"[ERROR] BaseType must be base of DerivedType"
);
36
BaseType *baseType =
new
DerivedType();
37
_baseTypes
.push_back( baseType );
38
return
baseType;
39
}
33
BaseType *
create
(
void
) {
…
}
40
};
11
class
BaseFactory
{
…
};
41
43
template
<
typename
BaseType ,
typename
DerivedType >
44
class
DerivedFactory
:
public
BaseFactory
< BaseType >
45
{
46
static_assert
( std::is_base_of< BaseType , DerivedType >::value ,
"[ERROR] BaseType must be base of DerivedType"
);
47
49
// BaseFactory< BaseType > methods //
51
BaseType *
_create
(
void
){
return
new
DerivedType(); }
52
};
44
class
DerivedFactory
:
public
BaseFactory
< BaseType > {
…
};
53
}
54
#endif
// FACTORY_INCLUDED
Util::BaseFactory
Definition
factory.h:12
Util::BaseFactory::create
BaseType * create(void)
Definition
factory.h:33
Util::BaseFactory::_create
virtual BaseType * _create(void)=0
Util::BaseFactory::_baseTypes
std::vector< BaseType * > _baseTypes
Definition
factory.h:14
Util::BaseFactory::~BaseFactory
virtual ~BaseFactory(void)
Definition
factory.h:21
Util::BaseFactory::create
BaseType * create(void)
Definition
factory.h:24
Util::DerivedFactory
Definition
factory.h:45
Util::DerivedFactory::_create
BaseType * _create(void)
Definition
factory.h:51
Util
Definition
algebra.h:7
Assignments
Util
factory.h
Generated by
1.11.0