|
pl_search_cpp 2.1
|
Represents the equivalent of Prolog if-then-else i.e. (G1 -> G2; G3) - similar to (G1, !, G2; G3) More...
#include <pred.hpp>


Public Member Functions | |
| IfThenElse (Trail *trail, PredPtr if_pred, PredPtr then_pred, PredPtr else_pred) | |
| The equlvalent of the Prolog call (If -> Then ; Else) | |
| void | set_continuation (PredPtr cont) override |
| Sets the continuation for the then and else predicates to the given continuation which will be the continuation of the IfThenElse predicate. | |
| bool | call () override |
Public Member Functions inherited from pl_search::Pred | |
| Pred (Trail *trail) | |
| Default constructor. | |
| PredPtr | get_continuation () |
| Gets the continuation of the predicate. | |
| PredPtr | last_pred () |
| Follows the continuation chain to the last predicate. | |
| bool | call_continuation () |
| Calls the continuation of the predicate. | |
| virtual | ~Pred ()=default |
| Virtual destructor for proper cleanup. | |
| virtual std::string | get_name () |
| For debugging. | |
Protected Attributes | |
| PredPtr | if_pred |
| PredPtr | then_pred |
| PredPtr | else_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 if-then-else i.e. (G1 -> G2; G3) - similar to (G1, !, G2; G3)
The IfThenElse meta-predicate is used to implement the equivalent of Prolog's if-then-else construct. If the guard predicate G1 succeeds then the then predicate G2 is called and any variable bindings made by G1 are preserved but any choice points made by G1 are removed. If G2 or the continuation fails then the IfThenElse predicate fails and any variable bindings made by G1 and G2 are undone. If G1 fails then the else predicate G3 is called and any variable bindings made by G1 are undone. If G3 or the continuation fails then the IfThenElse predicate fails. Note that G1 is a local call - i.e. its continuation is not related to the continuation of the IfThenElse predicate. Also note that the continuations of G2 and G3 are set to the continuation of the IfThenElse predicate. )
| pl_search::IfThenElse::IfThenElse | ( | Trail * | eng, |
| PredPtr | if_pred, | ||
| PredPtr | then_pred, | ||
| PredPtr | else_pred | ||
| ) |
The equlvalent of the Prolog call (If -> Then ; Else)
| trail | Pointer to the trail |
| if_pred | The guard predicate |
| then_pred | The then predicate |
| else_pred | The else predicate |
| eng | Pointer to the trail |
| if_pred | The guard predicate |
| then_pred | The then predicate |
| else_pred | The else predicate |
|
overridevirtual |
Reimplemented from pl_search::Pred.
|
overridevirtual |
Sets the continuation for the then and else predicates to the given continuation which will be the continuation of the IfThenElse predicate.
| cont | A shared pointer to the continuation predicate. |
As with DisjPred the continuations of the then and else predicates are set to the continuation of the IfThenElse predicate.
Reimplemented from pl_search::Pred.
|
protected |
|
protected |
|
protected |