|
pl_search_cpp 2.2
|
Represents the equivalent of Prolog's once(Pred). The aim is to remove any choicepoints produced by Pred. More...
#include <pred.hpp>


Public Member Functions | |
| Once (Trail *trail, PredPtr pred) | |
| Constructs a Once predicate with the given trail and predicate. | |
| bool | call () override |
| Calls the once predicate. | |
Public Member Functions inherited from pl_search::Pred | |
| Pred (Trail *trail) | |
| Default constructor. | |
| PredPtr | get_continuation () |
| Gets the continuation of the predicate. | |
| virtual void | set_continuation (PredPtr cont) |
| Sets the continuation of the predicate. | |
| PredPtr | last_pred () |
| Follows the continuation chain to the last predicate. | |
| virtual void | call_init () |
| Initialize call. | |
| bool | call_continuation () |
| Calls the continuation of the predicate - first call_init and then call. | |
| virtual | ~Pred ()=default |
| Virtual destructor for proper cleanup. | |
| virtual std::string | get_name () |
| For debugging. | |
Protected Attributes | |
| PredPtr | pred |
Protected Attributes inherited from pl_search::Pred | |
| PredPtr | continuation |
| The continuation of the predicate. | |
| Trail * | trail |
| Pointer to the trail for managing variable bindings. | |
Represents the equivalent of Prolog's once(Pred). The aim is to remove any choicepoints produced by Pred.
The meta-predicate Once is used to remove any choicepoints produced by Pred. If Pred succeeds then the continuation is called and any choicepoints produced by Pred are removed. If Pred or the continuation fails then the Once predicate fails and any bindings produced by Pred are undone. Note that Pred is a local call - i.e. its continuation is not related to the continuation of the Once predicate. Also note that Pred could be a conjunction of predicates.
Constructs a Once predicate with the given trail and predicate.
| trail | Pointer to the trail. |
| pred | The predicate called within the once. |
|
overridevirtual |
Calls the once predicate.
When a Once object is called it calls the predicate supplied to the Once constructor. If the call fails then the Once predicate fails and any bindings created by the call are undone. If the call succeeds then the continuation is called. Note that no alternative choices for pred are tried if the continuation fails. The Once predicate is used to remove any choicepoints produced by pred.
Reimplemented from pl_search::Pred.
|
protected |