pl_search_cpp 2.2
Loading...
Searching...
No Matches
Public Member Functions | List of all members
pl_search::ChoicePred Class Referenceabstract

A base class that represents a choice predicate. More...

#include <pred.hpp>

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

Public Member Functions

 ChoicePred (Trail *trail)
 Constructs a ChoicePred that tries available choices.
 
bool call () override
 Calls the choice predicate.
 
virtual bool has_next ()=0
 Checks if there are more choices available.
 
virtual bool make_choice ()=0
 Makes a choice from the available options.
 
virtual bool test_choice ()
 Tests the current choice for validity.
 
- 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.
 

Additional Inherited Members

- 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

A base class that represents a choice predicate.

The ChoicePred class represents a choice point in the execution of predicates. It tries to make a choice and, if successful, calls the continuation. If the choice fails, it tries the next choice until all choices are exhausted.

Constructor & Destructor Documentation

◆ ChoicePred()

pl_search::ChoicePred::ChoicePred ( Trail trail)
inline

Constructs a ChoicePred that tries available choices.

Parameters
trailPointer to the trail.

Member Function Documentation

◆ call()

bool pl_search::ChoicePred::call ( )
overridevirtual

Calls the choice predicate.

Returns
True if a choice is made successfully and the continuation succeeds and false if no choice and continuation succeeds.

Reimplemented from pl_search::Pred.

◆ has_next()

virtual bool pl_search::ChoicePred::has_next ( )
pure virtual

Checks if there are more choices available.

Returns
True if there are more choices, false otherwise.

Implemented in pl_search::VarChoicePred.

◆ make_choice()

virtual bool pl_search::ChoicePred::make_choice ( )
pure virtual

Makes a choice from the available options.

Returns
True if a choice is made successfully, false otherwise.

Implemented in pl_search::VarChoicePred.

◆ test_choice()

virtual bool pl_search::ChoicePred::test_choice ( )
inlinevirtual

Tests the current choice for validity.

Returns
True if the current choice is valid, false otherwise.

This method is typically overridden in derived classes to implement specific choice validation logic. By default, it returns true, indicating that the choice is valid.


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