OOFILE | Downloads | Purchasing | Press | Services | Company Information | Soapbox | References | F.A.Q. | HOME |
This sample tests the Persistent RAM database backend ability to save and revert the whole database.
#include "oofile.h" // the general oofile library #include "ooftst02.h" // the declarations for the database classes we will be using in this test.
These are the global variables that define the database using the ooftst02 classes. Note that our connection is to persistent ram by using dbConnect_ramp
dbConnect_ramp theDB; dbPatients Patients; dbVisits Visits; dbRelationship PatientVisits(Patients.Visits, Visits.Patient);
int main()
{
cout << "OOFILE Validation Suite - Test 34\n"
<< "Simple test of Persistent RAM (ramp) backend" << endl
<< "save and revert facility" << endl << endl;
We assign the filename and open or create the database, filling it with our test data.
const char* kDatabaseName = "ooftst34.db"; const char* kExistsName = kDatabaseName;
if (dbConnect::fileExists(kExistsName)) {
theDB.openConnection(kDatabaseName);
}
else {
theDB.newConnection(kDatabaseName);
Patients.AddTestData();
Now we save() the database so we have a database on disk from which to Revert.
Testing: function save()
theDB.save(); }
We start by printing the initial condition of the database.
cout << theDB;
Then we set a search selection based on the PatientNo field, finding a specific single record, then print it out.
Patients.search(Patients.PatientNo==3); cout << "Finding Patient No 3 : " << Patients << endl;
Now we change a field in this record. Then reprint the record so we can see the change.
cout << "Changing name: " << endl; Patients.LastName = "Whatnot"; Patients.saveRecord(); cout << Patients << endl << endl;
Now we restore the original condition of the database by using the revert() function. Then print out the database to show that it is as it was before the change.
Testing: function revert()
theDB.revert(); cout << "After revert\n" << theDB << endl << endl;
cout << "Test Completed" << endl;
return EXIT_SUCCESS; }
(c) Copyright A.D. Software 1994-2000 (All Rights Reserved).
Last Updated: 9th September 2001