36 #include <Ice/Handle.h>
37 #include <Ice/Object.h>
38 #include <Ice/ProxyF.h>
39 #include <IceUtil/Handle.h>
41 #include <type_traits>
50 inline namespace fundamentals_v2
55 template<
typename _Tp>
65 ICE_API ::Ice::LocalObject*
upCast(::Ice::Communicator*);
69 ICE_API ::Ice::LocalObject*
upCast(::Ice::ObjectAdapter*);
82 #define TYPEDEF_PTRS_SHARED(T) \
84 using T##Ptr = ::std::shared_ptr<T>; \
85 using Const##T##Ptr = ::std::shared_ptr<const T>
87 #define TYPEDEF_PTRS_HANDLE(T) \
89 using T##Ptr = IceUtil::Handle<T>
91 template<
class T,
class...Args>
95 std::is_base_of_v<IceUtil::Shared, T> ||
96 std::is_base_of_v<IceUtil::SimpleShared, T>
100 new T(std::forward<Args>(args)...)
105 return std::make_shared<T>(std::forward<Args>(args)...);
112 typedef ::IceInternal::Handle<::armarx::VariantBase>
VariantBasePtr;
120 struct ManagedIceObjectConnectivity;
166 virtual public Ice::Object,
173 std::map<std::pair<std::type_index, std::string>, std::unique_ptr<ManagedIceObjectPlugin>> _plugins;
175 void foreach_plugin(std::function<
void(std::type_index, std::string
const&,
ManagedIceObjectPlugin*)>
const& f,
176 int line,
const char* file,
const char*
function);
180 std::unique_ptr<ManagedIceObjectPlugin>& getPluginPointer(std::type_info
const& type, std::string
const& prefix);
183 template <
class PluginT,
class...ParamsT>
184 PluginT*
addPlugin(
const std::string prefix =
"", ParamsT && ...params)
186 static_assert(std::is_base_of_v<ManagedIceObjectPlugin, PluginT>);
187 auto& ptr = getPluginPointer(
typeid(PluginT), prefix);
190 auto tptr =
dynamic_cast<PluginT*
>(ptr.get());
194 PluginT* tptr =
new PluginT(*
this, prefix, std::forward<ParamsT>(params)...);
199 template<
class PluginT,
class...ParamsT>
200 void addPlugin(PluginT*& targ,
const std::string prefix =
"", ParamsT && ...params)
203 targ = addPlugin<PluginT>(prefix, std::forward<ParamsT>(params)...);
206 template<
class PluginT,
class...ParamsT>
234 std::string getName()
const;
242 static std::string generateSubObjectName(
const std::string& superObjectName,
const std::string& subObjectName);
255 std::string generateSubObjectName(
const std::string& subObjectName);
263 Ice::ObjectPrx getProxy(
long timeoutMs = 0,
bool waitForScheduler =
true)
const;
265 Prx
getProxy(
long timeoutMs = 0,
bool waitForScheduler =
true)
const
267 return Prx::checkedCast(getProxy(timeoutMs, waitForScheduler));
270 void getProxy(Prx& prx,
long timeoutMs = 0,
bool waitForScheduler =
true)
const
272 prx = Prx::checkedCast(getProxy(timeoutMs, waitForScheduler));
280 int getState()
const;
291 ManagedIceObjectConnectivity getConnectivity()
const;
315 bool usingProxy(
const std::string& name,
316 const std::string& endpoints =
"");
318 void waitForProxy(std::string
const& name,
bool addToDependencies);
330 template <
class ProxyType>
332 bool addToDependencies =
false,
333 const std::string& endpoints =
"",
334 bool throwOnProxyError =
true)
336 waitForProxy(name, addToDependencies);
341 return getIceManager()->getProxy<
ProxyType>(name, endpoints);
345 if (throwOnProxyError)
362 template <
class ProxyTarg,
class...Args>
363 void getProxy(IceInternal::ProxyHandle<ProxyTarg>& proxy,
const std::string& name, Args&& ...args)
365 using ProxyType = IceInternal::ProxyHandle<ProxyTarg>;
366 proxy = getProxy<ProxyType>(name, std::forward<Args>(args)...);
368 template <
class ProxyTarg,
class...Args>
369 void getProxy(
const std::string& name, IceInternal::ProxyHandle<ProxyTarg>& proxy, Args&& ...args)
371 using ProxyType = IceInternal::ProxyHandle<ProxyTarg>;
372 proxy = getProxy<ProxyType>(name, std::forward<Args>(args)...);
374 template <
class ProxyTarg,
class...Args>
375 void getProxy(IceInternal::ProxyHandle<ProxyTarg>& proxy,
const char* name, Args&& ...args)
377 using ProxyType = IceInternal::ProxyHandle<ProxyTarg>;
378 proxy = getProxy<ProxyType>(name, std::forward<Args>(args)...);
380 template <
class ProxyTarg,
class...Args>
381 void getProxy(
const char* name, IceInternal::ProxyHandle<ProxyTarg>& proxy, Args&& ...args)
383 using ProxyType = IceInternal::ProxyHandle<ProxyTarg>;
384 proxy = getProxy<ProxyType>(name, std::forward<Args>(args)...);
388 template <
class ProxyType>
390 bool addToDependencies =
false,
391 const std::string& endpoints =
"",
392 bool throwOnProxyError =
true)
394 getProxy<ProxyType>(proxy, std::string(name), addToDependencies, endpoints, throwOnProxyError);
400 std::vector<std::string> getUnresolvedDependencies()
const;
402 static std::string GetObjectStateAsString(
int state);
412 void enableProfiler(
bool enable);
427 void usingTopic(
const std::string& name,
bool orderedPublishing =
false);
434 bool unsubscribeFromTopic(
const std::string& name);
441 void offeringTopic(
const std::string& name);
443 void preambleGetTopic(std::string
const& name);
452 template <
class TopicProxyType>
455 preambleGetTopic(name);
458 return getIceManager()->getTopic<TopicProxyType>(name);
471 template <
class TopicProxyType>
472 void getTopic(TopicProxyType& topicProxy,
const std::string& name)
474 topicProxy = getTopic<TopicProxyType>(name);
480 void waitForObjectScheduler();
490 virtual std::string getDefaultName()
const = 0;
502 void startPeriodicTask(
const std::string& uniqueName,
503 std::function<
void(
void)> f,
505 bool assureMeanInterval =
false,
506 bool forceSystemTime =
true);
507 bool stopPeriodicTask(
const std::string& name);
508 PeriodicTaskPtr getPeriodicTask(
const std::string& name);
523 bool removeProxyDependency(
const std::string& name);
534 void setName(std::string name);
542 virtual void onInitComponent() = 0;
554 virtual void onConnectComponent() = 0;
587 void setObjectState(
int newState);
591 std::unique_ptr<Impl> impl;