Project SkyFire Core
SkyFire 5.4.8 server core API documentation
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 */
25template<class OBJECT> struct ContainerMapList
26{
27 //std::map<OBJECT_HANDLE, OBJECT *> _element;
29};
30
31template<> struct ContainerMapList<TypeNull> /* nothing is in type null */
32{
33};
39
40/*
41 * @class ContaierArrayList is a multi-type container for
42 * array of elements.
43 */
44template<class OBJECT> struct ContainerArrayList
45{
46 std::vector<OBJECT> _element;
47};
48
49// termination condition
50template<> struct ContainerArrayList<TypeNull> { };
51// recursion
57
58/*
59 * @class ContainerList is a simple list of different types of elements
60 *
61 */
62template<class OBJECT> struct ContainerList
63{
64 OBJECT _element;
65};
66
67/* TypeNull is underfined */
68template<> struct ContainerList<TypeNull> { };
69template<class H, class T> struct ContainerList<TypeList<H, T> >
70{
73};
74
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
84template<class OBJECT_TYPES>
86{
87public:
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
106
107private:
109};
110#endif
111
bool insert(SPECIFIC_TYPE *obj)
inserts a specific object into the container
ContainerMapList< OBJECT_TYPES > & GetElements(void)
Removes the object from the container, and returns the removed object.
size_t Count() const
ContainerMapList< AllGridObjectTypes > i_elements
const ContainerMapList< OBJECT_TYPES > & GetElements(void) const
size_t Count(const ContainerMapList< SPECIFIC_TYPE > &elements, SPECIFIC_TYPE *)
SPECIFIC_TYPE * Insert(ContainerMapList< SPECIFIC_TYPE > &elements, SPECIFIC_TYPE *obj)
ContainerArrayList< T > _TailElements
std::vector< OBJECT > _element
ContainerMapList< T > _TailElements
ContainerMapList< T > _TailElements
GridRefManager< OBJECT > _element