knowrob
2.1.0
A Knowledge Base System for Cognition-enabled Robots
|
#include <PrologEngine.h>
Public Types | |
using | ErrorHandler = ThreadPool::ExceptionHandler |
using | GoalFactory = std::function< PrologTerm()> |
using | Solution = std::map< Variable, TermPtr, std::less<> > |
using | ErrorHandler = ThreadPool::ExceptionHandler |
using | GoalFactory = std::function< PrologTerm()> |
using | Solution = std::map< Variable, TermPtr, std::less<> > |
Public Types inherited from knowrob::ThreadPool | |
using | ExceptionHandler = std::function< void(const std::exception &)> |
using | ExceptionHandler = std::function< void(const std::exception &)> |
Public Member Functions | |
PrologEngine (uint32_t maxNumThreads=0) | |
PrologEngine (uint32_t maxNumThreads=0) | |
Public Member Functions inherited from knowrob::ThreadPool | |
ThreadPool (uint32_t maxNumThreads) | |
virtual | ~ThreadPool () |
ThreadPool (const ThreadPool &)=delete | |
void | shutdown () |
void | pushWork (const std::shared_ptr< ThreadPool::Runner > &goal, ThreadPool::ExceptionHandler exceptionHandler) |
ThreadPool (uint32_t maxNumThreads) | |
virtual | ~ThreadPool () |
ThreadPool (const ThreadPool &)=delete | |
void | shutdown () |
void | pushWork (const std::shared_ptr< ThreadPool::Runner > &goal, ThreadPool::ExceptionHandler exceptionHandler) |
Static Public Member Functions | |
static void | initializeProlog () |
static void | finalizeProlog () |
static bool | isPrologInitialized () |
static bool | eval (const GoalFactory &goalFactory) |
static std::optional< Solution > | oneSolution (const GoalFactory &goalFactory) |
static std::vector< Solution > | allSolutions (const GoalFactory &goalFactory) |
static void | query (const GoalFactory &goalFactory, const BindingsHandler &callback) |
static bool | consult (const std::filesystem::path &uri, const char *module={}) |
static void | pushGoal (const std::shared_ptr< ThreadPool::Runner > &goal, const ErrorHandler &errHandler) |
static void | pushGoalAndJoin (const std::shared_ptr< ThreadPool::Runner > &goal) |
static std::filesystem::path | getPrologPath (const std::filesystem::path &filename) |
static std::filesystem::path | getResourcePath (const std::filesystem::path &filename) |
static void | initializeProlog () |
static void | finalizeProlog () |
static bool | isPrologInitialized () |
static bool | eval (const GoalFactory &goalFactory) |
static std::optional< Solution > | oneSolution (const GoalFactory &goalFactory) |
static std::vector< Solution > | allSolutions (const GoalFactory &goalFactory) |
static void | query (const GoalFactory &goalFactory, const BindingsHandler &callback) |
static bool | consult (const std::filesystem::path &uri, const char *module={}) |
static void | pushGoal (const std::shared_ptr< ThreadPool::Runner > &goal, const ErrorHandler &errHandler) |
static void | pushGoalAndJoin (const std::shared_ptr< ThreadPool::Runner > &goal) |
static std::filesystem::path | getPrologPath (const std::filesystem::path &filename) |
static std::filesystem::path | getResourcePath (const std::filesystem::path &filename) |
Protected Member Functions | |
bool | initializeWorker () override |
bool | initializeWorker () override |
Static Protected Member Functions | |
static void | expandSearchPaths () |
static void | expandSearchPaths () |
Static Protected Attributes | |
static bool | isPrologInitialized_ = false |
static std::vector< std::string > | arguments_ = std::vector<std::string>() |
static std::optional< PrologEngine > | self_ = std::nullopt |
Additional Inherited Members | |
Protected Attributes inherited from knowrob::ThreadPool | |
std::function< void()> | finalizeWorker_ |
A pool of threads with attached Prolog engines. Prolog threads have their own stacks and only share the Prolog heap: predicates, records, flags and other global non-backtrackable data. NOTE: term_t cannot be created in the main thread and used it in a worker thread! The term reference will be most likely a variable in the worker thread no matter what value it has in the main thread.
Definition at line 22 of file PrologEngine.h.
Definition at line 24 of file PrologEngine.h.
Definition at line 24 of file PrologEngine.h.
using knowrob::PrologEngine::GoalFactory = std::function<PrologTerm()> |
Definition at line 25 of file PrologEngine.h.
using knowrob::PrologEngine::GoalFactory = std::function<PrologTerm()> |
Definition at line 25 of file PrologEngine.h.
using knowrob::PrologEngine::Solution = std::map<Variable, TermPtr, std::less<> > |
Definition at line 26 of file PrologEngine.h.
using knowrob::PrologEngine::Solution = std::map<Variable, TermPtr, std::less<> > |
Definition at line 26 of file PrologEngine.h.
|
explicit |
maxNumThreads | maximum number of worker threads. |
Definition at line 32 of file PrologEngine.cpp.
|
explicit |
maxNumThreads | maximum number of worker threads. |
|
static |
Evaluate a goal in a thread with a Prolog engine.
goalFactory | a goal factory |
Definition at line 224 of file PrologEngine.cpp.
|
static |
Evaluate a goal in a thread with a Prolog engine.
goalFactory | a goal factory |
|
static |
Consults a Prolog file, i.e. loads facts and rules and executed directives in the file. May throw an exception if there is no valid Prolog file at the given path.
uri | the local path to the file. |
module | the module to consult the file into |
Definition at line 264 of file PrologEngine.cpp.
|
static |
Consults a Prolog file, i.e. loads facts and rules and executed directives in the file. May throw an exception if there is no valid Prolog file at the given path.
uri | the local path to the file. |
module | the module to consult the file into |
|
static |
Evaluate a goal in a thread with a Prolog engine.
goalFactory | a goal factory |
Definition at line 191 of file PrologEngine.cpp.
|
static |
Evaluate a goal in a thread with a Prolog engine.
goalFactory | a goal factory |
|
staticprotected |
Definition at line 130 of file PrologEngine.cpp.
|
staticprotected |
|
static |
Must be called after all Prolog library interactions.
Definition at line 118 of file PrologEngine.cpp.
|
static |
Must be called after all Prolog library interactions.
|
static |
Resolve the path to a Prolog file. The function attempts to resolve project-relative paths.
filename | a name or path. |
Definition at line 275 of file PrologEngine.cpp.
|
static |
Resolve the path to a Prolog file. The function attempts to resolve project-relative paths.
filename | a name or path. |
|
static |
Resolve the path to a resource file. The function attempts to resolve project-relative paths.
filename | a name or path. |
Definition at line 293 of file PrologEngine.cpp.
|
static |
Resolve the path to a resource file. The function attempts to resolve project-relative paths.
filename | a name or path. |
|
static |
Must be called before any Prolog library interactions.
Definition at line 72 of file PrologEngine.cpp.
|
static |
Must be called before any Prolog library interactions.
|
overrideprotectedvirtual |
|
overrideprotectedvirtual |
Reimplemented from knowrob::ThreadPool.
|
inlinestatic |
|
inlinestatic |
|
static |
Evaluate a goal in a thread with a Prolog engine.
goalFactory | a goal factory |
Definition at line 205 of file PrologEngine.cpp.
|
static |
Evaluate a goal in a thread with a Prolog engine.
goalFactory | a goal factory |
|
static |
Run a goal in a worker thread with a Prolog engine.
goal | the work goal |
errHandler | a function that handles exceptions thrown by the goal |
Definition at line 178 of file PrologEngine.cpp.
|
static |
Run a goal in a worker thread with a Prolog engine.
goal | the work goal |
errHandler | a function that handles exceptions thrown by the goal |
|
static |
Run a goal in a worker thread with a Prolog engine and wait for termination. Also rethrow any exceptions in the thread of the caller.
goal | the work goal |
Definition at line 182 of file PrologEngine.cpp.
|
static |
Run a goal in a worker thread with a Prolog engine and wait for termination. Also rethrow any exceptions in the thread of the caller.
goal | the work goal |
|
static |
Evaluate a goal in a thread with a Prolog engine.
goalFactory | a goal factory |
callback | a function that handles the solutions |
Definition at line 244 of file PrologEngine.cpp.
|
static |
Evaluate a goal in a thread with a Prolog engine.
goalFactory | a goal factory |
callback | a function that handles the solutions |
|
staticprotected |
Definition at line 118 of file PrologEngine.h.
|
staticprotected |
Definition at line 117 of file PrologEngine.h.
|
staticprotected |
Definition at line 119 of file PrologEngine.h.