34 #include <Ice/Object.h>
35 #include <Ice/Properties.h>
36 #include <Ice/Proxy.h>
37 #include <IceUtil/Handle.h>
38 #include <IceUtil/Shared.h>
46 class ConnectionRefusedException;
126 std::string name =
"",
127 const std::string topicSuffix =
"");
142 const std::string& objectName,
150 void removeObject(
const std::string& objectName);
160 template <
class ProxyType>
162 getProxy(
const std::string& name,
const std::string& endpoints = std::string())
164 std::string proxyString = name;
166 if (!endpoints.empty())
168 proxyString += std::string(
":") + endpoints;
171 std::string proxyTypedId =
172 proxyString + std::string(
":") + std::string(
typeid(
ProxyType).name());
176 return ProxyType::uncheckedCast(implGetCheckedProxy(proxyTypedId));
178 catch (std::out_of_range& uncheckedProxiesException)
182 Ice::ObjectPrx base = communicator_stringToProxy(proxyString);
188 proxy = ProxyType::checkedCast(base);
189 implSetCheckedProxy(proxyTypedId, proxy);
191 catch (
const Ice::ConnectionRefusedException&)
193 std::stringstream exceptionText;
194 exceptionText <<
"Connection refused for proxy of type '"
195 << GetTypeString<ProxyType>() <<
"': " << name
196 <<
" ProxyString: " << proxyString <<
" Endpoints: " << endpoints
198 throwUserException(exceptionText.str());
203 std::stringstream exceptionText;
204 exceptionText <<
"Invalid Proxy. Searched for: " << name
205 <<
" ProxyString: " << proxyString <<
" Endpoints: " << endpoints
207 throwUserException(exceptionText.str());
213 void throwUserException(std::string
const&
message);
222 template <
class ProxyType>
226 return removeProxyFromCache(name,
typeid(
ProxyType).name(), endpoints);
229 bool removeProxyFromCache(
const std::string& name,
230 const std::string& typeName,
231 const std::string& endpoints = std::string());
240 bool removeProxyFromCache(
const Ice::ObjectPrx& proxy);
258 template <
class TopicProxy>
260 getTopic(
const std::string& topicName,
bool useUDP =
false)
262 Ice::ObjectPrx pub = __getTopic(topicName, useUDP);
263 TopicProxy castTopic = TopicProxy::uncheckedCast(pub);
281 void subscribeTopic(Ice::ObjectPrx subscriber,
282 const std::string& topicName,
283 bool orderedPublishing =
false);
285 const std::string& topicName,
286 bool orderedPublishing =
false);
294 void unsubscribeTopic(Ice::ObjectPrx subscriberProxy,
const std::string& topicName);
306 void registerObjectDependency(
const std::string& registrantName,
307 const std::string& dependencyObjectName);
316 void registerDelayedTopicSubscription(
const std::string& registrantName,
317 const std::string& topicName);
325 void registerDelayedTopicRetrieval(
const std::string& registrantName,
326 const std::string& topicName);
334 bool isObjectReachable(std::string objectName);
342 template <
typename ProxyType>
343 bool isObjectReachable(std::string objectName);
370 void setName(std::string name);
381 void waitForShutdown();
396 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) :
408 name(name), proxy(proxy), resolved(false)
413 Ice::ObjectPrx proxy;
420 using TopicList = std::vector<std::string>;
426 void subscribeTopics(Ice::ObjectPrx subscriber,
427 const TopicList& topics,
428 bool orderedPublishing =
false);
433 void retrieveTopics(
const TopicList& topics);
440 void resolveObjectDependencies();
450 ObjectEntryPtr getOrCreateObjectEntry(
const std::string& objectName);
481 Ice::ObjectPrx implGetCheckedProxy(std::string
const& proxyTypedId);
482 void implSetCheckedProxy(std::string
const& proxyTypedId, Ice::ObjectPrx
const& proxy);
486 std::unique_ptr<Impl> impl;
489 template <
typename ProxyType>
495 ProxyType prx = getProxy<ProxyType>(objectName);
496 prx->ice_timeout(500)->ice_ping();