Bomberman
Public Types | Public Member Functions | Private Types | Private Attributes | List of all members
WAL::View< Components > Class Template Reference

A view allowing one to easily access entities containing a set list of component. A view is always updated and only references to entities are kept. More...

#include <View.hpp>

Inheritance diagram for WAL::View< Components >:
Collaboration diagram for WAL::View< Components >:

Public Types

using iterator = ViewIterator< typename std::vector< entity_type >::iterator, Components... >
 

Public Member Functions

iterator begin ()
 
iterator end ()
 
std::size_t size () const
 
ViewEntity< Components... > front ()
 
ViewEntity< Components... > back ()
 
const std::vector< std::type_index > & getTypes () const override
 The list of types that every entity of the view has. More...
 
void emplace_back (Entity &entity) override
 
void erase (const Entity &entity) override
 
 View (std::list< Entity > &scene)
 Construct a view from a list of entities. Those entities are never copied but references to them are kept internally. More...
 
 View (const View &)=delete
 Copying a view is not possible since a view must be managed by a scene. More...
 
 ~View () override=default
 A default destructor. More...
 
Viewoperator= (const View &)=delete
 A view is not assignable. More...
 
- Public Member Functions inherited from WAL::IView
virtual ~IView ()=default
 A default destructor. More...
 

Private Types

using entity_type = std::tuple< std::reference_wrapper< Entity >, std::reference_wrapper< Components >... >
 

Private Attributes

std::vector< entity_type_entities = {}
 The list of entities in the view. More...
 
std::vector< std::type_index > _types = {}
 The list of types that every entity of the view has. More...
 

Detailed Description

template<typename ... Components>
class WAL::View< Components >

A view allowing one to easily access entities containing a set list of component. A view is always updated and only references to entities are kept.

Member Typedef Documentation

◆ entity_type

template<typename ... Components>
using WAL::View< Components >::entity_type = std::tuple<std::reference_wrapper<Entity>, std::reference_wrapper<Components>...>
private

◆ iterator

template<typename ... Components>
using WAL::View< Components >::iterator = ViewIterator<typename std::vector<entity_type>::iterator, Components...>

Constructor & Destructor Documentation

◆ View() [1/2]

template<typename ... Components>
WAL::View< Components >::View ( std::list< Entity > &  scene)
inlineexplicit

Construct a view from a list of entities. Those entities are never copied but references to them are kept internally.

◆ View() [2/2]

template<typename ... Components>
WAL::View< Components >::View ( const View< Components > &  )
delete

Copying a view is not possible since a view must be managed by a scene.

◆ ~View()

template<typename ... Components>
WAL::View< Components >::~View ( )
overridedefault

A default destructor.

Member Function Documentation

◆ back()

template<typename ... Components>
ViewEntity<Components...> WAL::View< Components >::back ( )
inline

◆ begin()

template<typename ... Components>
iterator WAL::View< Components >::begin ( )
inline

◆ emplace_back()

template<typename ... Components>
void WAL::View< Components >::emplace_back ( Entity entity)
inlineoverridevirtual

Implements WAL::IView.

◆ end()

template<typename ... Components>
iterator WAL::View< Components >::end ( )
inline

◆ erase()

template<typename ... Components>
void WAL::View< Components >::erase ( const Entity entity)
inlineoverridevirtual

Implements WAL::IView.

◆ front()

template<typename ... Components>
ViewEntity<Components...> WAL::View< Components >::front ( )
inline

◆ getTypes()

template<typename ... Components>
const std::vector<std::type_index>& WAL::View< Components >::getTypes ( ) const
inlineoverridevirtual

The list of types that every entity of the view has.

Implements WAL::IView.

◆ operator=()

template<typename ... Components>
View& WAL::View< Components >::operator= ( const View< Components > &  )
delete

A view is not assignable.

◆ size()

template<typename ... Components>
std::size_t WAL::View< Components >::size ( ) const
inline

Member Data Documentation

◆ _entities

template<typename ... Components>
std::vector<entity_type> WAL::View< Components >::_entities = {}
private

The list of entities in the view.

◆ _types

template<typename ... Components>
std::vector<std::type_index> WAL::View< Components >::_types = {}
private

The list of types that every entity of the view has.


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