Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
TypeContainerVisitor.h
Go to the documentation of this file.
1
/*
2
* This file is part of Project SkyFire https://www.projectskyfire.org.
3
* See LICENSE.md file for Copyright information
4
*/
5
6
#ifndef SKYFIRE_TYPECONTAINERVISITOR_H
7
#define SKYFIRE_TYPECONTAINERVISITOR_H
8
9
/*
10
* @class TypeContainerVisitor is implemented as a visitor pattern. It is
11
* a visitor to the TypeContainerList or TypeContainerMapList. The visitor has
12
* to overload its types as a visit method is called.
13
*/
14
15
#include "
Define.h
"
16
#include "
Dynamic/TypeContainer.h
"
17
18
// forward declaration
19
template
<
class
T,
class
Y>
class
TypeContainerVisitor
;
20
21
// visitor helper
22
template
<
class
VISITOR,
class
TYPE_CONTAINER>
void
VisitorHelper
(VISITOR& v, TYPE_CONTAINER& c)
23
{
24
v.
Visit
(c);
25
}
26
27
// terminate condition for container list
28
template
<
class
VISITOR>
void
VisitorHelper
(VISITOR&
/*v*/
,
ContainerList<TypeNull>
&
/*c*/
) { }
29
30
template
<
class
VISITOR,
class
T>
void
VisitorHelper
(VISITOR& v,
ContainerList<T>
& c)
31
{
32
v.Visit(c.
_element
);
33
}
34
35
// recursion for container list
36
template
<
class
VISITOR,
class
H,
class
T>
void
VisitorHelper
(VISITOR& v,
ContainerList
<
TypeList<H, T>
>& c)
37
{
38
VisitorHelper
(v, c._elements);
39
VisitorHelper
(v, c._TailElements);
40
}
41
42
// terminate condition container map list
43
template
<
class
VISITOR>
void
VisitorHelper
(VISITOR&
/*v*/
,
ContainerMapList<TypeNull>
&
/*c*/
) { }
44
45
template
<
class
VISITOR,
class
T>
void
VisitorHelper
(VISITOR& v,
ContainerMapList<T>
& c)
46
{
47
v.Visit(c.
_element
);
48
}
49
50
// recursion container map list
51
template
<
class
VISITOR,
class
H,
class
T>
void
VisitorHelper
(VISITOR& v,
ContainerMapList
<
TypeList<H, T>
>& c)
52
{
53
VisitorHelper
(v, c._elements);
54
VisitorHelper
(v, c._TailElements);
55
}
56
57
// array list
58
template
<
class
VISITOR,
class
T>
void
VisitorHelper
(VISITOR& v,
ContainerArrayList<T>
& c)
59
{
60
v.Visit(c.
_element
);
61
}
62
63
template
<
class
VISITOR>
void
VisitorHelper
(VISITOR&
/*v*/
,
ContainerArrayList<TypeNull>
&
/*c*/
) { }
64
65
// recursion
66
template
<
class
VISITOR,
class
H,
class
T>
void
VisitorHelper
(VISITOR& v,
ContainerArrayList
<
TypeList<H, T>
>& c)
67
{
68
VisitorHelper
(v, c._elements);
69
VisitorHelper
(v, c._TailElements);
70
}
71
72
// for TypeMapContainer
73
template
<
class
VISITOR,
class
OBJECT_TYPES>
void
VisitorHelper
(VISITOR& v,
TypeMapContainer<OBJECT_TYPES>
& c)
74
{
75
VisitorHelper
(v, c.
GetElements
());
76
}
77
78
template
<
class
VISITOR,
class
TYPE_CONTAINER>
79
class
TypeContainerVisitor
80
{
81
public
:
82
TypeContainerVisitor
(VISITOR& v) :
i_visitor
(v) { }
83
84
void
Visit
(TYPE_CONTAINER& c)
85
{
86
VisitorHelper
(
i_visitor
, c);
87
}
88
89
void
Visit
(
const
TYPE_CONTAINER& c)
const
90
{
91
VisitorHelper
(
i_visitor
, c);
92
}
93
94
private
:
95
VISITOR&
i_visitor
;
96
};
97
#endif
98
Define.h
TypeContainer.h
VisitorHelper
void VisitorHelper(VISITOR &v, TYPE_CONTAINER &c)
Definition
TypeContainerVisitor.h:22
TypeContainerVisitor
Definition
TypeContainerVisitor.h:80
TypeContainerVisitor::TypeContainerVisitor
TypeContainerVisitor(VISITOR &v)
Definition
TypeContainerVisitor.h:82
TypeContainerVisitor::i_visitor
VISITOR & i_visitor
Definition
TypeContainerVisitor.h:95
TypeContainerVisitor::Visit
void Visit(const TYPE_CONTAINER &c) const
Definition
TypeContainerVisitor.h:89
TypeContainerVisitor::Visit
void Visit(TYPE_CONTAINER &c)
Definition
TypeContainerVisitor.h:84
TypeMapContainer
Definition
TypeContainer.h:86
TypeMapContainer::GetElements
ContainerMapList< OBJECT_TYPES > & GetElements(void)
Removes the object from the container, and returns the removed object.
Definition
TypeContainer.h:104
ContainerArrayList
Definition
TypeContainer.h:45
ContainerArrayList::_element
std::vector< OBJECT > _element
Definition
TypeContainer.h:46
ContainerList
Definition
TypeContainer.h:63
ContainerList::_element
OBJECT _element
Definition
TypeContainer.h:64
ContainerMapList
Definition
TypeContainer.h:26
ContainerMapList::_element
GridRefManager< OBJECT > _element
Definition
TypeContainer.h:28
TypeList
Definition
TypeList.h:19
src
server
shared
Dynamic
TypeContainerVisitor.h
Generated on
for Project SkyFire Core by
1.17.0