|
Clingo
|
The ground event handler interface. More...
#include <ground.h>
Public Attributes | |
| bool(* | callable )(char const *name, size_t name_size, size_t arguments_size, void *data, bool *result) |
| Check if the function with the given name and number of arguments is callable. | |
| bool(* | call )(clingo_lib_t *lib, clingo_location_t const *location, char const *name, size_t name_size, clingo_symbol_t const *arguments, size_t arguments_size, void *data, clingo_symbol_callback_t symbol_callback, void *symbol_callback_data) |
| Callback function to implement external functions. | |
| void(* | finish )(clingo_ground_result_t result, void *data) |
| Callback to notify that the grounding has finished. | |
| void(* | free )(void *data) |
| Callback to free the userdata of the handler. | |
The ground event handler interface.
| bool(* clingo_ground_event_handler::call) (clingo_lib_t *lib, clingo_location_t const *location, char const *name, size_t name_size, clingo_symbol_t const *arguments, size_t arguments_size, void *data, clingo_symbol_callback_t symbol_callback, void *symbol_callback_data) |
Callback function to implement external functions.
If an external function of form @name(parameters) occurs in a logic program, then this function is called with its location, name, parameters, and a callback to inject symbols as arguments. The callback can be called multiple times; all symbols passed are injected.
If a (non-recoverable) clingo API function fails in this callback, for example, the symbol callback, the callback must return its return code. In case of errors not related to clingo, this function can use clingo_set_error().
| [in] | lib | the library object |
| [in] | location | location from which the external function was called |
| [in] | name | name of the called external function |
| [in] | arguments | arguments of the called external function |
| [in] | arguments_size | number of arguments |
| [in] | data | user data of the callback |
| [in] | symbol_callback | function to inject symbols |
| [in] | symbol_callback_data | user data for the symbol callback (must be passed untouched) |
The following example implements the external function @f() returning 42.
| bool(* clingo_ground_event_handler::callable) (char const *name, size_t name_size, size_t arguments_size, void *data, bool *result) |
Check if the function with the given name and number of arguments is callable.
| [in] | name | name of the called external function |
| [in] | name_size | size of the name |
| [in] | arguments_size | number of arguments |
| [in] | data | user data of the callback |
| [out] | result | whether the function is callable |
| void(* clingo_ground_event_handler::finish) (clingo_ground_result_t result, void *data) |
Callback to notify that the grounding has finished.
This can be used for thread synchronization as the function is not called in the main thread when grounding asynchronously.
| result | the ground result |
| data | the user data |
Callback to free the userdata of the handler.
| data | the user data |