aether::entity_based_user_state< Traits > Class Template Referenceabstract

The class defines an interface that should be implemented in order to build an entity based simulation. More...

#include <user_state.hh>

Public Types

using traits_type = Traits
 
using octree_traits = typename traits_type::octree_traits
 
using store_type = typename traits_type::store_type
 
using agent_reference = typename store_type::agent_reference
 
using vector_type = typename aether::dimension_traits< octree_traits::morton_type::dimension >::vector_type
 
using morton_type = typename octree_traits::morton_type
 
using aether_state_type = aether::cell_state< octree_traits >
 
using aabb_type = morton::AABB< morton_type >
 
using key_type = uint64_t
 
using data_type = std::vector< char >
 
using subscriber_topic_type = aether::message::subscriber_topic_type
 
using message_reader_type = typename detail::find_messaging_type< octree_traits >::message_reader_type
 
using message_writer_type = typename detail::find_messaging_type< octree_traits >::message_writer_type
 
using client_writer_type = typename detail::find_messaging_type< octree_traits >::client_writer_type
 

Public Member Functions

virtual store_typeget_store ()=0
 This returns the entity storage mechanism. More...
 
virtual void initialise_cell (const aether::cell_state< typename Traits::octree_traits > &aether_state)=0
 This is called once on creation of the cell. More...
 
virtual void initialise_world (const aether::cell_state< typename Traits::octree_traits > &aether_state)=0
 This is called to initialise the simulation world. More...
 
virtual void deinitialise_cell (const aether::cell_state< typename Traits::octree_traits > &aether_state)=0
 This is called by the worker to send messages to the muxer. More...
 
virtual void cell_tick (const aether::cell_state< octree_traits > &aether_state, float delta_time)=0
 This is the basic worker tick function. More...
 
virtual void serialize_to_client (const aether::cell_state< octree_traits > &aether_state, client_writer_type &writer)=0
 This is called by the worker to send messages to the muxer. More...
 
virtual void receive_messages (const aether::cell_state< octree_traits > &aether_state, message_reader_type &reader)=0
 This is called every tick to handle events received from the muxer or dispatchers. More...
 
virtual std::vector< subscriber_topic_typeget_topics (const aether_state_type &aether_state)=0
 Override to subscribe for a custom list of message topics. More...
 
virtual morton_type agent_center (const aether_state_type &aether_state, agent_reference agent)=0
 This returns the centre of the agent. More...
 
virtual void send_messages (const aether_state_type &aether_state, message_writer_type &writer)=0
 This function is used to send messages to dispatcher. More...
 
virtual aabb_type agent_aabb (const aether_state_type &aether_state, agent_reference agent)=0
 This produces the Morton AABB for each agent. More...
 
virtual bool is_passive_agent (const aether_state_type &aether_state, agent_reference agent)=0
 This decides if an entity is not allowed to spawn new cells. More...
 
virtual std::vector< key_typeget_global_kv_store_queries (const aether::cell_state< octree_traits > &aether_state)=0
 returns a list of keys to querie the value one time More...
 
virtual void global_kv_store_responses (const aether::cell_state< octree_traits > &aether_state, const std::unordered_map< key_type, data_type > &responses)=0
 processess the responses from the global store More...
 
virtual std::unordered_map< key_type, data_typepublish_global_kv_store_data (const aether::cell_state< octree_traits > &aether_state)=0
 publishes data to the store to make it avaliable to other workers More...
 
virtual float estimate_load (const aether_state_type &aether_state)=0
 The value produced by this is used by the manager to decide if a cell should split or merge. More...
 
virtual bool is_idle ()=0
 
virtual std::unique_ptr< external_storage_ifacebuild_external_storage (const aether::cell_state< octree_traits > &aether_state)=0
 Override in order to implement external storage for the cell process. More...
 
virtual ~entity_based_user_state ()
 

Static Public Attributes

static constexpr size_t dimension = morton_type::dimension
 

Detailed Description

template<typename Traits>
class aether::entity_based_user_state< Traits >

The class defines an interface that should be implemented in order to build an entity based simulation.

Member Typedef Documentation

template<typename Traits >
using aether::entity_based_user_state< Traits >::aabb_type = morton::AABB<morton_type>
template<typename Traits >
using aether::entity_based_user_state< Traits >::agent_reference = typename store_type::agent_reference
template<typename Traits >
using aether::entity_based_user_state< Traits >::client_writer_type = typename detail::find_messaging_type<octree_traits>::client_writer_type
template<typename Traits >
using aether::entity_based_user_state< Traits >::data_type = std::vector<char>
template<typename Traits >
using aether::entity_based_user_state< Traits >::key_type = uint64_t
template<typename Traits >
using aether::entity_based_user_state< Traits >::message_reader_type = typename detail::find_messaging_type<octree_traits>::message_reader_type
template<typename Traits >
using aether::entity_based_user_state< Traits >::message_writer_type = typename detail::find_messaging_type<octree_traits>::message_writer_type
template<typename Traits >
using aether::entity_based_user_state< Traits >::morton_type = typename octree_traits::morton_type
template<typename Traits >
using aether::entity_based_user_state< Traits >::octree_traits = typename traits_type::octree_traits
template<typename Traits >
using aether::entity_based_user_state< Traits >::store_type = typename traits_type::store_type
template<typename Traits >
using aether::entity_based_user_state< Traits >::traits_type = Traits
template<typename Traits >
using aether::entity_based_user_state< Traits >::vector_type = typename aether::dimension_traits<octree_traits::morton_type::dimension>::vector_type

Constructor & Destructor Documentation

template<typename Traits >
virtual aether::entity_based_user_state< Traits >::~entity_based_user_state ( )
inlinevirtual

Member Function Documentation

template<typename Traits >
virtual aabb_type aether::entity_based_user_state< Traits >::agent_aabb ( const aether_state_type aether_state,
agent_reference  agent 
)
pure virtual

This produces the Morton AABB for each agent.

The AABB produced by this is used to decide when an agent is visible in neighbouring cells.

Implemented in aether::entity_based_user_state_base< Traits >.

template<typename Traits >
virtual morton_type aether::entity_based_user_state< Traits >::agent_center ( const aether_state_type aether_state,
agent_reference  agent 
)
pure virtual

This returns the centre of the agent.

The centre is used to decide when an agent is handed over to the neighbouring cell.

Implemented in aether::entity_based_user_state_base< Traits >.

template<typename Traits >
virtual std::unique_ptr<external_storage_iface> aether::entity_based_user_state< Traits >::build_external_storage ( const aether::cell_state< octree_traits > &  aether_state)
pure virtual

Override in order to implement external storage for the cell process.

See aether::external_storage_base.

Implemented in aether::entity_based_user_state_base< Traits >.

template<typename Traits >
virtual void aether::entity_based_user_state< Traits >::cell_tick ( const aether::cell_state< octree_traits > &  aether_state,
float  delta_time 
)
pure virtual

This is the basic worker tick function.

Write your main simulation code here.

template<typename Traits >
virtual void aether::entity_based_user_state< Traits >::deinitialise_cell ( const aether::cell_state< typename Traits::octree_traits > &  aether_state)
pure virtual

This is called by the worker to send messages to the muxer.

This is used to send information to the clients.

Implemented in aether::entity_based_user_state_base< Traits >.

template<typename Traits >
virtual float aether::entity_based_user_state< Traits >::estimate_load ( const aether_state_type aether_state)
pure virtual

The value produced by this is used by the manager to decide if a cell should split or merge.

By default Aether will try to split the cell if load is larger than 1.0, and merge if it's below 0.2.

Implemented in aether::entity_based_user_state_base< Traits >.

template<typename Traits >
virtual std::vector<key_type> aether::entity_based_user_state< Traits >::get_global_kv_store_queries ( const aether::cell_state< octree_traits > &  aether_state)
pure virtual

returns a list of keys to querie the value one time

Implemented in aether::entity_based_user_state_base< Traits >.

template<typename Traits >
virtual store_type& aether::entity_based_user_state< Traits >::get_store ( )
pure virtual

This returns the entity storage mechanism.

The entity store is directly accessed in order to perform operations such as handing over and/or receiving entities from other Aether workers.

template<typename Traits >
virtual std::vector<subscriber_topic_type> aether::entity_based_user_state< Traits >::get_topics ( const aether_state_type aether_state)
pure virtual

Override to subscribe for a custom list of message topics.

Called every tick.

Implemented in aether::entity_based_user_state_base< Traits >.

template<typename Traits >
virtual void aether::entity_based_user_state< Traits >::global_kv_store_responses ( const aether::cell_state< octree_traits > &  aether_state,
const std::unordered_map< key_type, data_type > &  responses 
)
pure virtual

processess the responses from the global store

Implemented in aether::entity_based_user_state_base< Traits >.

template<typename Traits >
virtual void aether::entity_based_user_state< Traits >::initialise_cell ( const aether::cell_state< typename Traits::octree_traits > &  aether_state)
pure virtual

This is called once on creation of the cell.

It is not called when a cell changes size.

Implemented in aether::entity_based_user_state_base< Traits >.

template<typename Traits >
virtual void aether::entity_based_user_state< Traits >::initialise_world ( const aether::cell_state< typename Traits::octree_traits > &  aether_state)
pure virtual

This is called to initialise the simulation world.

It's run only on first worker (and after its cell is initialised).

Example usage: creating the world volume or the initial agents.

Implemented in aether::entity_based_user_state_base< Traits >.

template<typename Traits >
virtual bool aether::entity_based_user_state< Traits >::is_idle ( )
pure virtual
Returns
true when the cell can to be deinitialized.

By default the cells are deinitialized when they don't own any agents and there are no ghost agents nearby which could be moved into the cell

Implemented in aether::entity_based_user_state_base< Traits >.

template<typename Traits >
virtual bool aether::entity_based_user_state< Traits >::is_passive_agent ( const aether_state_type aether_state,
agent_reference  agent 
)
pure virtual

This decides if an entity is not allowed to spawn new cells.

It may not be desirable for all entities to be able to spawn new cells, especially in procedural generation.

Implemented in aether::entity_based_user_state_base< Traits >.

template<typename Traits >
virtual std::unordered_map<key_type, data_type> aether::entity_based_user_state< Traits >::publish_global_kv_store_data ( const aether::cell_state< octree_traits > &  aether_state)
pure virtual

publishes data to the store to make it avaliable to other workers

Implemented in aether::entity_based_user_state_base< Traits >.

template<typename Traits >
virtual void aether::entity_based_user_state< Traits >::receive_messages ( const aether::cell_state< octree_traits > &  aether_state,
message_reader_type reader 
)
pure virtual

This is called every tick to handle events received from the muxer or dispatchers.

It's up to the user code to distinguish between the two. The reader enables the user code to read multiple messages.

Implemented in aether::entity_based_user_state_base< Traits >.

template<typename Traits >
virtual void aether::entity_based_user_state< Traits >::send_messages ( const aether_state_type aether_state,
message_writer_type writer 
)
pure virtual

This function is used to send messages to dispatcher.

It might be used for example to communicate with Global State.

Implemented in aether::entity_based_user_state_base< Traits >.

template<typename Traits >
virtual void aether::entity_based_user_state< Traits >::serialize_to_client ( const aether::cell_state< octree_traits > &  aether_state,
client_writer_type writer 
)
pure virtual

This is called by the worker to send messages to the muxer.

This is used to send information to the clients.

Member Data Documentation

template<typename Traits >
constexpr size_t aether::entity_based_user_state< Traits >::dimension = morton_type::dimension
static