Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

20.2 Overview

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 Tools.h++.

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 Section 20.5.1.

This sample program uses the VVVideoRepository class. This class hides the details of the DBTools.h++ code in the same manner that the DBTools.h++ code hides the details of the underlying database API.


Previous fileTop of DocumentContentsIndexNext file

©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.