Horizon Official Technical Documentation
Grid< GRID_OBJECT_TYPES > Class Template Reference

#include <Grid.hpp>

+ Collaboration diagram for Grid< GRID_OBJECT_TYPES >:

Public Member Functions

template<class SPECIFIC_OBJECT >
void add_object (SPECIFIC_OBJECT *obj)
 
template<class VISITOR >
void visit (GridReferenceContainerVisitor< VISITOR, GridReferenceContainer< GRID_OBJECT_TYPES > > &visitor)
 
template<class T >
uint32_t getObjectCount () const
 Returns the number of object within the grid. More...
 

Public Attributes

GridReferenceContainer< GRID_OBJECT_TYPES > _container
 

Detailed Description

template<class GRID_OBJECT_TYPES>
class Grid< GRID_OBJECT_TYPES >

Grid is used to store objects in a 2D grid. This is used to speed up the search for objects in a given area. The grid is divided into cells of a given size. Each grid-cell contains a list of objects that are in that grid-cell. The grid is actually stored in the GridHolder class.

The Grid class is a container for objects.

  • The GridReferenceContainer class is a container for objects in a grid-cell.
  • The GridReferenceContainerVisitor class is used to visit the objects in a grid-cell.
    Template Parameters
    ACTIVE_OBJECTis the object that is stored in the grid.
    GRID_OBJECT_TYPESis a type-list of object types that are stored in the grid.
    Parameters
    _containeris the container for objects in the grid-cell.

Member Function Documentation

◆ add_object()

template<class GRID_OBJECT_TYPES >
template<class SPECIFIC_OBJECT >
void Grid< GRID_OBJECT_TYPES >::add_object ( SPECIFIC_OBJECT *  obj)
inline
55 {
56 _container.template insert<SPECIFIC_OBJECT>(obj);
57 assert(obj->has_valid_grid_reference());
58 }
GridReferenceContainer< GRID_OBJECT_TYPES > _container
Definition: Grid.hpp:71

References Grid< GRID_OBJECT_TYPES >::_container.

◆ getObjectCount()

template<class GRID_OBJECT_TYPES >
template<class T >
uint32_t Grid< GRID_OBJECT_TYPES >::getObjectCount ( ) const
inline

Returns the number of object within the grid.

69{ return uint32_t(_container.template count<T>()); }

References Grid< GRID_OBJECT_TYPES >::_container.

◆ visit()

template<class GRID_OBJECT_TYPES >
template<class VISITOR >
void Grid< GRID_OBJECT_TYPES >::visit ( GridReferenceContainerVisitor< VISITOR, GridReferenceContainer< GRID_OBJECT_TYPES > > &  visitor)
inline
62 {
63 visitor.Visit(_container);
64 }
void Visit(TYPE_CONTAINER &c)
Definition: GridReferenceContainerVisitor.hpp:74

References Grid< GRID_OBJECT_TYPES >::_container.

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

+ Here is the caller graph for this function:

Member Data Documentation

◆ _container

template<class GRID_OBJECT_TYPES >
GridReferenceContainer<GRID_OBJECT_TYPES> Grid< GRID_OBJECT_TYPES >::_container

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