Horizon Official Technical Documentation
GridHolder< ZONE_OBJECT_TYPES > Class Template Reference

GridHolder is a container for Grids, handles the visiting of grids. More...

#include <GridHolder.hpp>

+ Collaboration diagram for GridHolder< ZONE_OBJECT_TYPES >:

Public Types

typedef Grid< ZONE_OBJECT_TYPES > GridType
 

Public Member Functions

 GridHolder (int width, int height)
 
 ~GridHolder ()
 
GridTypeget_grid (int x, int y)
 
uint16_t height ()
 
uint16_t width ()
 
template<class VISITOR , class CONTAINER_TYPE >
void visit_all (GridReferenceContainerVisitor< VISITOR, GridReferenceContainer< CONTAINER_TYPE > > &visitor)
 
template<class VISITOR , class CONTAINER_TYPE >
void visit (int x, int y, GridReferenceContainerVisitor< VISITOR, GridReferenceContainer< CONTAINER_TYPE > > &visitor)
 

Private Attributes

int _width { 0 }
 
int _height { 0 }
 
GridType _grids [MAX_GRIDS_PER_MAP][MAX_GRIDS_PER_MAP]
 

Detailed Description

template<class ZONE_OBJECT_TYPES>
class GridHolder< ZONE_OBJECT_TYPES >

GridHolder is a container for Grids, handles the visiting of grids.

Template Parameters
ZONE_OBJECT_TYPESTypeList of all the objects that can be stored in the grid.
Parameters
_boundsThe bounds of the GridHolder.
_gridsThe Grids contained in the GridHolder.

Member Typedef Documentation

◆ GridType

template<class ZONE_OBJECT_TYPES >
typedef Grid<ZONE_OBJECT_TYPES> GridHolder< ZONE_OBJECT_TYPES >::GridType

Constructor & Destructor Documentation

◆ GridHolder()

template<class ZONE_OBJECT_TYPES >
GridHolder< ZONE_OBJECT_TYPES >::GridHolder ( int  width,
int  height 
)
inline
50 {
51 }
int _height
Definition: GridHolder.hpp:86
int _width
Definition: GridHolder.hpp:86
uint16_t width()
Definition: GridHolder.hpp:67
uint16_t height()
Definition: GridHolder.hpp:66

◆ ~GridHolder()

template<class ZONE_OBJECT_TYPES >
GridHolder< ZONE_OBJECT_TYPES >::~GridHolder ( )
inline
54 {
55 }

Member Function Documentation

◆ get_grid()

template<class ZONE_OBJECT_TYPES >
GridType & GridHolder< ZONE_OBJECT_TYPES >::get_grid ( int  x,
int  y 
)
inline
58 {
59 assert(x <= _width);
60 assert(y <= _height);
61 assert(x >= 0 && y >= 0);
62
63 return _grids[x][y];
64 }
GridType _grids[MAX_GRIDS_PER_MAP][MAX_GRIDS_PER_MAP]
Definition: GridHolder.hpp:87

References GridHolder< ZONE_OBJECT_TYPES >::_grids, GridHolder< ZONE_OBJECT_TYPES >::_height, and GridHolder< ZONE_OBJECT_TYPES >::_width.

Referenced by Horizon::Zone::Map::ensure_grid_for_unit(), GridHolder< ZONE_OBJECT_TYPES >::visit(), and GridHolder< ZONE_OBJECT_TYPES >::visit_all().

+ Here is the caller graph for this function:

◆ height()

template<class ZONE_OBJECT_TYPES >
uint16_t GridHolder< ZONE_OBJECT_TYPES >::height ( )
inline

◆ visit()

template<class ZONE_OBJECT_TYPES >
template<class VISITOR , class CONTAINER_TYPE >
void GridHolder< ZONE_OBJECT_TYPES >::visit ( int  x,
int  y,
GridReferenceContainerVisitor< VISITOR, GridReferenceContainer< CONTAINER_TYPE > > &  visitor 
)
inline
81 {
82 get_grid(x, y).Visit(visitor);
83 }
GridType & get_grid(int x, int y)
Definition: GridHolder.hpp:57

References GridHolder< ZONE_OBJECT_TYPES >::get_grid().

+ Here is the call graph for this function:

◆ visit_all()

template<class ZONE_OBJECT_TYPES >
template<class VISITOR , class CONTAINER_TYPE >
void GridHolder< ZONE_OBJECT_TYPES >::visit_all ( GridReferenceContainerVisitor< VISITOR, GridReferenceContainer< CONTAINER_TYPE > > &  visitor)
inline
71 {
72 for (uint16_t x = 0; x < _width; ++x) {
73 for (uint16_t y = 0; y < _height; ++y) {
74 get_grid(x, y).visit(visitor);
75 }
76 }
77 }
void visit(GridReferenceContainerVisitor< VISITOR, GridReferenceContainer< GRID_OBJECT_TYPES > > &visitor)
Definition: Grid.hpp:61

References GridHolder< ZONE_OBJECT_TYPES >::_height, GridHolder< ZONE_OBJECT_TYPES >::_width, GridHolder< ZONE_OBJECT_TYPES >::get_grid(), and Grid< GRID_OBJECT_TYPES >::visit().

+ Here is the call graph for this function:

◆ width()

template<class ZONE_OBJECT_TYPES >
uint16_t GridHolder< ZONE_OBJECT_TYPES >::width ( )
inline

Member Data Documentation

◆ _grids

template<class ZONE_OBJECT_TYPES >
GridType GridHolder< ZONE_OBJECT_TYPES >::_grids[MAX_GRIDS_PER_MAP][MAX_GRIDS_PER_MAP]
private

◆ _height

template<class ZONE_OBJECT_TYPES >
int GridHolder< ZONE_OBJECT_TYPES >::_height { 0 }
private

◆ _width

template<class ZONE_OBJECT_TYPES >
int GridHolder< ZONE_OBJECT_TYPES >::_width { 0 }
private

The documentation for this class was generated from the following files: