A table of functions to define the behavior of a Space implemented in C.
More...
#include <hyperon.h>
A table of functions to define the behavior of a Space implemented in C.
- See also
- space_new
◆ add
Adds an atom to the space.
- Parameters
-
| [in] | params | A pointer to the space's params |
| [in] | atom | An atom_t representing the atom to add to the space |
- See also
- space_add
- Note
- This function must take ownership responsibility for the provided atom, and ultimately free it when the space is freed
◆ atom_count
| intptr_t(* space_api_t::atom_count) (const struct space_params_t *params) |
Returns the number of atoms contained within the space.
- Parameters
-
| [in] | params | A pointer to the space's params |
- Returns
- The number of top-level atoms contained within the Space
- See also
- space_atom_count
- Note
- If an atom_count function is provided, it will be called. NULL should be provided for spaces that cannot readily determine the number of contained atoms
◆ free_atom_iterator_state
| void(* space_api_t::free_atom_iterator_state) (const struct space_params_t *params, void *state) |
Frees the iterator state allocated by new_atom_iterator_state
- Parameters
-
- See also
- space_iterate
- Note
- This function is optional for Spaces that don't support iteration. However, if a new_atom_iterator_state implementation is provided then free_atom_iterator_state must also be provided
◆ free_payload
| void(* space_api_t::free_payload) (void *payload) |
Frees the payload buffer passed when the space was created.
- Parameters
-
| [in] | payload | The pointer to the space's payload |
- See also
- space_new
- Note
- This function is responsible for freeing the payload buffer, as well as any other objects and resources stored by the space. This includes freeing all atom_t objects and other buffers, as well as closing any connections and releasing any other resources held by the Space
◆ new_atom_iterator_state
| void *(* space_api_t::new_atom_iterator_state) (const struct space_params_t *params) |
Initializes state necessary to perform an iteration over all top-level atoms.
- Parameters
-
| [in] | params | A pointer to the space's params |
- Returns
- A pointer to an allocated "iterator state" object storing the necessary information to iterate each top-level atom contained within the space
- See also
- space_iterate
- Note
- If an new_atom_iterator_state function is provided, it will be called. NULL should be provided for spaces that cannot iterate all top-level atoms in an orderly way
◆ next_atom
Advances to the next top-level atom in the iteration sequence of the Space.
- Parameters
-
- Returns
- A reference to an atom owned by the space, or a null atom_ref_t to signal the iteration has finished
- See also
- space_iterate
- Note
- This function is optional for Spaces that don't support iteration. However, if a new_atom_iterator_state implementation is provided then next_atom must also be provided
◆ query
Performs a query against atoms in a space.
- Parameters
-
| [in] | params | A pointer to the space's params |
| [in] | atom | A pointer to the query atom |
- Returns
- A bindings_set_t representing the query results
- See also
- space_query
◆ remove
Removes an atom from the space.
- Parameters
-
| [in] | params | A pointer to the space's params |
| [in] | atom | A pointer to an atom_ref_t or atom_t to specify which atom to remove from the space |
- Returns
- true if the atom was removed, otherwise returns false
- See also
- space_remove
- Warning
- This function should NOT take ownership of the atom argument
◆ replace
Replaces one atom in the space with another.
- Parameters
-
| [in] | params | A pointer to the space's params |
| [in] | from | A pointer to an atom_ref_t or atom_t to specify the existing atom to replace in the space |
| [in] | to | An atom_t representing the atom to add to the space |
- Returns
- true if the atom was replaced, otherwise returns false
- See also
- space_replace
- Warning
- This function should NOT take ownership of the atom argument, but this function SHOULD take ownership of the to atom
◆ subst
Substitutes atoms matched by a query with atoms in a form derived from a template.
- Parameters
-
| [in] | params | A pointer to the space's params |
| [in] | pattern | A pointer to the the pattern atom to match |
| [in] | tmpl | A pointer to the the template atom from which to construct the substituted atoms |
- Returns
- An atom_vec_t containing all newly created atoms from the substitution
- See also
- space_subst
- Note
- If a subst function is provided, it will be called. If NULL is provided, the default implementation will be called.
The documentation for this struct was generated from the following file:
- hyperonc-install/include/hyperonc/hyperon/hyperon.h