Most of the above assumes Prolog is `in charge' of the application and C++ is used to add functionality to Prolog, either for accessing external resources or for performance reasons. In some applications, there is a main-program and we want to use Prolog as a logic server. For these applications, the class PlEngine has been defined.
Only a single instance of this class can exist in a process. When used in a multi-threading application, only one thread at a time may have a running query on this engine. Applications should ensure this using proper locking techniques.1For Unix, there is a multi-threaded version of SWI-Prolog. In this version each thread can create and destroy a thread-engine. There is currently no C++ interface defined to access this functionality, though ---of course--- you can use the C-functions.
- PlEngine :: PlEngine(int argc, char **argv)
- Initialises the Prolog engine. The application should make sure to pass
argvfrom its main function, which is needed in the Unix version to find the running executable. See PL_initialise() for details.
- PlEngine :: PlEngine(char *argv0)
- Simple constructure using the main constructor with the specified
- ~ PlEngine()
- Calls PL_cleanup() to destroy all data created by the Prolog engine.
Section 4.11 has a simple example using this class.