Clingo
Loading...
Searching...
No Matches
control.h
1#ifndef CLINGO_CONTROL_H
2#define CLINGO_CONTROL_H
3
4#include <clingo/core.h>
5#include <clingo/ground.h>
6#include <clingo/symbol.h>
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12typedef struct clingo_program clingo_program_t;
13
27
33
35typedef struct clingo_control clingo_control_t;
36
45typedef int clingo_mode_t;
46
48typedef struct clingo_const_map clingo_const_map_t;
49
58CLINGO_VISIBILITY_DEFAULT bool clingo_const_map_find(clingo_const_map_t const *map, char const *name, size_t name_size,
59 clingo_symbol_t *symbol, bool *found);
60
68CLINGO_VISIBILITY_DEFAULT bool clingo_const_map_at(clingo_const_map_t const *map, size_t index, clingo_string_t *name,
69 clingo_symbol_t *symbol);
70
76CLINGO_VISIBILITY_DEFAULT bool clingo_const_map_size(clingo_const_map_t const *map, size_t *size);
77
92CLINGO_VISIBILITY_DEFAULT bool clingo_control_new(clingo_lib_t *lib, clingo_string_t const *arguments, size_t size,
93 clingo_control_t **control);
94
98CLINGO_VISIBILITY_DEFAULT void clingo_control_acquire(clingo_control_t *control);
99
103CLINGO_VISIBILITY_DEFAULT void clingo_control_release(clingo_control_t *control);
104
110CLINGO_VISIBILITY_DEFAULT bool clingo_control_mode(clingo_control_t *control, clingo_mode_t *mode);
111
118CLINGO_VISIBILITY_DEFAULT bool clingo_control_parse_files(clingo_control_t *control, clingo_string_t const *files,
119 size_t size);
120
130CLINGO_VISIBILITY_DEFAULT bool clingo_control_parse_string(clingo_control_t *control, char const *program, size_t size);
131
148CLINGO_VISIBILITY_DEFAULT bool clingo_control_ground(clingo_control_t *control, clingo_part_t const *parts, size_t size,
149 clingo_ground_event_handler_t const *handler, void *data);
150
170CLINGO_VISIBILITY_DEFAULT bool clingo_control_start_ground(clingo_control_t *control, clingo_part_t const *parts,
171 size_t size, clingo_ground_event_handler_t const *handler,
172 void *data, clingo_ground_handle_t **handle);
173
178CLINGO_VISIBILITY_DEFAULT bool clingo_control_main(clingo_control_t *control);
179
185CLINGO_VISIBILITY_DEFAULT bool clingo_control_const_map(clingo_control_t *control, clingo_const_map_t const **map);
186
194CLINGO_VISIBILITY_DEFAULT bool clingo_control_buffer(clingo_control_t *control, clingo_string_t *result);
195
203CLINGO_VISIBILITY_DEFAULT bool clingo_control_get_parts(clingo_control_t *control, clingo_part_t const **parts,
204 size_t *size, bool *has_value);
205
213CLINGO_VISIBILITY_DEFAULT bool clingo_control_set_parts(clingo_control_t *control, clingo_part_t const *parts,
214 size_t size, bool has_value);
215
218 minimize = 1,
219 project = 2,
220};
222typedef unsigned clingo_discard_type_t;
223
228CLINGO_VISIBILITY_DEFAULT bool clingo_control_discard(clingo_control_t *control, clingo_discard_type_t type);
229
236CLINGO_VISIBILITY_DEFAULT void clingo_control_interrupt(clingo_control_t *control);
237
239
240#ifdef __cplusplus
241}
242#endif
243
244#endif
struct clingo_program clingo_program_t
Object to store.
Definition ast.h:496
unsigned clingo_discard_type_t
Corresponding type to clingo_discard_type_e.
Definition control.h:222
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:45
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.
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:48
CLINGO_VISIBILITY_DEFAULT void clingo_control_acquire(clingo_control_t *control)
Increment the reference count of the given control object.
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:217
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:38
CLINGO_VISIBILITY_DEFAULT bool clingo_control_ground(clingo_control_t *control, clingo_part_t const *parts, size_t size, clingo_ground_event_handler_t const *handler, void *data)
Ground the selected parts of the current (non-ground) logic program.
CLINGO_VISIBILITY_DEFAULT bool clingo_control_start_ground(clingo_control_t *control, clingo_part_t const *parts, size_t size, clingo_ground_event_handler_t const *handler, void *data, clingo_ground_handle_t **handle)
Start grounding a program asynchronously.
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:41
@ clingo_mode_parse
parse only
Definition control.h:39
@ clingo_mode_rewrite
parse and rewrite
Definition control.h:40
@ clingo_mode_solve
parse, rewrite, ground, and solve
Definition control.h:42
struct clingo_lib clingo_lib_t
A library object storing global information.
Definition core.h:171
struct clingo_ground_handle clingo_ground_handle_t
Handle to an asynchronous ground call.
Definition ground.h:136
uint64_t clingo_symbol_t
Type to represent a symbol.
Definition symbol.h:51
The ground event handler interface.
Definition ground.h:62
Struct used to specify the program parts that have to be grounded.
Definition ground.h:44
Struct to capture strings that are not null-terminated.
Definition core.h:86