entity
Entity/Component System for C++
entity::component::saturated_pool< T > Class Template Reference

Description

template<typename T>
class entity::component::saturated_pool< T >

Definition at line 50 of file saturated_pool.hpp.

Instances and minimal complete definitions

struct  entity_iterator
 
struct  window
 

Friends

class creation_queue< saturated_pool< T > >
 
class destruction_queue< saturated_pool< T > >
 

Public Types

typedef iterator_impl iterator
 
typedef T type
 

Public Member Functions

template<typename... Args>
void auto_create_components (entity_pool &owner_pool, Args...constructor_args)
 
iterator begin ()
 
template<typename... Args>
T * create (entity e, Args &&...args)
 
void destroy (entity e)
 
iterator end ()
 
T * get (entity e)
 
T const * get (entity e) const
 
 saturated_pool (entity_pool &owner_pool, T const &default_value=T())
 
std::size_t size ()
 
window view ()
 

Methods

template<typename T >
friend class creation_queue< saturated_pool< T > >
friend

Definition at line 323 of file saturated_pool.hpp.

template<typename T >
friend class destruction_queue< saturated_pool< T > >
friend

Definition at line 324 of file saturated_pool.hpp.

Member Function Documentation

template<typename T >
template<typename... Args>
void entity::component::saturated_pool< T >::auto_create_components ( entity_pool owner_pool,
Args...  constructor_args 
)

Definition at line 238 of file saturated_pool.hpp.

References entity::entity_pool::signal_list::on_entity_create, and entity::entity_pool::signals().

239  {
240  slots_.entity_create_handler =
241  owner_pool.signals().on_entity_create.connect(
242  std::function<void(entity)>(
243  [this, constructor_args...](entity e)
244  {
245  create(e, constructor_args...);
246  }
247  )
248  )
249  ;
250  }
template<typename T >
iterator entity::component::saturated_pool< T >::begin ( )

Definition at line 297 of file saturated_pool.hpp.

298  {
299  return iterator(this, 0);
300  }
template<typename T >
template<typename... Args>
T* entity::component::saturated_pool< T >::create ( entity  e,
Args &&...  args 
)

Definition at line 269 of file saturated_pool.hpp.

270  {
271  components_.emplace(components_.begin() + e.index(), std::forward<Args>(args)...);
272  return &components_[e.index()];
273  }
template<typename T >
void entity::component::saturated_pool< T >::destroy ( entity  e)

Definition at line 282 of file saturated_pool.hpp.

283  {
284  components_.erase(components_.begin() + e.index());
285  }
template<typename T >
iterator entity::component::saturated_pool< T >::end ( )

Definition at line 302 of file saturated_pool.hpp.

303  {
304  return iterator(this, components_.size());
305  }
template<typename T >
T* entity::component::saturated_pool< T >::get ( entity  e)

Definition at line 287 of file saturated_pool.hpp.

288  {
289  return get_component(e);
290  }
template<typename T >
T const* entity::component::saturated_pool< T >::get ( entity  e) const

Definition at line 292 of file saturated_pool.hpp.

293  {
294  return get_component(e);
295  }
template<typename T >
std::size_t entity::component::saturated_pool< T >::size ( )

Definition at line 312 of file saturated_pool.hpp.

313  {
314  return components_.size();
315  }
template<typename T >
window entity::component::saturated_pool< T >::view ( )

Definition at line 307 of file saturated_pool.hpp.

308  {
309  return window(this);
310  }

Member Typedef Documentation

template<typename T >
typedef iterator_impl entity::component::saturated_pool< T >::iterator

Definition at line 105 of file saturated_pool.hpp.

template<typename T >
typedef T entity::component::saturated_pool< T >::type

Definition at line 104 of file saturated_pool.hpp.

Constructor & Destructor Documentation

template<typename T >
entity::component::saturated_pool< T >::saturated_pool ( entity_pool owner_pool,
T const &  default_value = T() 
)

Definition at line 210 of file saturated_pool.hpp.

References entity::entity_pool::signal_list::on_entity_destroy, entity::entity_pool::signal_list::on_entity_swap, entity::entity_pool::signals(), and entity::entity_pool::size().

211  {
212  components_.resize(owner_pool.size(), default_value);
213 
214  slots_.entity_destroy_handler =
215  owner_pool.signals().on_entity_destroy.connect(
216  boost::bind(
217  &saturated_pool::handle_destroy_entity,
218  this,
219  ::_1
220  )
221  )
222  ;
223 
224  slots_.entity_swap_handler =
225  owner_pool.signals().on_entity_swap.connect(
226  boost::bind(
227  &saturated_pool::handle_swap_entity,
228  this,
229  ::_1,
230  ::_2
231  )
232  )
233  ;
234  }