execs v0.5.0 Execs

Execs provides the data abstraction layer for an Entity-Component System. It uses a Mnesia client by default, with disc_copy tables. There is currently no other client though the framework is in place for one should the need arise.

All clients must implement the Execs.DbClient.Client behavior.

Summary

Functions

Create a single entity and return the id

Create the specified number of entities and return their ids

Delete a set of entities and all their data

Delete a set of components and all their data from a set of entities

Delete a set of keys from a set of components which belong to a set of entities

List the entities which have a set of components

List the entities which have a set of keys

List the entities which have a set of keys. The value associated with the each key is passed to each of the comparison functions. If all functions return true then there is a match

List the entities which have at least one of a set of components

List the entities which have at least one of a set of keys

List the entities which have at least one of a set of keys. The value associated with the each key is passed to each of the comparison functions. If all functions return true then there is a match

Check to see if a set of entities has a set of components

Check to see if a set of entities has set of keys

Check to see if a set of entities has set of keys. The value associated with the each key is passed to each of the comparison functions. If all functions return true then there is a match

Check to see if a set of entities has at least one of a set of components

Check to see if a set of entities has at least one of a set of keys

Check to see if a set of entities has at least one of a set of keys. The value associated with the each key is passed to each of the comparison functions. If all functions return true then there is a match

Check to see which of a set of components a set of entities has

Check to see which of a set of keys a set of entities has

Check to see which of a set of keys a set of entities has. The value associated with the each key is passed to each of the comparison functions. If all functions return true then there is a match

List the components of a set of entities

List the keys belonging to a set of components of a set of entities

Read a set of entities

Read a set of components belonging to a set of entities

Read a set of keys belonging to a set of entities. Providing anything other than a single id, component, and key will return a map otherwise a single value is returned

All data manipulation functions expect to be performed in the context of a transaction. This ensures all systems can run concurrently while safely accessing data

Write a value to any combination of keys, components, and entities

Types

component()
component :: atom
component_list()
component_match()
component_match :: %{id: id, components: %{optional(component) => boolean}}
component_match_list()
entity()
entity :: %{id: id, components: %{optional(component) => kv_pairs}}
entity_list()
fun_list()
fun_list :: [(... -> any)]
id()
id
id_list()
id_list :: [id]
id_match()
id_match :: %{id: id, result: boolean}
id_match_list()
key()
key :: any
key_list()
key_list :: [key]
key_match()
key_match :: %{id: id, components: %{optional(component) => %{optional(key) => boolean}}}
key_match_list()
kv_pairs()
kv_pairs :: map
list_components()
list_components :: %{id: id, components: maybe_component_list}
list_components_list()
list_keys()
list_keys :: %{id: id, components: %{optional(component) => [key]}}
list_keys_list()
maybe_component_list()
maybe_entity_list()
maybe_fun_list()
maybe_fun_list :: (... -> any) | fun_list
maybe_id_list()
maybe_id_match_list()
maybe_key_list()
maybe_key_match_list()
maybe_list_keys_list()

Functions

create()
create :: id

Create a single entity and return the id.

create(n)
create(integer) :: id_list

Create the specified number of entities and return their ids.

delete(ids)

Delete a set of entities and all their data.

delete(ids, components)

Delete a set of components and all their data from a set of entities.

delete(ids, components, keys)

Delete a set of keys from a set of components which belong to a set of entities.

find_with_all(components)
find_with_all(maybe_component_list) :: id_list

List the entities which have a set of components.

find_with_all(components, keys)

List the entities which have a set of keys.

find_with_all(components, keys, functions)

List the entities which have a set of keys. The value associated with the each key is passed to each of the comparison functions. If all functions return true then there is a match.

find_with_any(components)
find_with_any(maybe_component_list) :: id_list

List the entities which have at least one of a set of components.

find_with_any(components, keys)

List the entities which have at least one of a set of keys.

find_with_any(components, keys, functions)

List the entities which have at least one of a set of keys. The value associated with the each key is passed to each of the comparison functions. If all functions return true then there is a match.

has_all(ids, components)

Check to see if a set of entities has a set of components.

has_all(ids, components, keys)

Check to see if a set of entities has set of keys.

has_all(ids, components, keys, functions)

Check to see if a set of entities has set of keys. The value associated with the each key is passed to each of the comparison functions. If all functions return true then there is a match.

has_any(ids, components)

Check to see if a set of entities has at least one of a set of components.

has_any(ids, components, keys)

Check to see if a set of entities has at least one of a set of keys.

has_any(ids, components, keys, functions)

Check to see if a set of entities has at least one of a set of keys. The value associated with the each key is passed to each of the comparison functions. If all functions return true then there is a match.

has_which(ids, components)

Check to see which of a set of components a set of entities has.

has_which(ids, components, keys)

Check to see which of a set of keys a set of entities has.

has_which(ids, components, keys, functions)

Check to see which of a set of keys a set of entities has. The value associated with the each key is passed to each of the comparison functions. If all functions return true then there is a match.

List the components of a set of entities.

List the keys belonging to a set of components of a set of entities.

read(ids)

Read a set of entities.

read(ids, components)

Read a set of components belonging to a set of entities.

read(ids, components, keys)

Read a set of keys belonging to a set of entities. Providing anything other than a single id, component, and key will return a map otherwise a single value is returned.

transaction(block)
transaction((... -> any)) :: any

All data manipulation functions expect to be performed in the context of a transaction. This ensures all systems can run concurrently while safely accessing data.

write(ids, components, keys, value)

Write a value to any combination of keys, components, and entities.