30 #include <type_traits>
34 #include <Ice/Handle.h>
35 #include <Ice/Object.h>
36 #include <Ice/ProxyF.h>
37 #include <IceUtil/Handle.h>
50 inline namespace fundamentals_v2
55 template <
typename _Tp>
81 #define TYPEDEF_PTRS_SHARED(T) \
83 using T##Ptr = ::std::shared_ptr<T>; \
84 using Const##T##Ptr = ::std::shared_ptr<const T>
86 #define TYPEDEF_PTRS_HANDLE(T) \
88 using T##Ptr = IceUtil::Handle<T>
90 template <
class T,
class... Args>
94 if constexpr (std::is_base_of_v<IceUtil::Shared, T> ||
95 std::is_base_of_v<IceUtil::SimpleShared, T>)
101 return std::make_shared<T>(std::forward<Args>(args)...);
109 typedef ::IceInternal::Handle<::armarx::VariantBase>
VariantBasePtr;
117 struct ManagedIceObjectConnectivity;
163 virtual public Ice::Object,
170 std::map<std::pair<std::type_index, std::string>, std::unique_ptr<ManagedIceObjectPlugin>>
178 const char*
function);
181 std::unique_ptr<ManagedIceObjectPlugin>& getPluginPointer(std::type_info
const& type,
182 std::string
const& prefix);
184 template <
class PluginT,
class... ParamsT>
186 addPlugin(
const std::string prefix =
"", ParamsT&&... params)
188 static_assert(std::is_base_of_v<ManagedIceObjectPlugin, PluginT>);
189 auto& ptr = getPluginPointer(
typeid(PluginT), prefix);
192 auto tptr =
dynamic_cast<PluginT*
>(ptr.get());
194 <<
"Plugin is of wrong type. This should be impossible!";
197 PluginT* tptr =
new PluginT(*
this, prefix, std::forward<ParamsT>(params)...);
202 template <
class PluginT,
class... ParamsT>
204 addPlugin(PluginT*& targ,
const std::string prefix =
"", ParamsT&&... params)
207 targ = addPlugin<PluginT>(prefix, std::forward<ParamsT>(params)...);
210 template <
class PluginT,
class... ParamsT>
213 const std::string prefix =
"",
218 addPlugin<PluginT>(prefix, std::forward<ParamsT>(params)...));
242 std::string getName()
const;
250 static std::string generateSubObjectName(
const std::string& superObjectName,
251 const std::string& subObjectName);
264 std::string generateSubObjectName(
const std::string& subObjectName);
272 Ice::ObjectPrx getProxy(
long timeoutMs = 0,
bool waitForScheduler =
true)
const;
276 getProxy(
long timeoutMs = 0,
bool waitForScheduler =
true)
const
278 return Prx::checkedCast(getProxy(timeoutMs, waitForScheduler));
283 getProxy(Prx& prx,
long timeoutMs = 0,
bool waitForScheduler =
true)
const
285 prx = Prx::checkedCast(getProxy(timeoutMs, waitForScheduler));
293 int getState()
const;
303 ManagedIceObjectConnectivity getConnectivity()
const;
327 bool usingProxy(
const std::string& name,
const std::string& endpoints =
"");
329 void waitForProxy(std::string
const& name,
bool addToDependencies);
341 template <
class ProxyType>
344 bool addToDependencies =
false,
345 const std::string& endpoints =
"",
346 bool throwOnProxyError =
true)
348 waitForProxy(name, addToDependencies);
353 return getIceManager()->getProxy<
ProxyType>(name, endpoints);
357 if (throwOnProxyError)
374 template <
class ProxyTarg,
class... Args>
377 const std::string& name,
381 proxy = getProxy<ProxyType>(name, std::forward<Args>(args)...);
384 template <
class ProxyTarg,
class... Args>
391 proxy = getProxy<ProxyType>(name, std::forward<Args>(args)...);
394 template <
class ProxyTarg,
class... Args>
399 proxy = getProxy<ProxyType>(name, std::forward<Args>(args)...);
402 template <
class ProxyTarg,
class... Args>
407 proxy = getProxy<ProxyType>(name, std::forward<Args>(args)...);
411 template <
class ProxyType>
415 bool addToDependencies =
false,
416 const std::string& endpoints =
"",
417 bool throwOnProxyError =
true)
420 proxy, std::string(name), addToDependencies, endpoints, throwOnProxyError);
426 std::vector<std::string> getUnresolvedDependencies()
const;
428 static std::string GetObjectStateAsString(
int state);
438 void enableProfiler(
bool enable);
453 void usingTopic(
const std::string& name,
bool orderedPublishing =
false);
460 bool unsubscribeFromTopic(
const std::string& name);
467 void offeringTopic(
const std::string& name);
469 void preambleGetTopic(std::string
const& name);
478 template <
class TopicProxyType>
482 preambleGetTopic(name);
485 return getIceManager()->getTopic<TopicProxyType>(name);
498 template <
class TopicProxyType>
500 getTopic(TopicProxyType& topicProxy,
const std::string& name)
502 topicProxy = getTopic<TopicProxyType>(name);
508 void waitForObjectScheduler();
518 virtual std::string getDefaultName()
const = 0;
530 void startPeriodicTask(
const std::string& uniqueName,
531 std::function<
void(
void)> f,
533 bool assureMeanInterval =
false,
534 bool forceSystemTime =
true);
535 bool stopPeriodicTask(
const std::string& name);
536 PeriodicTaskPtr getPeriodicTask(
const std::string& name);
552 bool removeProxyDependency(
const std::string& name);
563 void setName(std::string name);
571 virtual void onInitComponent() = 0;
591 virtual void onConnectComponent() = 0;
654 void setObjectState(
int newState);
658 std::unique_ptr<Impl> impl;