% Remember to use the lgrind style \File{octet.cc},{12:12},{Oct 24 1996} \L{\LB{\K{\#include}_\S{}\"packers.hh\"\SE{}____________________\C{}\1\1_ Include the header definition for}} \CE{}\L{\LB{_________________________________________\C{}\1\1_ the common interface declaration}} \CE{}\L{\LB{_________________________________________\C{}\1\1_ for the distributed class}} \CE{}\L{\LB{\K{\#include}_\S{}\"Buffer.h\"\SE{}______________________\C{}\1\1_ Provide Support for Buffer Class}} \CE{}\L{\LB{\K{\#include}_\<\V{iostream}.\V{h}\>____________________\C{}\1\1_ Provide Support for IO handling }} \CE{}\L{\LB{}} \L{\LB{\C{}\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1}} \CE{}\L{\LB{\C{}\1\1\V{Function}Function: main }} \CE{}\L{\LB{\C{}\1\1\V{Author}Author: Dean Thompson }} \CE{}\L{\LB{\C{}\1\1\V{Created}Created: 3rd August 1996 }} \CE{}\L{\LB{\C{}\1\1\V{Last}Last Modified: 4th October 1996 }} \CE{}\L{\LB{\C{}\1\1\V{Description}Description: This routine is }} \CE{}\L{\LB{\C{}\1\1_ responsible for conducting the }} \CE{}\L{\LB{\C{}\1\1_ test by doing the following: }} \CE{}\L{\LB{\C{}\1\1_ }} \CE{}\L{\LB{\C{}\1\1_ \* Creating two objects }} \CE{}\L{\LB{\C{}\1\1_ \* Binding to two servers }} \CE{}\L{\LB{\C{}\1\1_ \* Setting the data up into the }} \CE{}\L{\LB{\C{}\1\1_ objects }} \CE{}\L{\LB{\C{}\1\1_ \* Passing the data between the }} \CE{}\L{\LB{\C{}\1\1_ the objects 10,000 times }} \CE{}\L{\LB{\C{}\1\1_ \* Print the contents out to the}} \CE{}\L{\LB{\C{}\1\1_ screen }} \CE{}\L{\LB{\C{}\1\1_ }} \CE{}\L{\LB{\C{}\1\1_ \* (Octet Implementation) }} \CE{}\L{\LB{\C{}\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1}} \CE{}\L{\LB{}} \L{\LB{\K{int}_\V{main}()}} \L{\LB{\{}} \L{\LB{__\V{Packers\_var}_\V{aPackerVar},\V{bPackerVar};_____\C{}\1\1_ CORBA variables designed to }} \CE{}\L{\LB{_________________________________________\C{}\1\1_ manage pointers to objects }} \CE{}\L{\LB{_________________________________________\C{}\1\1_ which are \"bound\" to a server }} \CE{}\L{\LB{}} \L{\LB{__\V{byteStream}_\V{aByte};______________________\C{}\1\1_ Declare a local variable which is}} \CE{}\L{\LB{_________________________________________\C{}\1\1_ used to hold the octet stream}} \CE{}\L{\LB{_________________________________________\C{}\1\1_ when it is returned back from }} \CE{}\L{\LB{_________________________________________\C{}\1\1_ the object after the data has}} \CE{}\L{\LB{_________________________________________\C{}\1\1_ been committed into it }} \CE{}\L{\LB{}} \L{\LB{__\V{aPackerVar}_=_\V{Packers}::\V{\_bind}();_________\C{}\1\1_ Make contact with one server}} \CE{}\L{\LB{__\V{bPackerVar}_=_\V{Packers}::\V{\_bind}(\S{}\":ObjectStore2\"\SE{},\S{}\"ant.sd.monash.edu.au\"\SE{});}} \L{\LB{_________________________________________\C{}\1\1_ Make contact with a second server}} \CE{}\L{\LB{_________________________________________\C{}\1\1_ located on \"firefly.sd\" }} \CE{}\L{\LB{}} \L{\LB{__\V{aPackerVar}\-\!\>\V{aLong}(\-2100000000);________\C{}\1\1_ Transmit \"long\" value to remote }} \CE{}\L{\LB{_________________________________________\C{}\1\1_ object}} \CE{}\L{\LB{}} \L{\LB{__\V{aPackerVar}\-\!\>\V{aUnsignedLong}(4200000000);_\C{}\1\1_ Transmit \"unsigned long\" value to}} \CE{}\L{\LB{_________________________________________\C{}\1\1_ remote object}} \CE{}\L{\LB{}} \L{\LB{__\V{aPackerVar}\-\!\>\V{aUnsignedShort}(65535);_____\C{}\1\1_ Transmit \"unsigned short\" value to}} \CE{}\L{\LB{_________________________________________\C{}\1\1_ remote object}} \CE{}\L{\LB{}} \L{\LB{__\V{aPackerVar}\-\!\>\V{aFloat}(\-65545.57);_________\C{}\1\1_ Transmit \"float\" value to remote}} \CE{}\L{\LB{_________________________________________\C{}\1\1_ object}} \CE{}\L{\LB{}} \L{\LB{__\V{aPackerVar}\-\!\>\V{aDouble}(6000);_____________\C{}\1\1_ Transmit \"double\" value to remote}} \CE{}\L{\LB{_________________________________________\C{}\1\1_ object}} \CE{}\L{\LB{}} \L{\LB{__\V{aPackerVar}\-\!\>\V{aCharacter}(\S{}\'M\'\SE{});___________\C{}\1\1_ Transmit \"character\" value to}} \CE{}\L{\LB{_________________________________________\C{}\1\1_ remote object}} \CE{}\L{\LB{}} \L{\LB{__\V{aPackerVar}\-\!\>\V{aBoolean}(1);_______________\C{}\1\1_ Transmit \"boolean\" value to remote}} \CE{}\L{\LB{_________________________________________\C{}\1\1_ object}} \CE{}\L{\LB{}} \L{\LB{__\V{aPackerVar}\-\!\>\V{bFloat}(\-65545.57);}} \L{\LB{__\V{aPackerVar}\-\!\>\V{bDouble}(6000);}} \L{\LB{__\V{aPackerVar}\-\!\>\V{bLong}(\-2100000000);}} \L{\LB{}} \L{\LB{__\V{aPackerVar}\-\!\>\V{aString}(\S{}\"Data_Transfer_Test_for_Communications_Data.\,.\,.\,.\,.\,.\,.\,.\,.\"\SE{});_\C{}\1\1_ Transmit \"character array\"}} \CE{}\L{\LB{_________________________________________\C{}\1\1_ to remote object}} \CE{}\L{\LB{}} \L{\LB{__\K{for}_(\K{int}_\V{i}=0;\V{i}\<10000;\V{i}++)______________\C{}\1\1_ Setting up the looping construct}} \CE{}\L{\LB{_________________________________________\C{}\1\1_ for 10,000 iterations}} \CE{}\L{\LB{____\{}} \L{\LB{______\V{try}________________________________\C{}\1\1_ Make all the CORBA calls with the}} \CE{}\L{\LB{}\Tab{8}{_________________________________\C{}\1\1_ safety of a \"try block\" to \"catch\"}} \CE{}\L{\LB{___}\Tab{8}{_________________________________\C{}\1\1_ any errors}} \CE{}\L{\LB{}\Tab{8}{\{}} \L{\LB{}\Tab{8}{__\V{cout}_\<\<_\S{}\"Iteration_\#\"\SE{}_\<\<_\V{i}+1_\<\<_\S{}\".\"\SE{}_\<\<_\V{endl};}} \L{\LB{}\Tab{8}{_________________________________\C{}\1\1_ Report the number of the iteration}} \CE{}\L{\LB{}\Tab{8}{_________________________________\C{}\1\1_ that we are currently on }} \CE{}\L{\LB{}} \L{\LB{}\Tab{8}{__\V{aPackerVar}\-\!\>\V{aShort}(\V{i}+1);_______\C{}\1\1_ Set the local \"short\" variable to}} \CE{}\L{\LB{}\Tab{8}{_________________________________\C{}\1\1_ the current iteration}} \CE{}\L{\LB{}} \L{\LB{__________\V{aPackerVar}\-\!\>\V{bShort}(\V{i}+1);}} \L{\LB{}} \L{\LB{}\Tab{8}{__\V{aPackerVar}\-\!\>\V{saveObject}();______\C{}\1\1_ Issue the request to the remote}} \CE{}\L{\LB{}\Tab{8}{_________________________________\C{}\1\1_ object to flatten itself into a}} \CE{}\L{\LB{}\Tab{8}{_________________________________\C{}\1\1_ byteStream}} \CE{}\L{\LB{}} \L{\LB{}\Tab{8}{__\V{aByte}_=_\*(\V{aPackerVar}\-\!\>\V{aByteStream}());}} \L{\LB{}\Tab{8}{_________________________________\C{}\1\1_ Obtain the byteStream from the }} \CE{}\L{\LB{}\Tab{8}{_________________________________\C{}\1\1_ remote object}} \CE{}\L{\LB{_}} \L{\LB{}\Tab{8}{__\V{bPackerVar}\-\!\>\V{restoreObject}(\V{aByte});}} \L{\LB{}\Tab{8}{_________________________________\C{}\1\1_ Send the flatten representation of}} \CE{}\L{\LB{}\Tab{8}{_________________________________\C{}\1\1_ the first object to the second }} \CE{}\L{\LB{}\Tab{8}{_________________________________\C{}\1\1_ object for re-construction }} \CE{}\L{\LB{}} \L{\LB{_____\C{}\1\1_ To make sure that the data was sent to the second object correctly}} \CE{}\L{\LB{_____\C{}\1\1_ the client request all that data to be sent back and displayed to the}} \CE{}\L{\LB{_____\C{}\1\1_ screen}} \CE{}\L{\LB{}} \L{\LB{}\Tab{8}{__\V{cout}_\<\<_\S{}\"Reconstructed_short:_\"\SE{}_\<\<_\V{bPackerVar}\-\!\>\V{aShort}()_}} \L{\LB{_______________\<\<_\S{}\".\"\SE{}_\<\<_\V{endl};}} \L{\LB{______________\C{}\1\1_ Display the value of the remote object\'s short}} \CE{}\L{\LB{_}} \L{\LB{}\Tab{8}{__\V{cout}_\<\<_\S{}\"Reconstructed_long:_\"\SE{}_\<\<_\V{bPackerVar}\-\!\>\V{aLong}()_\<\<_\S{}\".\"\SE{}_\<\<_\V{endl};}} \L{\LB{______________\C{}\1\1_ Display the value of the remote object\'s long}} \CE{}\L{\LB{}} \L{\LB{}\Tab{8}{__\V{cout}_\<\<_\S{}\"Reconstructed_unsigned_short:_\"\SE{}_}} \L{\LB{_______________\<\<_\V{bPackerVar}\-\!\>\V{aUnsignedShort}()_\<\<_\S{}\".\"\SE{}_\<\<_\V{endl};}} \L{\LB{___________\C{}\1\1_ Display the value of the remote object\'s unsigned short }} \CE{}\L{\LB{}} \L{\LB{}\Tab{8}{__\V{cout}_\<\<_\S{}\"Reconstructed_unsigned_long:_\"\SE{}_}} \L{\LB{_______________\<\<_\V{bPackerVar}\-\!\>\V{aUnsignedLong}()_\<\<_\S{}\".\"\SE{}_\<\<_\V{endl};}} \L{\LB{___________\C{}\1\1_ Display the value of the remote object\'s unsigned long}} \CE{}\L{\LB{_____}} \L{\LB{}\Tab{8}{__\V{cout}_\<\<_\S{}\"Reconstructed_float:_\"\SE{}_\<\<_\V{bPackerVar}\-\!\>\V{aFloat}()_}} \L{\LB{_______________\<\<_\S{}\".\"\SE{}_\<\<_\V{endl};}} \L{\LB{___________\C{}\1\1_ Display the value of the remote object\'s float}} \CE{}\L{\LB{_____}} \L{\LB{}\Tab{8}{__\V{cout}_\<\<_\S{}\"Reconstructed_double:_\"\SE{}_\<\<_\V{bPackerVar}\-\!\>\V{aDouble}()_}} \L{\LB{_______________\<\<_\S{}\".\"\SE{}_\<\<_\V{endl};}} \L{\LB{___________\C{}\1\1_ Display the value of the remote object\'s double}} \CE{}\L{\LB{_____}} \L{\LB{}\Tab{8}{__\V{cout}_\<\<_\S{}\"Reconstructed_character:_\"\SE{}_}} \L{\LB{_______________\<\<_(\K{char})_\V{bPackerVar}\-\!\>\V{aCharacter}()_\<\<_\S{}\".\"\SE{}_\<\<_\V{endl};}} \L{\LB{__________\C{}\1\1_ Display the value of the remote object\'s character}} \CE{}\L{\LB{_____}} \L{\LB{}\Tab{8}{__\V{cout}_\<\<_\S{}\"Reconstructed_boolean:_\"\SE{}_}} \L{\LB{_______________\<\<_(\K{int})_\V{bPackerVar}\-\!\>\V{aBoolean}()_\<\<_\S{}\".\"\SE{}_\<\<_\V{endl};}} \L{\LB{__________\C{}\1\1_ Display the value of the remote object\'s boolean}} \CE{}\L{\LB{}\Tab{8}{__}} \L{\LB{}\Tab{8}{__\V{cout}_\<\<_\S{}\"Reconstructed_string:_\"\SE{}_\<\<_\V{bPackerVar}\-\!\>\V{aString}()_\<\<_\S{}\".\"\SE{}_}} \L{\LB{_______________\<\<_\V{endl};}} \L{\LB{__________\C{}\1\1_ Display the value of the remote object\'s string after it was}} \CE{}\L{\LB{__________\C{}\1\1_ return from the inital object}} \CE{}\L{\LB{}} \L{\LB{}\Tab{8}{__\V{cout}_\<\<_\S{}\"Reconstructed_short:_\"\SE{}_\<\<_\V{bPackerVar}\-\!\>\V{bShort}()_}} \L{\LB{_______________\<\<_\S{}\".\"\SE{}_\<\<_\V{endl};}} \L{\LB{______________\C{}\1\1_ Display the value of the remote object\'s short}} \CE{}\L{\LB{_}} \L{\LB{}\Tab{8}{__\V{cout}_\<\<_\S{}\"Reconstructed_long:_\"\SE{}_\<\<_\V{bPackerVar}\-\!\>\V{bLong}()_\<\<_\S{}\".\"\SE{}_\<\<_\V{endl};}} \L{\LB{______________\C{}\1\1_ Display the value of the remote object\'s long}} \CE{}\L{\LB{}} \L{\LB{}\Tab{8}{__\V{cout}_\<\<_\S{}\"Reconstructed_float:_\"\SE{}_\<\<_\V{bPackerVar}\-\!\>\V{bFloat}()_}} \L{\LB{_______________\<\<_\S{}\".\"\SE{}_\<\<_\V{endl};}} \L{\LB{______________\C{}\1\1_ Display the value of the remote object\'s short}} \CE{}\L{\LB{_}} \L{\LB{}\Tab{8}{__\V{cout}_\<\<_\S{}\"Reconstructed_double:_\"\SE{}_\<\<_\V{bPackerVar}\-\!\>\V{bDouble}()_\<\<_\S{}\".\"\SE{}_\<\<_\V{endl};}} \L{\LB{______________\C{}\1\1_ Display the value of the remote object\'s long}} \CE{}\L{\LB{}} \L{\LB{}\Tab{8}{__\V{cout}_\<\<_\V{endl};}} \L{\LB{}} \L{\LB{}\Tab{8}{\}}} \L{\LB{}} \L{\LB{______\V{catch}(\V{CORBA}::\V{SystemException}_\&\V{se})___\C{}\1\1_ catch any CORBA::SystemException}} \CE{}\L{\LB{______\{}} \L{\LB{_______\V{cout}_\<\<_\S{}\"Error\"\SE{}_\<\<_\&\V{se}_\<\<_\V{endl};____\C{}\1\1_ Display the data about the }} \CE{}\L{\LB{_________________________________________\C{}\1\1_ associated error}} \CE{}\L{\LB{_______\K{return}_1;}} \L{\LB{______\}}} \L{\LB{____\}}} \L{\LB{__\K{return}_0;}} \L{\LB{}}