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>
80 #define TYPEDEF_PTRS_SHARED(T) \
82 using T##Ptr = ::std::shared_ptr<T>; \
83 using Const##T##Ptr = ::std::shared_ptr<const T>
85 #define TYPEDEF_PTRS_HANDLE(T) \
87 using T##Ptr = IceUtil::Handle<T>
89 template<
class T,
class...Args>
93 std::is_base_of_v<IceUtil::Shared, T> ||
94 std::is_base_of_v<IceUtil::SimpleShared, T>
98 new T(std::forward<Args>(args)...)
103 return std::make_shared<T>(std::forward<Args>(args)...);
110 typedef ::IceInternal::Handle<::armarx::VariantBase>
VariantBasePtr;
118 struct ManagedIceObjectConnectivity;
164 virtual public Ice::Object,
171 std::map<std::pair<std::type_index, std::string>, std::unique_ptr<ManagedIceObjectPlugin>> _plugins;
173 void foreach_plugin(std::function<
void(std::type_index, std::string
const&,
ManagedIceObjectPlugin*)>
const& f,
174 int line,
const char* file,
const char*
function);
178 std::unique_ptr<ManagedIceObjectPlugin>& getPluginPointer(std::type_info
const& type, std::string
const& prefix);
181 template <
class PluginT,
class...ParamsT>
182 PluginT*
addPlugin(
const std::string prefix =
"", ParamsT && ...params)
184 static_assert(std::is_base_of_v<ManagedIceObjectPlugin, PluginT>);
185 auto& ptr = getPluginPointer(
typeid(PluginT), prefix);
188 auto tptr =
dynamic_cast<PluginT*
>(ptr.get());
192 PluginT* tptr =
new PluginT(*
this, prefix, std::forward<ParamsT>(params)...);
197 template<
class PluginT,
class...ParamsT>
198 void addPlugin(PluginT*& targ,
const std::string prefix =
"", ParamsT && ...params)
201 targ = addPlugin<PluginT>(prefix, std::forward<ParamsT>(params)...);
204 template<
class PluginT,
class...ParamsT>
232 std::string getName()
const;
240 static std::string generateSubObjectName(
const std::string& superObjectName,
const std::string& subObjectName);
253 std::string generateSubObjectName(
const std::string& subObjectName);
261 Ice::ObjectPrx getProxy(
long timeoutMs = 0,
bool waitForScheduler =
true)
const;
263 Prx
getProxy(
long timeoutMs = 0,
bool waitForScheduler =
true)
const
265 return Prx::checkedCast(getProxy(timeoutMs, waitForScheduler));
268 void getProxy(Prx& prx,
long timeoutMs = 0,
bool waitForScheduler =
true)
const
270 prx = Prx::checkedCast(getProxy(timeoutMs, waitForScheduler));
278 int getState()
const;
289 ManagedIceObjectConnectivity getConnectivity()
const;
313 bool usingProxy(
const std::string& name,
314 const std::string& endpoints =
"");
316 void waitForProxy(std::string
const& name,
bool addToDependencies);
328 template <
class ProxyType>
330 bool addToDependencies =
false,
331 const std::string& endpoints =
"",
332 bool throwOnProxyError =
true)
334 waitForProxy(name, addToDependencies);
339 return getIceManager()->getProxy<
ProxyType>(name, endpoints);
343 if (throwOnProxyError)
360 template <
class ProxyTarg,
class...Args>
364 proxy = getProxy<ProxyType>(name, std::forward<Args>(args)...);
366 template <
class ProxyTarg,
class...Args>
370 proxy = getProxy<ProxyType>(name, std::forward<Args>(args)...);
372 template <
class ProxyTarg,
class...Args>
376 proxy = getProxy<ProxyType>(name, std::forward<Args>(args)...);
378 template <
class ProxyTarg,
class...Args>
382 proxy = getProxy<ProxyType>(name, std::forward<Args>(args)...);
386 template <
class ProxyType>
388 bool addToDependencies =
false,
389 const std::string& endpoints =
"",
390 bool throwOnProxyError =
true)
392 getProxy<ProxyType>(proxy, std::string(name), addToDependencies, endpoints, throwOnProxyError);
398 std::vector<std::string> getUnresolvedDependencies()
const;
400 static std::string GetObjectStateAsString(
int state);
410 void enableProfiler(
bool enable);
425 void usingTopic(
const std::string& name,
bool orderedPublishing =
false);
432 bool unsubscribeFromTopic(
const std::string& name);
439 void offeringTopic(
const std::string& name);
441 void preambleGetTopic(std::string
const& name);
450 template <
class TopicProxyType>
453 preambleGetTopic(name);
456 return getIceManager()->getTopic<TopicProxyType>(name);
469 template <
class TopicProxyType>
470 void getTopic(TopicProxyType& topicProxy,
const std::string& name)
472 topicProxy = getTopic<TopicProxyType>(name);
478 void waitForObjectScheduler();
488 virtual std::string getDefaultName()
const = 0;
500 void startPeriodicTask(
const std::string& uniqueName,
501 std::function<
void(
void)> f,
503 bool assureMeanInterval =
false,
504 bool forceSystemTime =
true);
505 bool stopPeriodicTask(
const std::string& name);
506 PeriodicTaskPtr getPeriodicTask(
const std::string& name);
521 bool removeProxyDependency(
const std::string& name);
532 void setName(std::string name);
540 virtual void onInitComponent() = 0;
552 virtual void onConnectComponent() = 0;
585 void setObjectState(
int newState);
589 std::unique_ptr<Impl> impl;