3#include <clingo/base.hh>
4#include <clingo/core.hh>
5#include <clingo/stats.hh>
7#include <clingo/ground.h>
22 assert(!this->name.empty());
56 auto callable(std::string_view name,
size_t args) ->
bool {
return do_callable(name, args); }
65 return do_call(loc, name, args);
104 return GroundResult{Detail::call<clingo_ground_handle_get>(hnd_.get())};
115 void close() noexcept { hnd_.reset(); }
125 [[nodiscard]]
auto wait(std::optional<double> timeout) ->
bool {
126 return Detail::call<clingo_ground_handle_wait>(hnd_.get(), timeout.value_or(-1));
133 using Ptr = std::unique_ptr<clingo_ground_handle_t, Del>;
An interface for handling grounding events.
Definition ground.hh:45
auto callable(std::string_view name, size_t args) -> bool
Check whether a function is callable for the given number of arguments.
Definition ground.hh:56
virtual ~GroundEventHandler()=default
Default destructor.
void finish(GroundResult result) noexcept
Notify the handler that grounding has finished with the given result.
Definition ground.hh:69
GroundEventHandler()=default
Default constructor.
auto call(Location const &loc, std::string_view name, SymbolSpan args) -> SymbolVector
Call the given function with the given arguments.
Definition ground.hh:64
Class to control a running ground call.
Definition ground.hh:83
void close() noexcept
Closes the solve handle.
Definition ground.hh:115
GroundHandle(clingo_ground_handle_t *hnd)
Constructor from the underlying C representation.
Definition ground.hh:90
auto wait(std::optional< double > timeout) -> bool
Wait for a running ground call.
Definition ground.hh:125
void cancel()
Cancel the current search.
Definition ground.hh:110
friend auto c_cast(GroundHandle const &x) -> clingo_ground_handle_t *
Cast the solve handle to its C representation.
Definition ground.hh:95
auto get() const -> GroundResult
Get the solve result.
Definition ground.hh:103
Class representing a range in a file.
Definition core.hh:749
struct clingo_ground_handle clingo_ground_handle_t
Handle to an asynchronous ground call.
Definition ground.h:136
unsigned clingo_ground_result_t
Corresponding type to clingo_ground_result_e.
Definition ground.h:59
CLINGO_VISIBILITY_DEFAULT void clingo_ground_handle_close(clingo_ground_handle_t *handle)
Release the ground handle.
CLINGO_VISIBILITY_DEFAULT bool clingo_ground_handle_cancel(clingo_ground_handle_t *handle)
Stop the running ground call and block until done.
@ clingo_ground_result_ok
Grounding completed successfully.
Definition ground.h:54
@ clingo_ground_result_unsatisfiable
Grounding detected unsatisfiability.
Definition ground.h:55
@ clingo_ground_result_interrupted
Grounding was interrupted.
Definition ground.h:56
std::vector< Part > PartVector
A vector of program parts.
Definition ground.hh:35
std::span< Part const > PartSpan
A span of program parts.
Definition ground.hh:31
GroundResult
Enumeration of the results of a grounding process.
Definition ground.hh:38
std::initializer_list< Part > PartList
An initializer list of program parts.
Definition ground.hh:33
@ ok
Grounding completed successfully.
@ unsatisfiable
An inconsistency was detected during grounding.
@ interrupted
Grounding was interrupted.
std::vector< Symbol > SymbolVector
A vector of symbols.
Definition symbol.hh:42
std::span< Symbol const > SymbolSpan
A span of symbols, which is a view on a contiguous sequence of symbols.
Definition symbol.hh:38
A program part to provide inputs to program directives.
Definition ground.hh:16
constexpr Part(std::string name, SymbolVector params={})
Constructs a program part with the given name and parameters.
Definition ground.hh:21
std::string name
The name of the part.
Definition ground.hh:26
SymbolVector params
The parameters of the part.
Definition ground.hh:28