C++ Samples

These samples illustrate the use of the Amzi! Logic Server from C++.

Note - At of the Gnu 3.2 release standard use of exception classes causes segmentation faults, so when C++ applications are built with Gnu, Logic Server exceptions are thrown as pointers to the exception objects, rather than as references.

Hello / Console - The Hello Prolog example implemented as a C++ class running as a console application. Should be run from the console.

Hello / Win32_MFC - The Hello Prolog example implemented as a C++ class running in a simple MFC dialog application.

Pets - The trivial Pets expert system showing a simple architecture for expert system services. Should be run from the console.

Pets_Callback - A slightly more complex version of Pets in which the Prolog program has a prompt/2 predicate used to get information from the user. In the example, it is used to ask the user for the sound the pet makes.

prompt/2 is implemented as an extended predicate in the C++ class derived from LogicServer, illustrating the technique of having extended predicates associated with instances of classes derived from the Logic Server.

This is a trivial console example, where there is no real point in having multiple instances of the prompt/2 predicate, but the technique is important for GUI applications where, for example, different instances of the Logic Server might be associated with different windows on the screen.

Win32_Rubik_Multi - The Win32_Rubik_Multi (MultiThreaded) sample is an MDI MFC application. Each child window has an unfolded view of a Rubik's cube and a 'Solve' button. When the button is pressed, the cube is randomly scrambled and then solved.

The FILE/NEW menu item causes new child windows to be created, and each one is associated with a new Logic Server, running in a separate thread.

When you click the 'Solve' button in multiple windows, each one shows a cube being solved at the same (or as close to same as NT multi-threading allows) time.

This demo was derived from the Microsoft multi-threaded 'Bounce' sample, with solving Rubik's cube replacing the bouncing balls.

Copyright ©1987-2004 Amzi! inc. All Rights Reserved. Amzi! is a registered trademark and Logic Server and e-Prolog are trademarks of Amzi! inc.