Horizon Official Technical Documentation
Grid.hpp
Go to the documentation of this file.
1/***************************************************
2 * _ _ _ *
3 * | | | | (_) *
4 * | |_| | ___ _ __ _ _______ _ __ *
5 * | _ |/ _ \| '__| |_ / _ \| '_ \ *
6 * | | | | (_) | | | |/ / (_) | | | | *
7 * \_| |_/\___/|_| |_/___\___/|_| |_| *
8 ***************************************************
9 * This file is part of Horizon (c).
10 *
11 * Copyright (c) 2019 Sagun K. (sagunxp@gmail.com).
12 * Copyright (c) 2019 Horizon Dev Team.
13 *
14 * Base Author - Sagun K. (sagunxp@gmail.com)
15 *
16 * This library is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation, either version 3 of the License, or
19 * (at your option) any later version.
20 *
21 * This library is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this library. If not, see <http://www.gnu.org/licenses/>.
28 **************************************************/
29
30#ifndef HORIZON_ZONE_GAME_GRID_HPP
31#define HORIZON_ZONE_GAME_GRID_HPP
32
35
46template
47<
48 class GRID_OBJECT_TYPES
49>
50class Grid
51{
52public:
53 template <class SPECIFIC_OBJECT>
54 void add_object(SPECIFIC_OBJECT *obj)
55 {
56 _container.template insert<SPECIFIC_OBJECT>(obj);
57 assert(obj->has_valid_grid_reference());
58 }
59
60 template <class VISITOR>
62 {
63 visitor.Visit(_container);
64 }
65
68 template <class T>
69 uint32_t getObjectCount() const { return uint32_t(_container.template count<T>()); }
70
72};
73
74#endif /* HORIZON_ZONE_GAME_GRID_HPP */
Definition: GridReferenceContainerVisitor.hpp:70
Definition: Grid.hpp:51
void add_object(SPECIFIC_OBJECT *obj)
Definition: Grid.hpp:54
GridReferenceContainer< GRID_OBJECT_TYPES > _container
Definition: Grid.hpp:71
void visit(GridReferenceContainerVisitor< VISITOR, GridReferenceContainer< GRID_OBJECT_TYPES > > &visitor)
Definition: Grid.hpp:61
uint32_t getObjectCount() const
Returns the number of object within the grid.
Definition: Grid.hpp:69