00001
00002
00003 #include "LargeTemporaryReturnType.h"
00004 #include <ipc/core.h>
00005 #include <unistd.h>
00006
00007 void sl(const unsigned int s) {
00008 std::cout << "Sleeping for " << s << " seconds" << std::endl;
00009 sleep(s);
00010 };
00011
00012 void createATemporaryReturnTypeAndDoStuff() {
00013 std::cout << "Making a temporaryreturntype ..." << std::endl;
00014 LargeTemporaryReturnType & largeTemporaryReturnType = *(new LargeTemporaryReturnType);
00015 std::cout << "... finishing making a temporaryreturntype" << std::endl;
00016 sl(1);
00017 {
00018
00019 std::cout << "Getting a reference to the temporaryreturntype object" << std::endl;
00020 Stew::TemporaryReturnType_var temporaryreturntype = largeTemporaryReturnType._this();
00021 sl(1);
00022 };
00023
00024 {
00025
00026 std::cout << "Getting a different reference to the temporaryreturntype object" << std::endl;
00027 Stew::TemporaryReturnType_var temporaryreturntype = largeTemporaryReturnType._this();
00028 sl(1);
00029
00030 std::cout << "Calling endLifeOfServant on the reference" << std::endl;
00031 temporaryreturntype->deleteServant();
00032
00033 sl(1);
00034 };
00035
00036 };
00037
00038 int main(int argc, char * argv[]) {
00039 std::cout << "This program demonstrates how to use an object that will live only for a short time (eg a return type) that will not be published in the IPC::Partition index." << std::endl;
00040 std::cout << "Initialising IPC ..." << std::endl;
00041 IPCCore::init(argc, argv);
00042
00043
00044 createATemporaryReturnTypeAndDoStuff();
00045
00046 std::cout << "Bye" << std::endl;
00047 };