diff options
author | Bernard Normier <bernard@zeroc.com> | 2007-02-01 17:09:49 +0000 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2007-02-01 17:09:49 +0000 |
commit | abada90e3f84dc703b8ddc9efcbed8a946fadead (patch) | |
tree | 2c6f9dccd510ea97cb927a7bd635422efaae547a /cpp/test/IceStorm/single/Subscriber.cpp | |
parent | removing trace message (diff) | |
download | ice-abada90e3f84dc703b8ddc9efcbed8a946fadead.tar.bz2 ice-abada90e3f84dc703b8ddc9efcbed8a946fadead.tar.xz ice-abada90e3f84dc703b8ddc9efcbed8a946fadead.zip |
Expanded tabs into spaces
Diffstat (limited to 'cpp/test/IceStorm/single/Subscriber.cpp')
-rw-r--r-- | cpp/test/IceStorm/single/Subscriber.cpp | 238 |
1 files changed, 119 insertions, 119 deletions
diff --git a/cpp/test/IceStorm/single/Subscriber.cpp b/cpp/test/IceStorm/single/Subscriber.cpp index b1857119707..88d28a4e21e 100644 --- a/cpp/test/IceStorm/single/Subscriber.cpp +++ b/cpp/test/IceStorm/single/Subscriber.cpp @@ -23,10 +23,10 @@ class SingleI : public Single, public IceUtil::Monitor<IceUtil::Mutex> public: SingleI(const CommunicatorPtr& communicator, const string& name) : - _communicator(communicator), - _name(name), - _count(0), - _last(0) + _communicator(communicator), + _name(name), + _count(0), + _last(0) { } @@ -34,64 +34,64 @@ public: event(int i, const Current& current) { - if((_name == "default" || _name == "oneway" || _name == "batch" || _name == "datagram" || - _name == "batch datagram") && current.requestId != 0) - { - cerr << endl << "expected oneway request"; - test(false); - } - else if((_name == "twoway" || _name == "twoway ordered") && current.requestId == 0) - { - cerr << endl << "expected twoway request"; - } - if(_name == "twoway ordered" && i != _last) - { - cerr << endl << "received unordered event for `" << _name << "': " << i << " " << _last; - test(false); - } - if((_name == "datagram" || _name == "batch datagram") && current.con->type() != "udp") - { - cerr << endl << "expected datagram to be received over udp"; - test(false); - } - Lock sync(*this); - ++_last; - if(++_count == 1000) - { - notify(); - } + if((_name == "default" || _name == "oneway" || _name == "batch" || _name == "datagram" || + _name == "batch datagram") && current.requestId != 0) + { + cerr << endl << "expected oneway request"; + test(false); + } + else if((_name == "twoway" || _name == "twoway ordered") && current.requestId == 0) + { + cerr << endl << "expected twoway request"; + } + if(_name == "twoway ordered" && i != _last) + { + cerr << endl << "received unordered event for `" << _name << "': " << i << " " << _last; + test(false); + } + if((_name == "datagram" || _name == "batch datagram") && current.con->type() != "udp") + { + cerr << endl << "expected datagram to be received over udp"; + test(false); + } + Lock sync(*this); + ++_last; + if(++_count == 1000) + { + notify(); + } } virtual void waitForEvents() { - Lock sync(*this); - cout << "testing " << _name << " reliability... " << flush; - bool datagram = _name == "datagram" || _name == "batch datagram"; - IceUtil::Time timeout = (datagram) ? IceUtil::Time::seconds(5) : IceUtil::Time::seconds(20); - while(_count < 1000) - { - if(!timedWait(timeout)) - { - if(datagram && _count > 0) - { - if(_count < 100) - { - cout << "[" << _count << "/1000: This may be an error!!]"; - } - else - { - cout << "[" << _count << "/1000] "; - } - break; - } - else - { - test(false); - } - } - } - cout << "ok" << endl; + Lock sync(*this); + cout << "testing " << _name << " reliability... " << flush; + bool datagram = _name == "datagram" || _name == "batch datagram"; + IceUtil::Time timeout = (datagram) ? IceUtil::Time::seconds(5) : IceUtil::Time::seconds(20); + while(_count < 1000) + { + if(!timedWait(timeout)) + { + if(datagram && _count > 0) + { + if(_count < 100) + { + cout << "[" << _count << "/1000: This may be an error!!]"; + } + else + { + cout << "[" << _count << "/1000] "; + } + break; + } + else + { + test(false); + } + } + } + cout << "ok" << endl; } private: @@ -112,16 +112,16 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) string managerProxy = properties->getProperty(managerProxyProperty); if(managerProxy.empty()) { - cerr << argv[0] << ": property `" << managerProxyProperty << "' is not set" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": property `" << managerProxyProperty << "' is not set" << endl; + return EXIT_FAILURE; } ObjectPrx base = communicator->stringToProxy(managerProxy); IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(base); if(!manager) { - cerr << argv[0] << ": `" << managerProxy << "' is not running" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": `" << managerProxy << "' is not running" << endl; + return EXIT_FAILURE; } ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("SingleAdapter", "default:udp"); @@ -133,8 +133,8 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) } catch(const IceStorm::NoSuchTopic& e) { - cerr << argv[0] << ": NoSuchTopic: " << e.name << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": NoSuchTopic: " << e.name << endl; + return EXIT_FAILURE; } // @@ -145,84 +145,84 @@ run(int argc, char* argv[], const CommunicatorPtr& communicator) // First we use the old deprecated API. // { - subscribers.push_back(new SingleI(communicator, "default")); - topic->subscribe(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())); + subscribers.push_back(new SingleI(communicator, "default")); + topic->subscribe(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())); } { - subscribers.push_back(new SingleI(communicator, "oneway")); - IceStorm::QoS qos; - qos["reliability"] = "oneway"; - topic->subscribe(qos, adapter->addWithUUID(subscribers.back())); + subscribers.push_back(new SingleI(communicator, "oneway")); + IceStorm::QoS qos; + qos["reliability"] = "oneway"; + topic->subscribe(qos, adapter->addWithUUID(subscribers.back())); } { - subscribers.push_back(new SingleI(communicator, "twoway")); - IceStorm::QoS qos; - qos["reliability"] = "twoway"; - topic->subscribe(qos, adapter->addWithUUID(subscribers.back())); + subscribers.push_back(new SingleI(communicator, "twoway")); + IceStorm::QoS qos; + qos["reliability"] = "twoway"; + topic->subscribe(qos, adapter->addWithUUID(subscribers.back())); } { - subscribers.push_back(new SingleI(communicator, "batch")); - IceStorm::QoS qos; - qos["reliability"] = "batch"; - topic->subscribe(qos, adapter->addWithUUID(subscribers.back())); + subscribers.push_back(new SingleI(communicator, "batch")); + IceStorm::QoS qos; + qos["reliability"] = "batch"; + topic->subscribe(qos, adapter->addWithUUID(subscribers.back())); } { - subscribers.push_back(new SingleI(communicator, "twoway ordered")); // Ordered - IceStorm::QoS qos; - qos["reliability"] = "twoway ordered"; - topic->subscribe(qos, adapter->addWithUUID(subscribers.back())); + subscribers.push_back(new SingleI(communicator, "twoway ordered")); // Ordered + IceStorm::QoS qos; + qos["reliability"] = "twoway ordered"; + topic->subscribe(qos, adapter->addWithUUID(subscribers.back())); } { - subscribers.push_back(new SingleI(communicator, "datagram")); - IceStorm::QoS qos; - qos["reliability"] = "oneway"; - topic->subscribe(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())->ice_datagram()); + subscribers.push_back(new SingleI(communicator, "datagram")); + IceStorm::QoS qos; + qos["reliability"] = "oneway"; + topic->subscribe(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())->ice_datagram()); } { - subscribers.push_back(new SingleI(communicator, "batch datagram")); - IceStorm::QoS qos; - qos["reliability"] = "batch"; - topic->subscribe(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())->ice_datagram()); + subscribers.push_back(new SingleI(communicator, "batch datagram")); + IceStorm::QoS qos; + qos["reliability"] = "batch"; + topic->subscribe(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())->ice_datagram()); } // // Next we use the new API call with the new proxy semantics. // { - subscribers.push_back(new SingleI(communicator, "default")); - topic->subscribeAndGetPublisher(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())->ice_oneway()); + subscribers.push_back(new SingleI(communicator, "default")); + topic->subscribeAndGetPublisher(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())->ice_oneway()); } { - subscribers.push_back(new SingleI(communicator, "oneway")); - topic->subscribeAndGetPublisher(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())->ice_oneway()); + subscribers.push_back(new SingleI(communicator, "oneway")); + topic->subscribeAndGetPublisher(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())->ice_oneway()); } { - subscribers.push_back(new SingleI(communicator, "twoway")); - topic->subscribeAndGetPublisher(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())); + subscribers.push_back(new SingleI(communicator, "twoway")); + topic->subscribeAndGetPublisher(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())); } { - subscribers.push_back(new SingleI(communicator, "batch")); - topic->subscribeAndGetPublisher(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())->ice_batchOneway()); + subscribers.push_back(new SingleI(communicator, "batch")); + topic->subscribeAndGetPublisher(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())->ice_batchOneway()); } { - subscribers.push_back(new SingleI(communicator, "twoway ordered")); // Ordered - IceStorm::QoS qos; - qos["reliability"] = "ordered"; - topic->subscribeAndGetPublisher(qos, adapter->addWithUUID(subscribers.back())); + subscribers.push_back(new SingleI(communicator, "twoway ordered")); // Ordered + IceStorm::QoS qos; + qos["reliability"] = "ordered"; + topic->subscribeAndGetPublisher(qos, adapter->addWithUUID(subscribers.back())); } { - subscribers.push_back(new SingleI(communicator, "datagram")); - topic->subscribeAndGetPublisher(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())->ice_datagram()); + subscribers.push_back(new SingleI(communicator, "datagram")); + topic->subscribeAndGetPublisher(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())->ice_datagram()); } { - subscribers.push_back(new SingleI(communicator, "batch datagram")); - topic->subscribeAndGetPublisher(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())->ice_batchDatagram()); + subscribers.push_back(new SingleI(communicator, "batch datagram")); + topic->subscribeAndGetPublisher(IceStorm::QoS(), adapter->addWithUUID(subscribers.back())->ice_batchDatagram()); } adapter->activate(); for(vector<SingleIPtr>::const_iterator p = subscribers.begin(); p != subscribers.end(); ++p) { - (*p)->waitForEvents(); + (*p)->waitForEvents(); } return EXIT_SUCCESS; @@ -236,26 +236,26 @@ main(int argc, char* argv[]) try { - communicator = initialize(argc, argv); - status = run(argc, argv, communicator); + communicator = initialize(argc, argv); + status = run(argc, argv, communicator); } catch(const Exception& ex) { - cerr << ex << endl; - status = EXIT_FAILURE; + cerr << ex << endl; + status = EXIT_FAILURE; } if(communicator) { - try - { - communicator->destroy(); - } - catch(const Exception& ex) - { - cerr << ex << endl; - status = EXIT_FAILURE; - } + try + { + communicator->destroy(); + } + catch(const Exception& ex) + { + cerr << ex << endl; + status = EXIT_FAILURE; + } } return status; |