diff options
author | Matthew Newhook <matthew@zeroc.com> | 2001-11-27 14:09:19 +0000 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2001-11-27 14:09:19 +0000 |
commit | 328b6c574d858e70fbf08c1c956e7dce5743e2cb (patch) | |
tree | 35ac7e84e8ad2c334b1b14699600b813e2775ffd /cpp/src/IceStorm/TopicManagerI.cpp | |
parent | string/string test (diff) | |
download | ice-328b6c574d858e70fbf08c1c956e7dce5743e2cb.tar.bz2 ice-328b6c574d858e70fbf08c1c956e7dce5743e2cb.tar.xz ice-328b6c574d858e70fbf08c1c956e7dce5743e2cb.zip |
Bug fixes. Added name to NoSuchTopic & TopicExists. Attempting to subscribe
to a non-existent topic throws exception.
Diffstat (limited to 'cpp/src/IceStorm/TopicManagerI.cpp')
-rw-r--r-- | cpp/src/IceStorm/TopicManagerI.cpp | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/cpp/src/IceStorm/TopicManagerI.cpp b/cpp/src/IceStorm/TopicManagerI.cpp index 2fe5fd032c0..7a282c28baa 100644 --- a/cpp/src/IceStorm/TopicManagerI.cpp +++ b/cpp/src/IceStorm/TopicManagerI.cpp @@ -44,7 +44,9 @@ TopicManagerI::create(const string& name) if (_topicIMap.find(name) != _topicIMap.end()) { - throw TopicExists(); + TopicExists ex; + ex.name = name; + throw ex; } if (_traceLevels->topicMgr > 0) @@ -73,7 +75,9 @@ TopicManagerI::retrieve(const string& name) if (_topicIMap.find(name) != _topicIMap.end()) return TopicPrx::uncheckedCast(_adapter->createProxy(name)); - throw NoSuchTopic(); + NoSuchTopic ex; + ex.name = name; + throw ex; } // @@ -132,7 +136,28 @@ TopicManagerI::subscribe(const string& id, const QoS& qos, const StringSeq& topi _communicator->getLogger()->trace(_traceLevels->topicMgrCat, s.str()); } - for (StringSeq::const_iterator i = topics.begin() ; i != topics.end() ; ++i) + // + // First scan the set of topics to ensure that each exists. + // + // TODO: This could be slightly optimized by remembering the + // TopicIPtr's so that the list doesn't need to scanned again. + // + StringSeq::const_iterator i; + for (i = topics.begin() ; i != topics.end() ; ++i) + { + TopicIMap::iterator elem = _topicIMap.find(*i); + if (elem == _topicIMap.end()) + { + NoSuchTopic ex; + ex.name = *i; + throw ex; + } + } + + // + // Now subscribe to each Topic. + // + for (i = topics.begin() ; i != topics.end() ; ++i) { TopicIMap::iterator elem = _topicIMap.find(*i); if (elem != _topicIMap.end()) |