aether::entity_based_user_state_base< Traits > Class Template Referenceabstract

The class makes it simpler to create a simulation by providing default implementations for many functions required by the entity_based_user_state interface. 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 = 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

void initialise_cell (const aether::cell_state< typename Traits::octree_traits > &aether_state) override
 This is called once on creation of the cell. More...
 
void initialise_world (const aether::cell_state< typename Traits::octree_traits > &aether_state) override
 This is called to initialise the simulation world. More...
 
void deinitialise_cell (const aether::cell_state< typename Traits::octree_traits > &aether_state) override
 This is called by the worker to send messages to the muxer. More...
 
void receive_messages (const aether::cell_state< octree_traits > &aether_state, message_reader_type &reader) override
 This is called every tick to handle events received from the muxer or dispatchers. More...
 
std::vector< subscriber_topic_typeget_topics (const aether_state_type &aether_state) override
 Override to subscribe for a custom list of message topics. More...
 
morton_type agent_center (const aether_state_type &aether_state, agent_reference agent) override
 This returns the centre of the agent. More...
 
void send_messages (const aether_state_type &aether_state, message_writer_type &writer) override
 This function is used to send messages to dispatcher. More...
 
aabb_type agent_aabb (const aether_state_type &aether_state, agent_reference agent) override
 This produces the Morton AABB for each agent. More...
 
bool is_passive_agent (const aether_state_type &aether_state, agent_reference agent) override
 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) override
 override this function to provide a list of keys to be queried More...
 
virtual void global_kv_store_responses (const aether::cell_state< octree_traits > &aether_state, const std::unordered_map< key_type, data_type > &responses) override
 override this function to process the data received from the global_kv_store More...
 
virtual std::unordered_map< key_type, data_typepublish_global_kv_store_data (const aether::cell_state< octree_traits > &aether_state) override
 override this function to update data to the global_kv_store so it is accessible by other workers More...
 
float estimate_load (const aether_state_type &aether_state) override
 The value produced by this is used by the manager to decide if a cell should split or merge. More...
 
std::unique_ptr< external_storage_ifacebuild_external_storage (const aether::cell_state< octree_traits > &aether_state) override
 Override in order to implement external storage for the cell process. More...
 
bool is_idle () override
 
virtual store_typeget_store ()=0
 This returns the entity storage mechanism. 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...
 

Static Public Attributes

static constexpr size_t dimension = morton_type::dimension
 

Detailed Description

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

The class makes it simpler to create a simulation by providing default implementations for many functions required by the entity_based_user_state interface.

See the documentation of the interface for the purpose of these functions.

Member Typedef Documentation

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

Member Function Documentation

template<typename Traits >
aabb_type aether::entity_based_user_state_base< Traits >::agent_aabb ( const aether_state_type aether_state,
agent_reference  agent 
)
inlineoverridevirtual

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.

Implements aether::entity_based_user_state< Traits >.

template<typename Traits >
morton_type aether::entity_based_user_state_base< Traits >::agent_center ( const aether_state_type aether_state,
agent_reference  agent 
)
inlineoverridevirtual

This returns the centre of the agent.

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

Implements aether::entity_based_user_state< Traits >.

template<typename Traits >
std::unique_ptr<external_storage_iface> aether::entity_based_user_state_base< Traits >::build_external_storage ( const aether::cell_state< octree_traits > &  aether_state)
inlineoverridevirtual

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

See aether::external_storage_base.

Implements aether::entity_based_user_state< 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 virtualinherited

This is the basic worker tick function.

Write your main simulation code here.

template<typename Traits >
void aether::entity_based_user_state_base< Traits >::deinitialise_cell ( const aether::cell_state< typename Traits::octree_traits > &  aether_state)
inlineoverridevirtual

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

This is used to send information to the clients.

Implements aether::entity_based_user_state< Traits >.

template<typename Traits >
float aether::entity_based_user_state_base< Traits >::estimate_load ( const aether_state_type aether_state)
inlineoverridevirtual

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.

Implements aether::entity_based_user_state< Traits >.

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

override this function to provide a list of keys to be queried

Implements aether::entity_based_user_state< Traits >.

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

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 >
std::vector<subscriber_topic_type> aether::entity_based_user_state_base< Traits >::get_topics ( const aether_state_type aether_state)
inlineoverridevirtual

Override to subscribe for a custom list of message topics.

Called every tick.

Implements aether::entity_based_user_state< Traits >.

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

override this function to process the data received from the global_kv_store

Implements aether::entity_based_user_state< Traits >.

template<typename Traits >
void aether::entity_based_user_state_base< Traits >::initialise_cell ( const aether::cell_state< typename Traits::octree_traits > &  aether_state)
inlineoverridevirtual

This is called once on creation of the cell.

It is not called when a cell changes size.

Implements aether::entity_based_user_state< Traits >.

template<typename Traits >
void aether::entity_based_user_state_base< Traits >::initialise_world ( const aether::cell_state< typename Traits::octree_traits > &  aether_state)
inlineoverridevirtual

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.

Implements aether::entity_based_user_state< Traits >.

template<typename Traits >
bool aether::entity_based_user_state_base< Traits >::is_idle ( )
inlineoverridevirtual
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

Implements aether::entity_based_user_state< Traits >.

template<typename Traits >
bool aether::entity_based_user_state_base< Traits >::is_passive_agent ( const aether_state_type aether_state,
agent_reference  agent 
)
inlineoverridevirtual

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.

Implements aether::entity_based_user_state< Traits >.

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

override this function to update data to the global_kv_store so it is accessible by other workers

Implements aether::entity_based_user_state< Traits >.

template<typename Traits >
void aether::entity_based_user_state_base< Traits >::receive_messages ( const aether::cell_state< octree_traits > &  aether_state,
message_reader_type reader 
)
inlineoverridevirtual

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.

Implements aether::entity_based_user_state< Traits >.

template<typename Traits >
void aether::entity_based_user_state_base< Traits >::send_messages ( const aether_state_type aether_state,
message_writer_type writer 
)
inlineoverridevirtual

This function is used to send messages to dispatcher.

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

Implements aether::entity_based_user_state< 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 virtualinherited

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_base< Traits >::dimension = morton_type::dimension
static