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

Constructs a predicate that loops over (instances of) a predicate while some condition (loop_continues) is satisfied. More...

#include <pred.hpp>

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

Public Member Functions

 Loop (Engine *eng, LoopBodyFactory *bf)
 Constructs a predicate that loops over (instances of) a predicate while some condition (loop_continues) is satisfied.
 
void initialize_call () override
 Initializes the predicate call.
 
bool apply_choice () override
 Applies a choice for the loop predicate.
 
void set_continuation (PredPtr cont)
 Sets the continuation for the loop predicate.
 
- Public Member Functions inherited from pl_search::DetPred
 DetPred (Engine *eng)
 Represents a deterministic predicate.
 
- Public Member Functions inherited from pl_search::SemiDetPred
 SemiDetPred (Engine *eng)
 Represents a semi-deterministic predicate.
 
bool more_choices () override
 Applies a choice.
 
bool is_non_det ()
 
- 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.
 

Public Attributes

LoopBodyFactorybody_factory
 

Protected Attributes

PredPtr saved_continuation
 
- Protected Attributes inherited from pl_search::Pred
PredPtr continuation
 The continuation of the predicate.
 
Engineengine
 

Detailed Description

Constructs a predicate that loops over (instances of) a predicate while some condition (loop_continues) is satisfied.

Constructor & Destructor Documentation

◆ Loop()

pl_search::Loop::Loop ( Engine eng,
LoopBodyFactory bf 
)
inline

Constructs a predicate that loops over (instances of) a predicate while some condition (loop_continues) is satisfied.

Parameters
engPointer to the engine.
bfa subclass of LoopBodyFactory that is used to generate body predicates to call and to test if the loop should continue.

Member Function Documentation

◆ apply_choice()

bool pl_search::Loop::apply_choice ( )
overridevirtual

Applies a choice for the loop predicate.

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

Reimplemented from pl_search::DetPred.

◆ initialize_call()

void pl_search::Loop::initialize_call ( )
overridevirtual

Initializes the predicate call.

Reimplemented from pl_search::Pred.

◆ set_continuation()

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

Sets the continuation for the loop predicate.

Parameters
contA shared pointer to the continuation predicate.

When the loop body predicate is created in apply_choice, continuation is set to the newely created predicate. When the loop exits continuation is reset to the original continuation (the predicate to call after the loop body). Therefore the set continuation needs to be saved.

Reimplemented from pl_search::Pred.

Member Data Documentation

◆ body_factory

LoopBodyFactory* pl_search::Loop::body_factory

◆ saved_continuation

PredPtr pl_search::Loop::saved_continuation
protected

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