diff options
author | Marc Laukien <marc@zeroc.com> | 2001-11-30 19:17:29 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2001-11-30 19:17:29 +0000 |
commit | f9eda6f68a8251fb312e715f5eda443b56925657 (patch) | |
tree | 0ad697d27e22eeb42804ef7fd2b6b7cb53f36a34 /cpp/demo/IceStorm/clock/Subscriber.cpp | |
parent | Added DBCursor to the Freeze module. (diff) | |
download | ice-f9eda6f68a8251fb312e715f5eda443b56925657.tar.bz2 ice-f9eda6f68a8251fb312e715f5eda443b56925657.tar.xz ice-f9eda6f68a8251fb312e715f5eda443b56925657.zip |
converted some stuff to use Application.h
Diffstat (limited to 'cpp/demo/IceStorm/clock/Subscriber.cpp')
-rw-r--r-- | cpp/demo/IceStorm/clock/Subscriber.cpp | 68 |
1 files changed, 25 insertions, 43 deletions
diff --git a/cpp/demo/IceStorm/clock/Subscriber.cpp b/cpp/demo/IceStorm/clock/Subscriber.cpp index 02663318c28..859a21b17dc 100644 --- a/cpp/demo/IceStorm/clock/Subscriber.cpp +++ b/cpp/demo/IceStorm/clock/Subscriber.cpp @@ -8,33 +8,49 @@ // // ********************************************************************** -#include <Ice/Ice.h> +#include <Ice/Application.h> #include <IceStorm/IceStorm.h> #include <ClockI.h> +using namespace Ice; +using namespace IceStorm; using namespace std; +class Subscriber : public Application +{ +public: + + virtual int run(int, char*[]); +}; + +int +main(int argc, char* argv[]) +{ + Subscriber app; + return app.main(argc, argv, "config"); +} + int -run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) +Subscriber::run(int argc, char* argv[]) { - Ice::PropertiesPtr properties = communicator->getProperties(); + Ice::PropertiesPtr properties = communicator()->getProperties(); const char* refProperty = "IceStorm.TopicManager"; std::string ref = properties->getProperty(refProperty); if (ref.empty()) { - cerr << argv[0] << ": property `" << refProperty << "' not set" << endl; + cerr << appName() << ": property `" << refProperty << "' not set" << endl; return EXIT_FAILURE; } - Ice::ObjectPrx base = communicator->stringToProxy(ref); + Ice::ObjectPrx base = communicator()->stringToProxy(ref); IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(base); if (!manager) { - cerr << argv[0] << ": invalid object reference" << endl; + cerr << appName() << ": invalid object reference" << endl; return EXIT_FAILURE; } - Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("ClockAdapter", "tcp"); + Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapterWithEndpoints("ClockAdapter", "tcp"); Ice::ObjectPtr clock = new ClockI(); const char* id = "events#time"; adapter->add(clock, id); @@ -60,46 +76,12 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) } catch(const IceStorm::NoSuchTopic& e) { - cerr << argv[0] << ": NoSuchTopic: " << e.name << endl; + cerr << appName() << ": NoSuchTopic: " << e.name << endl; return EXIT_FAILURE; } adapter->activate(); - communicator->waitForShutdown(); + communicator()->waitForShutdown(); return EXIT_SUCCESS; } - -int -main(int argc, char* argv[]) -{ - int status; - Ice::CommunicatorPtr communicator; - - try - { - Ice::PropertiesPtr properties = Ice::createPropertiesFromFile(argc, argv, "config"); - communicator = Ice::initializeWithProperties(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; -} |