32 #include <Ice/Object.h>
33 #include <Ice/Proxy.h>
35 #include <IceUtil/Handle.h>
36 #include <IceUtil/Shared.h>
46 class ConnectionRefusedException;
68 using TopicManagerPrx = ::IceInternal::ProxyHandle< ::IceProxy::IceStorm::TopicManager>;
69 using TopicPrx = ::IceInternal::ProxyHandle< ::IceProxy::IceStorm::Topic>;
74 using RegistryPrx = ::IceInternal::ProxyHandle< ::IceProxy::IceGrid::Registry>;
106 public IceUtil::Shared,
128 std::string name =
"",
const std::string topicSuffix =
"");
150 void removeObject(
const std::string& objectName);
160 template <
class ProxyType>
162 const std::string& endpoints = std::string())
164 std::string proxyString = name;
166 if (!endpoints.empty())
168 proxyString += std::string(
":") + endpoints;
171 std::string proxyTypedId =
178 return ProxyType::uncheckedCast(implGetCheckedProxy(proxyTypedId));
180 catch (std::out_of_range& uncheckedProxiesException)
184 Ice::ObjectPrx base = communicator_stringToProxy(proxyString);
190 proxy = ProxyType::checkedCast(base);
191 implSetCheckedProxy(proxyTypedId, proxy);
193 catch (
const Ice::ConnectionRefusedException&)
195 std::stringstream exceptionText;
196 exceptionText <<
"Connection refused for proxy of type '" << GetTypeString<ProxyType>()
197 <<
"': " << name <<
" ProxyString: " << proxyString <<
" Endpoints: " << endpoints << std::endl;
198 throwUserException(exceptionText.str());
203 std::stringstream exceptionText;
204 exceptionText <<
"Invalid Proxy. Searched for: " << name <<
" ProxyString: " << proxyString <<
" Endpoints: " << endpoints << std::endl;
205 throwUserException(exceptionText.str());
211 void throwUserException(std::string
const&
message);
220 template <
class ProxyType>
222 const std::string& endpoints = std::string())
224 return removeProxyFromCache(name,
typeid(
ProxyType).name(), endpoints);
227 bool removeProxyFromCache(
const std::string& name,
228 const std::string& typeName,
229 const std::string& endpoints = std::string());
238 bool removeProxyFromCache(
const Ice::ObjectPrx& proxy);
256 template <
class TopicProxy>
257 TopicProxy
getTopic(
const std::string& topicName,
bool useUDP =
false)
259 Ice::ObjectPrx pub = __getTopic(topicName, useUDP);
260 TopicProxy castTopic = TopicProxy::uncheckedCast(pub);
278 void subscribeTopic(Ice::ObjectPrx subscriber,
279 const std::string& topicName,
bool orderedPublishing =
false);
281 const std::string& topicName,
bool orderedPublishing =
false);
289 void unsubscribeTopic(Ice::ObjectPrx subscriberProxy,
290 const std::string& topicName);
302 void registerObjectDependency(
303 const std::string& registrantName,
304 const std::string& dependencyObjectName);
313 void registerDelayedTopicSubscription(
314 const std::string& registrantName,
315 const std::string& topicName);
323 void registerDelayedTopicRetrieval(
324 const std::string& registrantName,
325 const std::string& topicName);
333 bool isObjectReachable(std::string objectName);
341 template <
typename ProxyType>
342 bool isObjectReachable(std::string objectName);
369 void setName(std::string name);
380 void waitForShutdown();
395 std::string getTopicSuffix()
const;
399 Ice::ObjectPrx communicator_stringToProxy(std::string
const& proxyString);
401 Ice::ObjectPrx __getTopic(
const std::string& topicName,
bool useUDP =
false);
405 struct DependencyObjectEntry:
public IceUtil::Shared
407 DependencyObjectEntry(std::string name, Ice::ObjectPrx proxy) :
416 Ice::ObjectPrx proxy;
423 using TopicList = std::vector<std::string>;
429 void subscribeTopics(Ice::ObjectPrx subscriber,
430 const TopicList& topics,
bool orderedPublishing =
false);
435 void retrieveTopics(
const TopicList& topics);
442 void resolveObjectDependencies();
452 ObjectEntryPtr getOrCreateObjectEntry(
const std::string& objectName);
483 Ice::ObjectPrx implGetCheckedProxy(std::string
const& proxyTypedId);
484 void implSetCheckedProxy(std::string
const& proxyTypedId, Ice::ObjectPrx
const& proxy);
488 std::unique_ptr<Impl> impl;
492 template <
typename ProxyType>
497 ProxyType prx = getProxy<ProxyType>(objectName);
498 prx->ice_timeout(500)->ice_ping();