Clingo
Loading...
Searching...
No Matches
control.h
1#ifndef CLINGO_CONTROL_H
2#define CLINGO_CONTROL_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <clingo/core.h>
9#include <clingo/symbol.h>
10
11typedef struct clingo_program clingo_program_t;
12
26
32
34typedef struct clingo_control clingo_control_t;
35
44typedef int clingo_mode_t;
45
57typedef struct clingo_part {
58 char const *name;
59 size_t name_size;
61 size_t params_size;
63
105typedef bool (*clingo_ground_callback_t)(clingo_lib_t *lib, clingo_location_t const *location, char const *name,
106 size_t name_size, clingo_symbol_t const *arguments, size_t arguments_size,
107 void *data, clingo_symbol_callback_t symbol_callback,
108 void *symbol_callback_data);
109
111typedef struct clingo_const_map clingo_const_map_t;
112
121CLINGO_VISIBILITY_DEFAULT bool clingo_const_map_find(clingo_const_map_t const *map, char const *name, size_t name_size,
122 clingo_symbol_t *symbol, bool *found);
123
131CLINGO_VISIBILITY_DEFAULT bool clingo_const_map_at(clingo_const_map_t const *map, size_t index, clingo_string_t *name,
132 clingo_symbol_t *symbol);
133
139CLINGO_VISIBILITY_DEFAULT bool clingo_const_map_size(clingo_const_map_t const *map, size_t *size);
140
155CLINGO_VISIBILITY_DEFAULT bool clingo_control_new(clingo_lib_t *lib, clingo_string_t const *arguments, size_t size,
156 clingo_control_t **control);
157
161CLINGO_VISIBILITY_DEFAULT void clingo_control_acquire(clingo_control_t *control);
162
166CLINGO_VISIBILITY_DEFAULT void clingo_control_release(clingo_control_t *control);
167
173CLINGO_VISIBILITY_DEFAULT bool clingo_control_mode(clingo_control_t *control, clingo_mode_t *mode);
174
181CLINGO_VISIBILITY_DEFAULT bool clingo_control_parse_files(clingo_control_t *control, clingo_string_t const *files,
182 size_t size);
183
193CLINGO_VISIBILITY_DEFAULT bool clingo_control_parse_string(clingo_control_t *control, char const *program, size_t size);
194
209CLINGO_VISIBILITY_DEFAULT bool clingo_control_ground(clingo_control_t *control, clingo_part_t const *parts, size_t size,
210 clingo_ground_callback_t ground_callback, void *data);
211
216CLINGO_VISIBILITY_DEFAULT bool clingo_control_main(clingo_control_t *control);
217
223CLINGO_VISIBILITY_DEFAULT bool clingo_control_const_map(clingo_control_t *control, clingo_const_map_t const **map);
224
232CLINGO_VISIBILITY_DEFAULT bool clingo_control_buffer(clingo_control_t *control, clingo_string_t *result);
233
241CLINGO_VISIBILITY_DEFAULT bool clingo_control_get_parts(clingo_control_t *control, clingo_part_t const **parts,
242 size_t *size, bool *has_value);
243
251CLINGO_VISIBILITY_DEFAULT bool clingo_control_set_parts(clingo_control_t *control, clingo_part_t const *parts,
252 size_t size, bool has_value);
253
256 minimize = 1,
257 project = 2,
258};
260typedef unsigned clingo_discard_type_t;
261
266CLINGO_VISIBILITY_DEFAULT bool clingo_control_discard(clingo_control_t *control, clingo_discard_type_t type);
267
274CLINGO_VISIBILITY_DEFAULT void clingo_control_interrupt(clingo_control_t *control);
275
277
278#ifdef __cplusplus
279}
280#endif
281
282#endif
struct clingo_program clingo_program_t
Object to store.
Definition ast.h:499
unsigned clingo_discard_type_t
Corresponding type to clingo_discard_type_e.
Definition control.h:260
CLINGO_VISIBILITY_DEFAULT bool clingo_const_map_find(clingo_const_map_t const *map, char const *name, size_t name_size, clingo_symbol_t *symbol, bool *found)
Get the constant with the given name.
int clingo_mode_t
The corresponding type to clingo_mode_e.
Definition control.h:44
CLINGO_VISIBILITY_DEFAULT bool clingo_control_parse_string(clingo_control_t *control, char const *program, size_t size)
Extend the logic program with the given non-ground logic program in string form.
CLINGO_VISIBILITY_DEFAULT bool clingo_control_get_parts(clingo_control_t *control, clingo_part_t const **parts, size_t *size, bool *has_value)
Get the program parts to ground.
CLINGO_VISIBILITY_DEFAULT bool clingo_control_discard(clingo_control_t *control, clingo_discard_type_t type)
Discard the statements of the given types.
struct clingo_part clingo_part_t
Struct used to specify the program parts that have to be grounded.
CLINGO_VISIBILITY_DEFAULT bool clingo_const_map_at(clingo_const_map_t const *map, size_t index, clingo_string_t *name, clingo_symbol_t *symbol)
Get the name and value of the contstant at the given index.
struct clingo_const_map clingo_const_map_t
A map from constantns to their values.
Definition control.h:111
CLINGO_VISIBILITY_DEFAULT void clingo_control_acquire(clingo_control_t *control)
Increment the reference count of the given control object.
bool(* clingo_ground_callback_t)(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.
Definition control.h:105
CLINGO_VISIBILITY_DEFAULT bool clingo_control_parse_files(clingo_control_t *control, clingo_string_t const *files, size_t size)
Extend the logic program with a program in a file.
CLINGO_VISIBILITY_DEFAULT bool clingo_control_const_map(clingo_control_t *control, clingo_const_map_t const **map)
Get the map of constants.
CLINGO_VISIBILITY_DEFAULT void clingo_control_interrupt(clingo_control_t *control)
Interrupt the running search.
clingo_discard_type_e
Enumeration of discardable statements.
Definition control.h:255
CLINGO_VISIBILITY_DEFAULT bool clingo_control_ground(clingo_control_t *control, clingo_part_t const *parts, size_t size, clingo_ground_callback_t ground_callback, void *data)
Ground the selected parts of the current (non-ground) logic program.
CLINGO_VISIBILITY_DEFAULT bool clingo_control_main(clingo_control_t *control)
Execute the default ground and solve flow after parsing.
CLINGO_VISIBILITY_DEFAULT bool clingo_control_mode(clingo_control_t *control, clingo_mode_t *mode)
Get the configured mode.
CLINGO_VISIBILITY_DEFAULT bool clingo_control_new(clingo_lib_t *lib, clingo_string_t const *arguments, size_t size, clingo_control_t **control)
Create a new control object.
CLINGO_VISIBILITY_DEFAULT bool clingo_control_buffer(clingo_control_t *control, clingo_string_t *result)
Get the output of the text output.
CLINGO_VISIBILITY_DEFAULT bool clingo_control_set_parts(clingo_control_t *control, clingo_part_t const *parts, size_t size, bool has_value)
Set the program parts to ground.
CLINGO_VISIBILITY_DEFAULT void clingo_control_release(clingo_control_t *control)
Decrement the reference count of the given control object and destroy if zero.
clingo_mode_e
The available application modes.
Definition control.h:37
CLINGO_VISIBILITY_DEFAULT bool clingo_const_map_size(clingo_const_map_t const *map, size_t *size)
Get the size of the constant map.
@ clingo_mode_ground
parse, rewrite, ground
Definition control.h:40
@ clingo_mode_parse
parse only
Definition control.h:38
@ clingo_mode_rewrite
parse and rewrite
Definition control.h:39
@ clingo_mode_solve
parse, rewrite, ground, and solve
Definition control.h:41
struct clingo_lib clingo_lib_t
A library object storing global information.
Definition core.h:176
struct clingo_location clingo_location_t
Represents a source code location marking its beginning and end.
Definition core.h:359
bool(* clingo_symbol_callback_t)(clingo_symbol_t const *symbols, size_t symbols_size, void *data)
Callback function to inject symbols.
Definition symbol.h:60
uint64_t clingo_symbol_t
Type to represent a symbol.
Definition symbol.h:51
Struct used to specify the program parts that have to be grounded.
Definition control.h:57
char const * name
name of the program part
Definition control.h:58
clingo_symbol_t const * params
array of parameters
Definition control.h:60
size_t params_size
number of parameters
Definition control.h:61
size_t name_size
the size of the name
Definition control.h:59
Struct to capture strings that are not null-terminated.
Definition core.h:91