diff options
author | Mark Spruiell <mes@zeroc.com> | 2005-06-01 23:28:22 +0000 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2005-06-01 23:28:22 +0000 |
commit | 4d37cb10011490fc9929c5cd1c8f672b4eebf651 (patch) | |
tree | ef71347e626d7a637286161b319edf406f9f04f4 /cpp/demo/Ice/value/Client.cpp | |
parent | Fix for bug 346. (diff) | |
download | ice-4d37cb10011490fc9929c5cd1c8f672b4eebf651.tar.bz2 ice-4d37cb10011490fc9929c5cd1c8f672b4eebf651.tar.xz ice-4d37cb10011490fc9929c5cd1c8f672b4eebf651.zip |
changing to use Ice::Application to fix bug 315
Diffstat (limited to 'cpp/demo/Ice/value/Client.cpp')
-rw-r--r-- | cpp/demo/Ice/value/Client.cpp | 63 |
1 files changed, 23 insertions, 40 deletions
diff --git a/cpp/demo/Ice/value/Client.cpp b/cpp/demo/Ice/value/Client.cpp index 1ec3920d9d1..c6ed3184a08 100644 --- a/cpp/demo/Ice/value/Client.cpp +++ b/cpp/demo/Ice/value/Client.cpp @@ -14,10 +14,28 @@ using namespace std; using namespace Demo; +class ValueClient : public Ice::Application +{ +public: + + virtual int run(int, char*[]); + +private: + + void menu(); +}; + int -run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) +main(int argc, char* argv[]) { - Ice::PropertiesPtr properties = communicator->getProperties(); + ValueClient app; + return app.main(argc, argv, "config"); +} + +int +ValueClient::run(int argc, char* argv[]) +{ + Ice::PropertiesPtr properties = communicator()->getProperties(); const char* refProperty = "Value.Initial"; std::string ref = properties->getProperty(refProperty); if(ref.empty()) @@ -26,7 +44,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) return EXIT_FAILURE; } - Ice::ObjectPrx base = communicator->stringToProxy(ref); + Ice::ObjectPrx base = communicator()->stringToProxy(ref); InitialPrx initial = InitialPrx::checkedCast(base); if(!initial) { @@ -85,7 +103,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) cin.getline(c, 2); Ice::ObjectFactoryPtr factory = new ObjectFactory; - communicator->addObjectFactory(factory, "::Demo::Printer"); + communicator()->addObjectFactory(factory, "::Demo::Printer"); initial->getPrinter(printer, printerProxy); cout << "==> " << printer->message << endl; @@ -127,7 +145,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) << "[press enter]\n"; cin.getline(c, 2); - communicator->addObjectFactory(factory, "::Demo::DerivedPrinter"); + communicator()->addObjectFactory(factory, "::Demo::DerivedPrinter"); derivedAsBase = initial->getDerivedPrinter(); DerivedPrinterPtr derived = DerivedPrinterPtr::dynamicCast(derivedAsBase); @@ -178,38 +196,3 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) return EXIT_SUCCESS; } - -int -main(int argc, char* argv[]) -{ - int status; - Ice::CommunicatorPtr communicator; - - try - { - Ice::PropertiesPtr properties = Ice::createProperties(); - properties->load("config"); - communicator = Ice::initializeWithProperties(argc, argv, properties); - status = run(argc, argv, communicator); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } - - if(communicator) - { - try - { - communicator->destroy(); - } - catch(const Ice::Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } - } - - return status; -} |