#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 // // * (Octet Implementation) /////////////////////////////////////// int main() { Packers_var aPackerVar,bPackerVar; // CORBA variables designed to // manage pointers to objects // which are "bound" to a server byteStream aByte; // Declare a local variable which is // used to hold the octet stream // when it is returned back from // the object after the data has // been committed into it aPackerVar = Packers::_bind(); // Make contact with one server bPackerVar = Packers::_bind(":ObjectStore2","ant.sd.monash.edu.au"); // Make contact with a second server // located on "firefly.sd" aPackerVar->aLong(-2100000000); // Transmit "long" value to remote // object aPackerVar->aUnsignedLong(4200000000); // Transmit "unsigned long" value to // remote object aPackerVar->aUnsignedShort(65535); // Transmit "unsigned short" value to // remote object aPackerVar->aFloat(-65545.57); // Transmit "float" value to remote // object aPackerVar->aDouble(6000); // Transmit "double" value to remote // object aPackerVar->aCharacter('M'); // Transmit "character" value to // remote object aPackerVar->aBoolean(1); // Transmit "boolean" value to remote // object aPackerVar->bFloat(-65545.57); aPackerVar->bDouble(6000); aPackerVar->bLong(-2100000000); aPackerVar->aString("Data Transfer Test for Communications Data........."); // Transmit "character array" // to remote object 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 aPackerVar->aShort(i+1); // Set the local "short" variable to // the current iteration aPackerVar->bShort(i+1); aPackerVar->saveObject(); // Issue the request to the remote // object to flatten itself into a // byteStream aByte = *(aPackerVar->aByteStream()); // Obtain the byteStream from the // remote object bPackerVar->restoreObject(aByte); // Send the flatten representation of // the first object to the second // object for re-construction // 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: " << bPackerVar->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 short cout << "Reconstructed double: " << bPackerVar->bDouble() << "." << endl; // Display the value of the remote object's long cout << endl; } catch(CORBA::SystemException &se) // catch any CORBA::SystemException { cout << "Error" << &se << endl; // Display the data about the // associated error return 1; } } return 0;