Overview of This Tutorial
The manager of the video store wants to know the names of the ten most popular videos over a particular time period. The information could be used to drive purchasing decisions or advertising.
The query techniques of the early tutorials are employed here again; however, the records are not processed one at a time. This time, the records are brought into the program’s memory space as a group. To accomplish this, a template-based memory table is employed. When given an RWDBTable, RWDBSelector, or RWDBReader instance, a memory table populates itself up to its maximum size. The template-based memory tables can store their contents using any one of several template-based collections from the Essential Tools Module.
A new class is created for this tutorial, topTenVideo. It is a simple class that stores one element of the top ten video list. It consists of just the name of the video and the number of times it was rented. The class has constructors, and several member functions used in comparing two instances. It also includes a friend function that allows an instance to be initialized from a reader. Because this class is relatively simple, detailed commentary about its inner workings is omitted. The source code for this class is found in t6.cpp, the source file for this tutorial. This class and the collection class RWTPtrOrderedVector, are used as template arguments for the memory table. Details about the memory table are given in the code comments in The Main Routine .
This sample program uses the VVVideoRepository class. This class hides the details of the DB Interface Module code in the same manner that the DB Interface Module code hides the details of the underlying database API.