Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
TypeContainer.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_TYPECONTAINER_H
7
#define SKYFIRE_TYPECONTAINER_H
8
9
/*
10
* Here, you'll find a series of containers that allow you to hold multiple
11
* types of object at the same time.
12
*/
13
14
#include "
Define.h
"
15
#include "
Dynamic/TypeList.h
"
16
#include "
GridRefManager.h
"
17
#include <map>
18
#include <vector>
19
20
/*
21
* @class ContainerMapList is a mulit-type container for map elements
22
* By itself its meaningless but collaborate along with TypeContainers,
23
* it become the most powerfully container in the whole system.
24
*/
25
template
<
class
OBJECT>
struct
ContainerMapList
26
{
27
//std::map<OBJECT_HANDLE, OBJECT *> _element;
28
GridRefManager<OBJECT>
_element
;
29
};
30
31
template
<>
struct
ContainerMapList
<TypeNull>
/* nothing is in type null */
32
{
33
};
34
template
<
class
H,
class
T>
struct
ContainerMapList
<
TypeList
<H, T> >
35
{
36
ContainerMapList<H>
_elements
;
37
ContainerMapList<T>
_TailElements
;
38
};
39
40
/*
41
* @class ContaierArrayList is a multi-type container for
42
* array of elements.
43
*/
44
template
<
class
OBJECT>
struct
ContainerArrayList
45
{
46
std::vector<OBJECT>
_element
;
47
};
48
49
// termination condition
50
template
<>
struct
ContainerArrayList
<TypeNull> { };
51
// recursion
52
template
<
class
H,
class
T>
struct
ContainerArrayList
<
TypeList
<H, T> >
53
{
54
ContainerArrayList<H>
_elements
;
55
ContainerArrayList<T>
_TailElements
;
56
};
57
58
/*
59
* @class ContainerList is a simple list of different types of elements
60
*
61
*/
62
template
<
class
OBJECT>
struct
ContainerList
63
{
64
OBJECT
_element
;
65
};
66
67
/* TypeNull is underfined */
68
template
<>
struct
ContainerList
<TypeNull> { };
69
template
<
class
H,
class
T>
struct
ContainerList
<
TypeList
<H, T> >
70
{
71
ContainerList<H>
_elements
;
72
ContainerMapList<T>
_TailElements
;
73
};
74
75
#include "
TypeContainerFunctions.h
"
76
77
/*
78
* @class TypeMapContainer contains a fixed number of types and is
79
* determined at compile time. This is probably the most complicated
80
* class and do its simplest thing, that is, holds objects
81
* of different types.
82
*/
83
84
template
<
class
OBJECT_TYPES>
85
class
TypeMapContainer
86
{
87
public
:
88
template
<
class
SPECIFIC_TYPE>
size_t
Count
()
const
{
return
Skyfire::Count
(
i_elements
, (SPECIFIC_TYPE*)NULL); }
89
91
template
<
class
SPECIFIC_TYPE>
bool
insert
(SPECIFIC_TYPE* obj)
92
{
93
SPECIFIC_TYPE* t =
Skyfire::Insert
(
i_elements
, obj);
94
return
(t != NULL);
95
}
96
98
//template<class SPECIFIC_TYPE> bool remove(SPECIFIC_TYPE* obj)
99
//{
100
// SPECIFIC_TYPE* t = Skyfire::Remove(i_elements, obj);
101
// return (t != NULL);
102
//}
103
104
ContainerMapList<OBJECT_TYPES>
&
GetElements
(
void
) {
return
i_elements
; }
105
const
ContainerMapList<OBJECT_TYPES>
&
GetElements
(
void
)
const
{
return
i_elements
; }
106
107
private
:
108
ContainerMapList<OBJECT_TYPES>
i_elements
;
109
};
110
#endif
111
Define.h
GridRefManager.h
TypeContainerFunctions.h
TypeList.h
GridRefManager
Definition
GridRefManager.h:16
TypeMapContainer
Definition
TypeContainer.h:86
TypeMapContainer::insert
bool insert(SPECIFIC_TYPE *obj)
inserts a specific object into the container
Definition
TypeContainer.h:91
TypeMapContainer::GetElements
ContainerMapList< OBJECT_TYPES > & GetElements(void)
Removes the object from the container, and returns the removed object.
Definition
TypeContainer.h:104
TypeMapContainer::Count
size_t Count() const
Definition
TypeContainer.h:88
TypeMapContainer< AllGridObjectTypes >::i_elements
ContainerMapList< AllGridObjectTypes > i_elements
Definition
TypeContainer.h:108
TypeMapContainer::GetElements
const ContainerMapList< OBJECT_TYPES > & GetElements(void) const
Definition
TypeContainer.h:105
Skyfire::Count
size_t Count(const ContainerMapList< SPECIFIC_TYPE > &elements, SPECIFIC_TYPE *)
Definition
TypeContainerFunctions.h:23
Skyfire::Insert
SPECIFIC_TYPE * Insert(ContainerMapList< SPECIFIC_TYPE > &elements, SPECIFIC_TYPE *obj)
Definition
TypeContainerFunctions.h:49
ContainerArrayList< TypeList< H, T > >::_TailElements
ContainerArrayList< T > _TailElements
Definition
TypeContainer.h:55
ContainerArrayList< TypeList< H, T > >::_elements
ContainerArrayList< H > _elements
Definition
TypeContainer.h:54
ContainerArrayList
Definition
TypeContainer.h:45
ContainerArrayList::_element
std::vector< OBJECT > _element
Definition
TypeContainer.h:46
ContainerList< TypeList< H, T > >::_elements
ContainerList< H > _elements
Definition
TypeContainer.h:71
ContainerList< TypeList< H, T > >::_TailElements
ContainerMapList< T > _TailElements
Definition
TypeContainer.h:72
ContainerList
Definition
TypeContainer.h:63
ContainerList::_element
OBJECT _element
Definition
TypeContainer.h:64
ContainerMapList< TypeList< H, T > >::_elements
ContainerMapList< H > _elements
Definition
TypeContainer.h:36
ContainerMapList< TypeList< H, T > >::_TailElements
ContainerMapList< T > _TailElements
Definition
TypeContainer.h:37
ContainerMapList
Definition
TypeContainer.h:26
ContainerMapList::_element
GridRefManager< OBJECT > _element
Definition
TypeContainer.h:28
TypeList
Definition
TypeList.h:19
src
server
shared
Dynamic
TypeContainer.h
Generated on
for Project SkyFire Core by
1.17.0