34#include <Ice/Handle.h>
35#include <Ice/Object.h>
36#include <Ice/ProxyF.h>
37#include <IceUtil/Handle.h>
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)...);
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>);
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)
210 template <
class PluginT,
class... ParamsT>
213 const std::string prefix =
"",
251 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)
357 if (throwOnProxyError)
374 template <
class ProxyTarg,
class... Args>
377 const std::string& name,
384 template <
class ProxyTarg,
class... Args>
394 template <
class ProxyTarg,
class... Args>
402 template <
class ProxyTarg,
class... 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>
498 template <
class TopicProxyType>
500 getTopic(TopicProxyType& topicProxy,
const std::string& name)
508 void waitForObjectScheduler();
531 std::function<
void(
void)> f,
533 bool assureMeanInterval =
false,
534 bool forceSystemTime =
true);
563 void setName(std::string name);
654 void setObjectState(
int newState);
658 std::unique_ptr<Impl> impl;
#define ARMARX_CHECK_NULL(ptr)
#define ARMARXCORE_IMPORT_EXPORT
The ManagedIceObject is the base class for all ArmarX objects.
VariantBasePtr getMetaInfo(const std::string &id)
friend class ArmarXManager
virtual void preOnInitComponent()
void addPlugin(PluginT *&targ, const std::string prefix="", ParamsT &&... params)
TopicProxyType getTopic(const std::string &name)
Returns a proxy of the specified topic.
ProxyType getProxy(const std::string &name, bool addToDependencies=false, const std::string &endpoints="", bool throwOnProxyError=true)
Retrieves a proxy object.
bool stopPeriodicTask(const std::string &name)
IceUtil::Handle< SimplePeriodicTask< std::function< void(void)> > > PeriodicTaskPtr
virtual void onExitComponent()
Hook for subclass.
StringVariantBaseMap getMetaInfoMap() const
static const ManagedIceObjectPtr NullPtr
A nullptr to be used when a const ref to a nullptr is required.
static std::string generateSubObjectName(const std::string &superObjectName, const std::string &subObjectName)
Generates a unique name for a sub object from a general name and unique name.
virtual void postOnExitComponent()
void getProxy(IceInternal::ProxyHandle< ProxyTarg > &proxy, const std::string &name, Args &&... args)
Assigns a proxy to proxy.
virtual void postOnInitComponent()
virtual void onDisconnectComponent()
Hook for subclass.
friend class ArmarXObjectScheduler
PluginT * addPlugin(const std::string prefix="", ParamsT &&... params)
ManagedIceObject(ManagedIceObject const &other)
virtual std::string getDefaultName() const =0
Retrieve default name of component.
void getProxy(const std::string &name, IceInternal::ProxyHandle< ProxyTarg > &proxy, Args &&... args)
friend class ManagedIceObjectPlugin
virtual void postOnDisconnectComponent()
void terminate()
Initiates termination of this IceManagedObject.
void waitForProxy(std::string const &name, bool addToDependencies)
std::unique_ptr< ManagedIceObjectPlugin > & getPluginPointer(std::type_info const &type, std::string const &prefix)
virtual void onConnectComponent()=0
Pure virtual hook for the subclass.
std::string getName() const
Retrieve name of object.
IceManagerPtr getIceManager() const
Returns the IceManager.
Ice::ObjectPrx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
Returns the proxy of this object (optionally it waits for the proxy)
bool removeProxyDependency(const std::string &name)
This function removes the dependency of this object on the in parameter name specified object.
void getProxy(IceInternal::ProxyHandle< ProxyTarg > &proxy, const char *name, Args &&... args)
void getTopic(TopicProxyType &topicProxy, const std::string &name)
Assigns a proxy of the specified topic to topicProxy.
void getProxy(const char *name, IceInternal::ProxyHandle< ProxyTarg > &proxy, Args &&... args)
void getProxy(Prx &prx, long timeoutMs=0, bool waitForScheduler=true) const
void startPeriodicTask(const std::string &uniqueName, std::function< void(void)> f, int periodMs, bool assureMeanInterval=false, bool forceSystemTime=true)
virtual void preOnConnectComponent()
virtual void preOnDisconnectComponent()
virtual void onInitComponent()=0
Pure virtual hook for the subclass.
PeriodicTaskPtr getPeriodicTask(const std::string &name)
void setMetaInfo(const std::string &id, const VariantBasePtr &value)
Allows to set meta information that can be queried live via Ice interface on the ArmarXManager.
void preambleGetTopic(std::string const &name)
void setName(std::string name)
Override name of well-known object.
virtual void preOnExitComponent()
virtual void postOnConnectComponent()
void getProxy(ProxyType &proxy, const char *name, bool addToDependencies=false, const std::string &endpoints="", bool throwOnProxyError=true)
Overload to allow using string literals as name (solve ambiguous overload).
void addPlugin(std::experimental::observer_ptr< PluginT > &targ, const std::string prefix="", ParamsT &&... params)
Prx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
The armarx::Profiler::Profiler class can be used for timing executions within the ArmarX framework.
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
::IceInternal::Handle<::Ice::Communicator > CommunicatorPtr
::IceInternal::Handle<::Ice::ObjectAdapter > ObjectAdapterPtr
std::shared_ptr< Profiler > ProfilerPtr
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< ArmarXManager > ArmarXManagerPtr
std::map< std::string, VariantBasePtr > StringVariantBaseMap
auto make_shared(Args &&... args)
IceUtil::Handle< ArmarXObjectScheduler > ArmarXObjectSchedulerPtr
IceUtil::Handle< IceManager > IceManagerPtr
IceManager smart pointer.
::IceInternal::Handle<::armarx::VariantBase > VariantBasePtr
IceInternal::Handle< ManagedIceObject > ManagedIceObjectPtr
observer_ptr< _Tp > make_observer(_Tp *__p) noexcept