Step 2: C++ Demo

As explained in the previous step the eXtremeDB C++ API consists of a set of generated classes that provide a thin wrapper around the generated C API functions. All of the implementation details described for the C API apply also to C++ applications. For example getting eXtremeDB runtime information, opening and connecting to databases are performed using the C API. One of the main conveniences of the generated C++ wrapper classes is the ability to inherit and extend their functionality with application level classes. A simple example of this technique is demonstrated in sample samples/native/core/20-languages/cpp/cppdemo.

Please build and run this sample then examine the source code. Note how the application level class MyPart extends the functionality of the generated class Part. Also, note how the function populate_db() uses the C APIs mco_trans_start() and mco_trans_commit() to manage a database transaction, and uses MyPart inherited methods to create database objects and store values in their individual fields.

The function printPartsOfType() further demonstrates the use of C API functions together with MyPart methods to search for a given type of Part, then instantiate and scroll through a cursor to display the result set of database objects.