Cytopia  0.3
A city building simulation game
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MapGrid< T > Class Template Referenceabstract

#include <MapGrid.hxx>

+ Inheritance diagram for MapGrid< T >:
+ Collaboration diagram for MapGrid< T >:

Public Member Functions

 MapGrid (T node)
 
virtual ~MapGrid ()=0
 
size_t size ()
 
virtual void addNode (T node)
 Add a T node to this gridnode. More...
 
virtual void removeNode (Point coordinate)
 Remove a node on a given coordinate from this gridnode. More...
 
bool isNeighbor (Point coordinate) const
 If this coordinate is a neighbor of one of the node in the grid. More...
 
bool isMemberOf (Point coordinate) const
 If this coordinate is part of the grid. More...
 
auto begin ()
 
auto end ()
 

Protected Attributes

std::vector< T > m_gridNodes
 

Detailed Description

template<class T>
class MapGrid< T >

Definition at line 7 of file MapGrid.hxx.

Constructor & Destructor Documentation

◆ MapGrid()

template<class T >
MapGrid< T >::MapGrid ( node)
explicit

Definition at line 3 of file MapGrid.inl.hxx.

3 : m_gridNodes{node} {}

◆ ~MapGrid()

template<class T >
MapGrid< T >::~MapGrid
pure virtual

Definition at line 5 of file MapGrid.inl.hxx.

5 { m_gridNodes.clear(); }

Member Function Documentation

◆ addNode()

template<class T >
void MapGrid< T >::addNode ( node)
virtual

Add a T node to this gridnode.

Parameters
nodeto add

Reimplemented in ZoneArea.

Definition at line 7 of file MapGrid.inl.hxx.

7 { m_gridNodes.push_back(node); }
+ Here is the caller graph for this function:

◆ begin()

template<class T >
auto MapGrid< T >::begin ( )
inline

Definition at line 46 of file MapGrid.hxx.

46 { return m_gridNodes.begin(); }
+ Here is the caller graph for this function:

◆ end()

template<class T >
auto MapGrid< T >::end ( )
inline

Definition at line 47 of file MapGrid.hxx.

47 { return m_gridNodes.end(); }
+ Here is the caller graph for this function:

◆ isMemberOf()

template<class T >
bool MapGrid< T >::isMemberOf ( Point  coordinate) const

If this coordinate is part of the grid.

Parameters
coordinatethe point to check
Returns
if the given coordinate is a member of this grid

Definition at line 22 of file MapGrid.inl.hxx.

23 {
24  return m_gridNodes.end() != std::find_if(m_gridNodes.begin(), m_gridNodes.end(),
25  [&coordinate](const T &node) { return node.coordinate == coordinate; });
26 }

◆ isNeighbor()

template<class T >
bool MapGrid< T >::isNeighbor ( Point  coordinate) const

If this coordinate is a neighbor of one of the node in the grid.

Parameters
coordinatethe point to check
Returns
if the given coordinate is a neighbor of this grid

Definition at line 16 of file MapGrid.inl.hxx.

17 {
18  return std::any_of(m_gridNodes.begin(), m_gridNodes.end(),
19  [coordinate](const T &node) { return node.coordinate.isDirectNeighborOf(coordinate); });
20 }

◆ removeNode()

template<class T >
void MapGrid< T >::removeNode ( Point  coordinate)
virtual

Remove a node on a given coordinate from this gridnode.

Parameters
coordinateof the node

Definition at line 9 of file MapGrid.inl.hxx.

10 {
11  m_gridNodes.erase(std::remove_if(m_gridNodes.begin(), m_gridNodes.end(),
12  [coordinate](const T &node) { return node.coordinate == coordinate; }),
13  m_gridNodes.end());
14 }

◆ size()

template<class T >
size_t MapGrid< T >::size ( )
inline

Definition at line 13 of file MapGrid.hxx.

13 { return m_gridNodes.size(); };

Member Data Documentation

◆ m_gridNodes

template<class T >
std::vector<T> MapGrid< T >::m_gridNodes
protected

Definition at line 50 of file MapGrid.hxx.


The documentation for this class was generated from the following files:
MapGrid::m_gridNodes
std::vector< T > m_gridNodes
Definition: MapGrid.hxx:50