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

Represents a disjunction of predicates. More...

#include <pred.hpp>

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

Public Member Functions

 DisjPred (Trail *trail, std::vector< PredPtr > preds)
 Constructs a DisjPred with the given predicates.
 
bool call () override
 Calls the disjunction predicate, iterating through available predicates.
 
void set_continuation (PredPtr cont) override
 Sets the continuation for all predicates in the disjunction.
 
- 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.
 
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

std::vector< PredPtrpreds
 The predicates in the disjunction.
 
- Protected Attributes inherited from pl_search::Pred
PredPtr continuation
 The continuation of the predicate.
 
Trailtrail
 Pointer to the trail for managing variable bindings.
 

Detailed Description

Represents a disjunction of predicates.

Constructor & Destructor Documentation

◆ DisjPred()

pl_search::DisjPred::DisjPred ( Trail trail,
std::vector< PredPtr preds 
)
inline

Constructs a DisjPred with the given predicates.

Parameters
trailPointer to the trail.
predsA vector of shared pointers to the predicates. It is the vector of predicate choices - when a choice is made that choice becomes the next predicate to be called.

The DisjPred class represents a disjunction of predicates, where each predicate is tried in order until one succeeds or all fail.

Member Function Documentation

◆ call()

bool pl_search::DisjPred::call ( )
overridevirtual

Calls the disjunction predicate, iterating through available predicates.

Returns
True if a predicate is called successfully and the continuation succeeds and false if no predicate and continuation succeeds.

Reimplemented from pl_search::Pred.

◆ set_continuation()

void pl_search::DisjPred::set_continuation ( PredPtr  cont)
overridevirtual

Sets the continuation for all predicates in the disjunction.

Parameters
contA shared pointer to the continuation predicate.

All disjuncts are set to the same continuation, which is the continuation of the DisjPred itself. This ensures that when any disjunct succeeds, the correct continuation is called.

Reimplemented from pl_search::Pred.

Member Data Documentation

◆ preds

std::vector<PredPtr> pl_search::DisjPred::preds
protected

The predicates in the disjunction.


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