#include "packers.hh" // Include the header definition for // the common interface declaration // for the distributed class #include "Buffer.h" // Provide Support for Buffer Class #include // Provide Support for IO handling /////////////////////////////////////// //Function: main //Author: Dean Thompson //Created: 3rd August 1996 //Last Modified: 4th October 1996 //Description: This routine is // responsible for conducting the // test by doing the following: // // * Creating two objects // * Binding to two servers // * Setting the data up into the // objects // * Passing the data between the // the objects 10,000 times // * Print the contents out to the // screen // // * (Standard Implementation) /////////////////////////////////////// int main() { Packers_var aPackerVar,bPackerVar; // CORBA variables designed to // manage pointers to objects // which are "bound" to a server short aShort,bShort; // Declare a local variable which is // used to set the short data member long aLong,bLong; // Declare a local variable which is // used to set the long data member unsigned short aUnsignedShort; // Declare a local variable which is // used to set the unsigned short // data member unsigned long aUnsignedLong; // Declare a local variable which is // used to set the unsigned long // data member float aFloat,bFloat // Declare a local variable which is // used to set the float data member double aDouble,bDouble; // Declare a local variable which is // used to set the double data member char aCharacter; // Declare a local variable which is // used to set the character data // member CORBA::Boolean aBoolean; // Declare a local variable which is // used to set the boolean data // member CORBA::string aString; // Declare a local variable which is // used to set the character array // data member aString = CORBA::string_alloc(1000); // Allocate memory for the character // array aPackerVar = Packers::_bind(); // Make contact with one server bPackerVar = Packers::_bind(":ObjectStore2","firefly.sd.monash.edu.au"); // Make contact with a second server // located on "firefly.sd" aLong = -2100000000; // Set the local "long" variable bLong = -2100000000; aUnsignedLong = 4200000000; // Set the local "unsigned long" // variable aUnsignedShort = 65535; // Set the local "unsigned short" // variable aFloat = -65545.57; // Set the local "float" variable bFloat = -65545.57; aDouble = 6000; // Set the local "double" variable bDouble = 6000; aCharacter = 'M'; // Set the local "character" variable aBoolean = 1; // Set the local "boolean" variable strcpy(aString, "Data Transfer Test for Communications Data........"); // Set the local "character array" // variable for (int i=0;i<10000;i++) // Setting up the looping construct // for 10,000 iterations { try // Make all the CORBA calls with the // safety of a "try" block to "catch" // any errors { cout << "Iteration #" << i+1 << "." << endl; // Report the number of the iteration // that we are currently on aShort = i+1; // Set the local "short" variable to // the current iteration bShort = i+1; aPackerVar->defaultSave(aShort, aLong, aUnsignedShort, aUnsignedLong, aFloat, aDouble, aCharacter, aBoolean, aString, bFloat, bDouble, bShort, bLong); // Pass all the local data to the // first object and get that object // to store the data aPackerVar->defaultLoad(aShort, aLong, aUnsignedShort, aUnsignedLong, aFloat, aDouble, aCharacter, aBoolean, aString, bFloat, bDouble, bShort, bLong); // Get all the data back from the // first object that we connected to bPackerVar->defaultSave(aShort, aLong, aUnsignedShort, aUnsignedLong, aFloat, aDouble, aCharacter, aBoolean, aString, bFloat, bDouble, bShort, bLong); // Take all the data that we received // from the first object and use it // as input data for the second // object // To make sure that the data was sent to the second object correctly // the client request all that data to be sent back and displayed to the // screen cout << "Reconstructed short: " << bPackerVar->aShort() << "." << endl; // Display the value of the remote object's short cout << "Reconstructed long: " << bPackerVar->aLong() << "." << endl; // Display the value of the remote object's long cout << "Reconstructed unsigned short: " << bPackerVar->aUnsignedShort() << "." << endl; // Display the value of the remote object's unsigned short cout << "Reconstructed unsigned long: " << bPackerVar->aUnsignedLong() << "." << endl; // Display the value of the remote object's unsigned long cout << "Reconstructed float: " << bPackerVar->aFloat() << "." << endl; // Display the value of the remote object's float cout << "Reconstructed double: " << bPackerVar->aDouble() << "." << endl; // Display the value of the remote object's double cout << "Reconstructed character: " << (char) bPackerVar->aCharacter() << "." << endl; // Display the value of the remote object's character cout << "Reconstructed boolean: " << (int) bPackerVar->aBoolean() << "." << endl; // Display the value of the remote object's boolean cout << "Reconstructed string: " << bPacketVar->aString() << "." << endl; // Display the value of the remote object's string after it was // return from the inital object cout << "Reconstructed short: " << bPackerVar->bShort() << "." << endl; // Display the value of the remote object's short cout << "Reconstructed long: " << bPackerVar->bLong() << "." << endl; // Display the value of the remote object's long cout << "Reconstructed float: " << bPackerVar->bFloat() << "." << endl; // Display the value of the remote object's float cout << "Reconstructed double: " << bPackerVar->bDouble() << "." << endl; // Display the value of the remote object's double cout << endl; } catch(CORBA::SystemException &se) // catch any CORBA::SystemException { CORBA::string_free(aString); // De-Allocate any memory that was // allocated cout << "Error" << &se << endl; // Display the data about the // associated error return 1; } } CORBA::string_free(aString); // De-Allocate any memory that was // allocated return 0; }