home *** CD-ROM | disk | FTP | other *** search
- // Copyright 1994 A.D. Software. All Rights Reserved
-
- // OOFTEST2
-
- // This sample tests the database backend by creating a pair of tables
- // and storing and retrieving indexed data via traversal paths.
-
- // Simple stream I/O is used to interact with the user.
- #include "oofile.hpp"
-
- #include "ooftst02.inc"
-
- int main()
- {
- cout << "OOFILE Validation Suite - Test 2\n"
- << "Simple test to store some data and retrieve it" << endl
- << "using a relation joining over a field and showing" << endl
- << "iterators on related tables and 1-many relations" << endl << endl;
-
- if (dbConnect::fileExists("ooftst02.db"))
- theDB.openConnection("ooftst02.db");
- else {
- theDB.newConnection("ooftst02.db");
- People.AddTest2Data();
- }
-
- People.sortBy(People.LastName);
- People.start();
- while (People.more()) {
- cout << People.PatientNo << '\t'
- << People.LastName << endl;
- if (People.Visits.count()==0)
- cout << "no visits" << endl;
- else {
- People.Visits.start();
- while (People.Visits.more()) {
- cout << '\t' << People.Visits->VisitDate() << '\t'
- << People.Visits->Why() << endl;
- People.Visits.next();
- }
- }
- cout << endl;
- People.next();
- }
-
- cout << endl << "Now repeating the process using a dbView instead of explicitly"
- << endl << "iterating over the related file." << endl;
- dbView relatedVisits(People.Visits);
- relatedVisits << People.Visits->VisitDate() << People.Visits->Why();
- People.start();
- while (People.more()) {
- cout << People.PatientNo << '\t'
- << People.LastName << endl;
- if (relatedVisits.source()->empty())
- cout << "no visits" << endl;
- else
- cout << relatedVisits << endl;
- cout << endl;
- People.next();
- }
- cout << "Test Completed" << endl;
-
- return EXIT_SUCCESS;
- }