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

Abstract base class for Prolog-like predicates. More...

#include <pred.hpp>

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

Public Member Functions

 Pred (Engine *eng)
 Default constructor.
 
virtual void initialize_call ()
 Initializes the predicate call.
 
virtual bool apply_choice ()
 Applies a choice.
 
virtual bool more_choices ()
 Checks if there are more choices.
 
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.
 
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 continuation
 The continuation of the predicate.
 
Engineengine
 

Detailed Description

Abstract base class for Prolog-like predicates.

The Pred class provides an interface for Prolog-like predicates. It includes methods for initializing calls, applying choices, testing choices, and checking for more choices. It also includes methods for managing continuations.

Constructor & Destructor Documentation

◆ Pred()

pl_search::Pred::Pred ( Engine eng)
inline

Default constructor.

◆ ~Pred()

virtual pl_search::Pred::~Pred ( )
virtualdefault

Virtual destructor for proper cleanup.

Member Function Documentation

◆ apply_choice()

virtual bool pl_search::Pred::apply_choice ( )
inlinevirtual

Applies a choice.

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

Reimplemented in pl_search::ChoicePred, pl_search::DetPred, pl_search::DisjPred, pl_search::Cut, pl_search::NotNotEnd, pl_search::NotNot, pl_search::IfThenElse, and pl_search::Loop.

◆ get_continuation()

PredPtr pl_search::Pred::get_continuation ( )
inline

Gets the continuation of the predicate.

Returns
A shared pointer to the continuation predicate.

◆ get_name()

std::string pl_search::Pred::get_name ( )
inline

For debugging.

◆ initialize_call()

virtual void pl_search::Pred::initialize_call ( )
inlinevirtual

◆ is_non_det()

bool pl_search::Pred::is_non_det ( )
inline

Determines if the predicate is non-deterministic.

Returns
True if the predicate is non-deterministic, false otherwise.

◆ last_pred()

PredPtr pl_search::Pred::last_pred ( )

Follows the continuation chain to the last predicate.

Initializes the predicate call.

Returns
A shared pointer to the last predicate in the continuation chain.

Follows the continuation chain to the last predicate.

Returns
A shared pointer to the last predicate in the continuation chain.

◆ more_choices()

virtual bool pl_search::Pred::more_choices ( )
inlinevirtual

Checks if there are more choices.

Returns
True if there are more choices, false otherwise.

Reimplemented in pl_search::ChoicePred, pl_search::SemiDetPred, pl_search::DisjPred, pl_search::NotNot, and pl_search::IfThenElse.

◆ set_continuation()

virtual void pl_search::Pred::set_continuation ( PredPtr  cont)
inlinevirtual

Sets the continuation of the predicate.

Parameters
contA shared pointer to the continuation predicate.

Reimplemented in pl_search::IfThenElse, and pl_search::Loop.

◆ wrap_with_once()

void pl_search::Pred::wrap_with_once ( )

Wraps the predicate with a once.

Member Data Documentation

◆ continuation

PredPtr pl_search::Pred::continuation
protected

The continuation of the predicate.

◆ engine

Engine* pl_search::Pred::engine
protected

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