pl_search_cpp 1.4
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
pl_search::IfThenElse Class Reference

Represents the equivalent of Prolog if-then-else i.e. (G1 -> G2; G3) - similar to (G1, !, G2; G3) ) More...

#include <pred.hpp>

Inheritance diagram for pl_search::IfThenElse:
Inheritance graph
[legend]
Collaboration diagram for pl_search::IfThenElse:
Collaboration graph
[legend]

Public Member Functions

 IfThenElse (Engine *eng, PredPtr if_pred, PredPtr then_pred, PredPtr else_pred)
 The equlvalent of the Prolog call (If -> Then ; Else)
 
void initialize_call () override
 Initializes the predicate call.
 
bool apply_choice () override
 Applies a choice.
 
bool more_choices () override
 Checks if there are more choices.
 
void set_continuation (PredPtr cont)
 Sets the continuation of the predicate.
 
- Public Member Functions inherited from pl_search::Pred
 Pred (Engine *eng)
 Default constructor.
 
PredPtr get_continuation ()
 Gets the continuation of the predicate.
 
PredPtr last_pred ()
 Follows the continuation chain to the last predicate.
 
bool is_non_det ()
 Determines if the predicate is non-deterministic.
 
void wrap_with_once ()
 Wraps the predicate with a once.
 
virtual ~Pred ()=default
 Virtual destructor for proper cleanup.
 
std::string get_name ()
 For debugging.
 

Protected Attributes

PredPtr if_pred
 
PredPtr then_pred
 
PredPtr else_pred
 
PredPtr if_then_pred
 
std::shared_ptr< Cutcut_pred
 
int choice_number
 
- Protected Attributes inherited from pl_search::Pred
PredPtr continuation
 The continuation of the predicate.
 
Engineengine
 

Detailed Description

Represents the equivalent of Prolog if-then-else i.e. (G1 -> G2; G3) - similar to (G1, !, G2; G3) )

Constructor & Destructor Documentation

◆ IfThenElse()

pl_search::IfThenElse::IfThenElse ( Engine eng,
PredPtr  if_pred,
PredPtr  then_pred,
PredPtr  else_pred 
)

The equlvalent of the Prolog call (If -> Then ; Else)

Parameters
engPointer to the engine
if_predThe guard predicate
then_predThe then predicate
else_predThe else predicate

Member Function Documentation

◆ apply_choice()

bool pl_search::IfThenElse::apply_choice ( )
overridevirtual

Applies a choice.

Returns
True if the choice is applied successfully, false otherwise.

Reimplemented from pl_search::Pred.

◆ initialize_call()

void pl_search::IfThenElse::initialize_call ( )
overridevirtual

Initializes the predicate call.

Reimplemented from pl_search::Pred.

◆ more_choices()

bool pl_search::IfThenElse::more_choices ( )
overridevirtual

Checks if there are more choices.

Returns
True if there are more choices, false otherwise.

Reimplemented from pl_search::Pred.

◆ set_continuation()

void pl_search::IfThenElse::set_continuation ( PredPtr  cont)
virtual

Sets the continuation of the predicate.

Parameters
contA shared pointer to the continuation predicate.

Reimplemented from pl_search::Pred.

Member Data Documentation

◆ choice_number

int pl_search::IfThenElse::choice_number
protected

◆ cut_pred

std::shared_ptr<Cut> pl_search::IfThenElse::cut_pred
protected

◆ else_pred

PredPtr pl_search::IfThenElse::else_pred
protected

◆ if_pred

PredPtr pl_search::IfThenElse::if_pred
protected

◆ if_then_pred

PredPtr pl_search::IfThenElse::if_then_pred
protected

◆ then_pred

PredPtr pl_search::IfThenElse::then_pred
protected

The documentation for this class was generated from the following files: