Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
Grid.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_GRID_H
7#define SKYFIRE_GRID_H
8
9/*
10 @class Grid
11 Grid is a logical segment of the game world represented inside SkyFire.
12 Grid is bind at compile time to a particular type of object which
13 we call it the object of interested. There are many types of loader,
14 specially, dynamic loader, static loader, or on-demand loader. There's
15 a subtle difference between dynamic loader and on-demand loader but
16 this is implementation specific to the loader class. From the
17 Grid's perspective, the loader meets its API requirement is suffice.
18*/
19
20#include "Define.h"
21#include "TypeContainer.h"
23
24// forward declaration
25template<class A, class T, class O> class GridLoader;
26
27template
28<
29 class ACTIVE_OBJECT,
30 class WORLD_OBJECT_TYPES,
31 class GRID_OBJECT_TYPES
32>
33class Grid
34{
35 // allows the GridLoader to access its internals
36 template<class A, class T, class O> friend class GridLoader;
37public:
41 ~Grid() { }
42
45 template<class SPECIFIC_OBJECT> void AddWorldObject(SPECIFIC_OBJECT* obj)
46 {
47 i_objects.template insert<SPECIFIC_OBJECT>(obj);
48 ASSERT(obj->IsInGrid());
49 }
50
53 //Actually an unlink is enough, no need to go through the container
54 //template<class SPECIFIC_OBJECT> void RemoveWorldObject(SPECIFIC_OBJECT *obj)
55 //{
56 // ASSERT(obj->GetGridRef().isValid());
57 // i_objects.template remove<SPECIFIC_OBJECT>(obj);
58 // ASSERT(!obj->GetGridRef().isValid());
59 //}
60
63 //void RefreshGrid(void) { /* TBI */}
64
67 //void LockGrid(void) { /* TBI */ }
68
71 //void UnlockGrid(void) { /* TBI */ }
72
73 // Visit grid objects
74 template<class T>
76 {
77 visitor.Visit(i_container);
78 }
79
80 // Visit world objects
81 template<class T>
83 {
84 visitor.Visit(i_objects);
85 }
86
89 //unsigned int ActiveObjectsInGrid(void) const { return i_objects.template Count<ACTIVE_OBJECT>(); }
90 template<class T>
92 {
93 return i_objects.template Count<T>();
94 }
95
98 template<class SPECIFIC_OBJECT> void AddGridObject(SPECIFIC_OBJECT* obj)
99 {
100 i_container.template insert<SPECIFIC_OBJECT>(obj);
101 ASSERT(obj->IsInGrid());
102 }
103
106 //template<class SPECIFIC_OBJECT> void RemoveGridObject(SPECIFIC_OBJECT *obj)
107 //{
108 // ASSERT(obj->GetGridRef().isValid());
109 // i_container.template remove<SPECIFIC_OBJECT>(obj);
110 // ASSERT(!obj->GetGridRef().isValid());
111 //}
112
113 /*bool NoWorldObjectInGrid() const
114 {
115 return i_objects.GetElements().isEmpty();
116 }
117
118 bool NoGridObjectInGrid() const
119 {
120 return i_container.GetElements().isEmpty();
121 }*/
122
123private:
126 //typedef std::set<void*> ActiveGridObjects;
127 //ActiveGridObjects m_activeGridObjects;
128};
129#endif
std::uint32_t uint32
Definition Define.h:77
#define ASSERT
Definition Errors.h:29
Definition Grid.h:34
TypeMapContainer< AllWorldObjectTypes > i_objects
Definition Grid.h:125
TypeMapContainer< AllGridObjectTypes > i_container
Definition Grid.h:124
uint32 GetWorldObjectCountInGrid() const
Definition Grid.h:91
void Visit(TypeContainerVisitor< T, TypeMapContainer< GRID_OBJECT_TYPES > > &visitor)
Definition Grid.h:75
void AddWorldObject(SPECIFIC_OBJECT *obj)
Definition Grid.h:45
void AddGridObject(SPECIFIC_OBJECT *obj)
Definition Grid.h:98
~Grid()
Definition Grid.h:41
void Visit(TypeContainerVisitor< T, TypeMapContainer< WORLD_OBJECT_TYPES > > &visitor)
Definition Grid.h:82