libqi-api  release-2.5.3-2016-11-18
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
object.hxx
Go to the documentation of this file.
1 #pragma once
2 /*
3 ** Copyright (C) 2013 Aldebaran Robotics
4 ** See COPYING for the license
5 */
6 
7 #ifndef _QI_TYPE_DETAIL_OBJECT_HXX_
8 #define _QI_TYPE_DETAIL_OBJECT_HXX_
9 
10 #include <boost/mpl/if.hpp>
11 
12 #include <qi/future.hpp>
14 #include <qi/type/typeobject.hpp>
17 #include <qi/type/metasignal.hpp>
18 #include <qi/type/metamethod.hpp>
19 #include <qi/type/metaobject.hpp>
20 
21 // Visual defines interface...
22 #ifdef interface
23 #undef interface
24 #endif
25 
26 namespace qi {
27 
28 class Empty {};
29 
30 namespace detail {
31  using ProxyGeneratorMap = std::map<TypeInfo, boost::function<AnyReference(AnyObject)>>;
33 
34  /* On ubuntu (and maybe other platforms), the linking is done by default with
35  * --as-needed.
36  * Proxy libraries constist only of static initialization functions which add
37  * the proxy factories to the global maps, thus there is no direct dependency
38  * between the program and the library (no function call whatsoever) and the
39  * dependency gets dropped by the linker.
40  * This class is specialized when including interfaces which have proxies
41  * and the function is defined in the .so to force a dependency.
42  */
43  template <typename T>
45  {
46  bool dummyCall() { return true; }
47  };
48 
49  // bounce to a genericobject obtained by (O*)this->asAnyObject()
50  /* Everything need to be const:
51  * anyobj.call bounces to anyobj.asObject().call, and the
52  * second would work on const object
53  */
54  template<typename O> class GenericObjectBounce
55  {
56  public:
57  const MetaObject &metaObject() const { return go()->metaObject(); }
58  inline qi::Future<AnyReference> metaCall(unsigned int method, const GenericFunctionParameters& params, MetaCallType callType = MetaCallType_Auto, Signature returnSignature=Signature()) const
59  {
60  return go()->metaCall(method, params, callType, returnSignature);
61  }
62  inline int findMethod(const std::string& name, const GenericFunctionParameters& parameters) const
63  {
64  return go()->findMethod(name, parameters);
65  }
66  inline qi::Future<AnyReference> metaCall(const std::string &nameWithOptionalSignature, const GenericFunctionParameters& params, MetaCallType callType = MetaCallType_Auto, Signature returnSignature=Signature()) const
67  {
68  return go()->metaCall(nameWithOptionalSignature, params, callType, returnSignature);
69  }
70  inline void metaPost(unsigned int event, const GenericFunctionParameters& params) const
71  {
72  return go()->metaPost(event, params);
73  }
74  inline void metaPost(const std::string &nameWithOptionalSignature, const GenericFunctionParameters &in) const
75  {
76  return go()->metaPost(nameWithOptionalSignature, in);
77  }
78  template <typename... Args>
79  inline void post(const std::string& eventName, Args&&... args) const
80  {
81  return go()->post(eventName, std::forward<Args>(args)...);
82  }
83  template <typename FUNCTOR_TYPE>
84  inline qi::FutureSync<SignalLink> connect(const std::string& eventName, FUNCTOR_TYPE callback,
85  MetaCallType threadingModel = MetaCallType_Auto) const
86  {
87  return go()->connect(eventName, callback, threadingModel);
88  }
89  inline qi::FutureSync<SignalLink> connect(const std::string &name, const SignalSubscriber& functor) const
90  {
91  return go()->connect(name, functor);
92  }
93  inline qi::FutureSync<SignalLink> connect(unsigned int signal, const SignalSubscriber& subscriber) const
94  {
95  return go()->connect(signal, subscriber);
96  }
97  // Cannot inline here, AnyObject not fully declared
98  qi::FutureSync<SignalLink> connect(unsigned int signal, AnyObject target, unsigned int slot) const;
100  {
101  return go()->disconnect(linkId);
102  }
103  template<typename T>
104  inline qi::FutureSync<T> property(const std::string& name) const
105  {
106  return go()->template property<T>(name);
107  }
108  template<typename T>
109  inline qi::FutureSync<void> setProperty(const std::string& name, const T& val) const
110  {
111  return go()->setProperty(name, val);
112  }
113  inline qi::FutureSync<AnyValue> property(unsigned int id) const
114  {
115  return go()->property(id);
116  }
117  inline qi::FutureSync<void> setProperty(unsigned int id, const AnyValue &val) const
118  {
119  return go()->setProperty(id, val);
120  }
122  {
123  return go()->executionContext().get();
124  }
125  inline bool isStatsEnabled() const
126  {
127  return go()->isStatsEnabled();
128  }
129  inline void enableStats(bool enable) const
130  {
131  return go()->enableStats(enable);
132  }
133  inline ObjectStatistics stats() const
134  {
135  return go()->stats();
136  }
137  inline void clearStats() const
138  {
139  return go()->clearStats();
140  }
141  inline bool isTraceEnabled() const
142  {
143  return go()->isTraceEnabled();
144  }
145  inline void enableTrace(bool enable)
146  {
147  return go()->enableTrace(enable);
148  }
149  inline void forceExecutionContext(boost::shared_ptr<qi::ExecutionContext> ec)
150  {
151  return go()->forceExecutionContext(ec);
152  }
153  template <typename R, typename... Args>
154  qi::Future<R> async(const std::string& methodName, Args&&... args) const
155  {
156  return go()->template async<R>(methodName, std::forward<Args>(args)...);
157  }
158  template <typename R, typename... Args>
159  R call(const std::string& methodName, Args&&... args) const
160  {
161  return go()->template call<R>(methodName, std::forward<Args>(args)...);
162  }
163 
164  private:
165  inline GenericObject* go() const
166  {
167  GenericObject* g = static_cast<const O*>(this)->asGenericObject();
168  if (!g)
169  throw std::runtime_error("This object is null");
170  return g;
171  }
172  };
173 
174  template <typename T>
176  {
177  using Defined = boost::false_type;
178  };
179 }
180 
181 // these methods are used by advertiseFactory and arguments are specified explicitely, we can't used forwarding here
182 template <typename T, typename... Args>
183 typename boost::enable_if<typename detail::InterfaceImplTraits<T>::Defined, qi::Object<T> >::type constructObject(
184  Args... args)
185 {
186  return boost::make_shared<typename detail::InterfaceImplTraits<T>::SyncType>(std::forward<Args>(args)...);
187 }
188 template <typename T, typename... Args>
189 typename boost::disable_if<typename detail::InterfaceImplTraits<T>::Defined, qi::Object<T> >::type constructObject(
190  Args&&... args)
191 {
192  return Object<T>(new T(std::forward<Args>(args)...));
193 }
194 
195 #define QI_REGISTER_IMPLEMENTATION_H(interface, impl) \
196  namespace qi \
197  { \
198  namespace detail \
199  { \
200  template <> \
201  struct InterfaceImplTraits<interface> \
202  { \
203  using Defined = boost::true_type; \
204  using ImplType = impl; \
205  using LocalType = interface##Local<ImplType>; \
206  using SyncType = interface##LocalSync<LocalType>; \
207  }; \
208  } \
209  }
210 
221 template<typename T> class Object :
222  public detail::GenericObjectBounce<Object<T>>
223 {
224  // see qi::Future constructors below
225  struct None {
227  };
228 public:
229  Object();
230 
231  template<typename U> Object(const Object<U>& o);
232  template<typename U> Object<T>& operator=(const Object<U>& o);
233  // Templates above do not replace default ctor or copy operator
234  Object(const Object& o);
235  Object<T>& operator=(const Object& o);
236  // Disable the ctor taking future if T is Empty, as it would conflict with
237  // We use None to disable it. The method must be instantiable because when we
238  // export the class under windows, all functions are instanciated
239  // Future cast operator
240  using MaybeAnyObject = typename boost::mpl::if_<typename boost::is_same<T, Empty>::type, None, Object<Empty>>::type;
241  Object(const qi::Future<MaybeAnyObject>& fobj);
243 
245 
251  Object(GenericObject* go);
252  Object(T* ptr);
253  Object(GenericObject* go, boost::function<void(GenericObject*)> deleter);
254  Object(T* ptr, boost::function<void(T*)> deleter);
256 
258  template<typename U> Object(GenericObject* go, boost::shared_ptr<U> other);
259  template<typename U> Object(boost::shared_ptr<U> other);
260  bool operator <(const Object& b) const;
261  template<typename U> bool operator !=(const Object<U>& b) const;
262  template<typename U> bool operator ==(const Object<U>& b) const;
263  operator bool() const;
264  operator Object<Empty>() const;
265 
266  boost::shared_ptr<T> asSharedPtr();
267 
268  T& asT() const;
269  T* operator->() const;
270  T& operator *() const;
271  bool unique() const;
273  void reset();
274  unsigned use_count() const { return _obj.use_count();}
275 
277  // Check or obtain T interface, or throw
278  void checkT();
279  // no-op deletor callback
281  template<typename U>
282  static void keepReference(GenericObject* obj, boost::shared_ptr<U> ptr) {qiLogDebug("qi.object") << "AnyObject ptr holder deleter"; delete obj;}
283  static void noDeleteT(T*) {qiLogDebug("qi.object") << "AnyObject noop T deleter";}
284  static void noDelete(GenericObject*) {qiLogDebug("qi.object") << "AnyObject noop deleter";}
285  // deletor callback that deletes only the GenericObject and not the content
286  static void deleteGenericObjectOnly(GenericObject* obj) { qiLogDebug("qi.object") << "AnyObject GO deleter"; delete obj;}
287  template<typename U>
288  static void deleteGenericObjectOnlyAndKeep(GenericObject* obj, U) { qiLogDebug("qi.object") << "AnyObject GO-keep deleter";delete obj;}
289  static void deleteCustomDeleter(GenericObject* obj, boost::function<void(T*)> deleter)
290  {
291  qiLogDebug("qi.object") << "custom deleter";
292  deleter((T*)obj->value);
293  delete obj;
294  }
296 private:
297  friend class GenericObject;
298 
299  template <typename> friend class Object;
300  template <typename> friend class WeakObject;
301 
303  {
304  init(obj);
305  }
306 
307  void init(detail::ManagedObjectPtr obj);
308 
309  static void deleteObject(GenericObject* obj)
310  {
311  qiLogDebug("qi.object") << "deleteObject " << obj << " "
312  << obj->value << " " << obj->type->infoString();
313  obj->type->destroy(obj->value);
314  delete obj;
315  }
316 
317  /* Do not change this, Object<T> must be binary-equivalent to
318  * ManagedObjectPtr.
319  */
321 };
322 
323 template<typename T> class WeakObject
324 {
325 public:
327  template<typename U> WeakObject(const Object<U>& o)
328  : _ptr(o._obj) {}
329  Object<T> lock() { return Object<T>(_ptr.lock());}
330  boost::weak_ptr<GenericObject> _ptr;
331 };
333 
334 template<typename T> inline ObjectTypeInterface* Object<T>::interface()
335 {
336  TypeInterface* type = typeOf<T>();
337  if (type->kind() != TypeKind_Object)
338  {
339  std::stringstream err;
340  err << "Object<T> can only be used on registered object types. ("
341  << type->infoString() << ")(" << type->kind() << ')';
342  throw std::runtime_error(err.str());
343  }
344  ObjectTypeInterface* otype = static_cast<ObjectTypeInterface*>(type);
345  return otype;
346 }
347 
348 template<typename T> inline Object<T>::Object() {}
349 
350 template<typename T>
351 template<typename U>
352 inline Object<T>::Object(const Object<U>& o)
353 {
354  static bool unused = qi::detail::ForceProxyInclusion<T>().dummyCall();
355  (void)unused;
356 
357  /* An Object<T> created by convert may be in fact an object that does
358  * not implement the T interface.
359  * Checking and converting on first access to T& is not enough:
360  * Object<Iface> o = obj.call("fetchOne"); // this one might be incorrect
361  * someVector.push_back(o); // pushes the incorrect one
362  * o->someIfaceOperation(); // will upgrade o, but not the one in someVector
363  *
364  * So we check as early as we can, in all copy pathes, and back-propagate
365  * the upgrade to the source of the copy
366  */
367  const_cast<Object<U>&>(o).checkT();
368  init(o._obj);
369 }
370 template<typename T>
371 template<typename U>
373 {
374  static bool unused = qi::detail::ForceProxyInclusion<T>().dummyCall();
375  (void)unused;
376 
377  const_cast<Object<U>&>(o).checkT();
378  init(o._obj);
379 
380  return *this;
381 }
382 template<typename T> inline Object<T>::Object(const Object<T>& o)
383 {
384  const_cast<Object<T>&>(o).checkT();
385  init(o._obj);
386 }
387 template<typename T> inline Object<T>& Object<T>::operator=(const Object<T>& o)
388 {
389  if (this == &o)
390  return *this;
391 
392  const_cast<Object<T>&>(o).checkT();
393  init(o._obj);
394 
395  return *this;
396 }
397 template<typename T> inline Object<T>::Object(GenericObject* go)
398 {
399  init(detail::ManagedObjectPtr(go, &deleteObject));
400 }
401 template<typename T> inline Object<T>::Object(GenericObject* go, boost::function<void(GenericObject*)> deleter)
402 {
403  init(detail::ManagedObjectPtr(go, deleter));
404 }
405 template<typename T> template<typename U> Object<T>::Object(GenericObject* go, boost::shared_ptr<U> other)
406 {
407  init(detail::ManagedObjectPtr(other, go));
408  // Notify the shared_from_this of GenericObject
409  _obj->_internal_accept_owner(&other, go);
410 }
411 namespace detail
412 {
413  template<typename T, typename U> ManagedObjectPtr fromSharedPtr(Object<T>& dst, boost::shared_ptr<U>& other, boost::false_type)
414  {
415  ObjectTypeInterface* otype = dst.interface();
416  T* ptr = static_cast<T*>(other.get());
417  return ManagedObjectPtr(new GenericObject(otype, ptr),
418  boost::bind(&Object<T>::template keepReference<U>, _1, other));
419  }
420  template<typename U> ManagedObjectPtr fromSharedPtr(AnyObject& dst, boost::shared_ptr<U>& other, boost::true_type)
421  {
422  return Object<U>(other).managedObjectPtr();
423  }
424 }
425 
426 template<typename T> template<typename U> Object<T>::Object(boost::shared_ptr<U> other)
427 { // bounce depending on T==Empty
428  _obj = detail::fromSharedPtr(*this, other, typename boost::is_same<T, Empty>::type());
429 }
430 
431 template<typename T> inline Object<T>::Object(T* ptr)
432 {
433  ObjectTypeInterface* otype = interface();
434  _obj = detail::ManagedObjectPtr(new GenericObject(otype, ptr), &deleteObject);
435 }
436 template<typename T> inline Object<T>::Object(T* ptr, boost::function<void(T*)> deleter)
437 {
438  ObjectTypeInterface* otype = interface();
439  if (deleter)
440  _obj = detail::ManagedObjectPtr(new GenericObject(otype, ptr),
442  else
443  _obj = detail::ManagedObjectPtr(new GenericObject(otype, ptr), &deleteObject);
444 }
445 template<typename T> inline Object<T>::Object(const qi::Future<MaybeAnyObject>& fobj)
446 {
447  static bool unused = qi::detail::ForceProxyInclusion<T>().dummyCall();
448  (void)unused;
449 
450  init(fobj.value()._obj);
451 }
452 template<typename T> inline Object<T>::Object(const qi::FutureSync<MaybeAnyObject>& fobj)
453 {
454  static bool unused = qi::detail::ForceProxyInclusion<T>().dummyCall();
455  (void)unused;
456 
457  init(fobj.value()._obj);
458 }
459 
460 template<typename T> inline boost::shared_ptr<T> Object<T>::asSharedPtr()
461 {
462  checkT();
463  return boost::shared_ptr<T>(&asT(), boost::bind(&keepManagedObjectPtr, _obj));
464 }
465 
466 template<typename T> inline void Object<T>::init(detail::ManagedObjectPtr obj)
467 {
468  _obj = obj;
469  if (!boost::is_same<T, Empty>::value && obj)
470  checkT();
471  _obj = obj;
472 }
473 
474 template<typename T> inline bool Object<T>::operator <(const Object& b) const { return _obj < b._obj;}
475 template<typename T> template<typename U> bool Object<T>::operator !=(const Object<U>& b) const
476 {
477  return !(*this ==b);
478 }
479 template<typename T> template<typename U> bool Object<T>::operator ==(const Object<U>& b) const
480 {
481  return asGenericObject() == b.asGenericObject();
482 }
483 template<typename T> Object<T>::operator bool() const { return _obj && _obj->type;}
484 
485 template<typename T> Object<T>::operator Object<Empty>() const { return Object<Empty>(_obj);}
487 template<typename T> void Object<T>::checkT()
488 {
489  if (boost::is_same<T, Empty>::value || !_obj)
490  return;
491 
492  const auto isMatchingType = [&] {
493  return _obj->type->info() == typeOf<T>()->info()
494  || _obj->type->inherits(typeOf<T>()) != ObjectTypeInterface::INHERITS_FAILED;
495  };
496 
497  if (!isMatchingType())
498  { // No T interface, try upgrading _obj
500  detail::ProxyGeneratorMap::iterator it = map.find(typeOf<T>()->info());
501  if (it != map.end())
502  {
503  qiLogDebug("qitype.anyobject") << "Upgrading Object to specialized proxy.";
504  AnyReference ref = it->second(AnyObject(_obj));
505  _obj = ref.to<detail::ManagedObjectPtr>();
506  ref.destroy();
507  QI_ASSERT(isMatchingType());
508  return;
509  }
510  throw std::runtime_error(std::string() + "Object does not have interface " + typeOf<T>()->infoString());
511  }
512 }
513 template<typename T> T& Object<T>::asT() const
514 {
515  const_cast<Object<T>* >(this)->checkT();
516  return *static_cast<T*>(_obj->value);
517 }
518 template<typename T> T* Object<T>::operator->() const
519 {
520  return &asT();
521 }
522 template<typename T> T& Object<T>::operator *() const
523 {
524  return asT();
525 }
526 template<typename T> bool Object<T>::unique() const
527 {
528  return _obj.unique();
529 }
530 template<typename T> GenericObject* Object<T>::asGenericObject() const
531 {
532  return _obj.get();
533 }
534 template<typename T> void Object<T>::reset()
535 {
536  _obj.reset();
537 }
538 
539 namespace detail
540 {
541  template<typename O>
542  inline qi::FutureSync<SignalLink> GenericObjectBounce<O>::connect(unsigned int signal, AnyObject target, unsigned int slot) const
543  {
544  return go()->connect(signal, target, slot);
545  }
546 }
547 
548 /* Pretend that Object<T> is exactly shared_ptr<GenericObject>
549  * Which it is in terms of memory layout.
550  * But as a consequence, convert will happily create Object<T> for any T
551  * without checking it.
552  * Object<T> is handling this through the checkT() method.
553  */
554 template<typename T>
555 class QI_API TypeImpl<Object<T>> :
556  public TypeImpl<boost::shared_ptr<GenericObject>>
557 {
558 };
559 
560 #ifdef _MSC_VER
561 /* Because we use types marked with QI_API and inheriting from Object<Empty>
562  * (through AnyObject), then Object<Empty> functions must be explicitly
563  * exported/imported to avoid link issues with MSVC.
564  */
565 template class QI_API Object<Empty>;
566 #endif
567 
568 }
569 
570 #endif // _QITYPE_DETAIL_OBJECT_HXX_
boost::shared_ptr< T > asSharedPtr()
Definition: object.hxx:460
GenericObject * asGenericObject() const
Definition: object.hxx:530
static void noDeleteT(T *)
Definition: object.hxx:283
boost::enable_if< typename detail::InterfaceImplTraits< T >::Defined, qi::Object< T > >::type constructObject(Args...args)
Definition: object.hxx:183
boost::weak_ptr< GenericObject > _ptr
Definition: object.hxx:330
#define QI_API
Definition: api.hpp:33
qi::Future< AnyReference > metaCall(const std::string &nameWithOptionalSignature, const GenericFunctionParameters &params, MetaCallType callType=MetaCallType_Auto, Signature returnSignature=Signature()) const
Definition: object.hxx:66
qi::FutureSync< void > setProperty(const std::string &name, const T &val) const
Definition: object.hxx:109
qi::FutureSync< void > disconnect(SignalLink linkId) const
Definition: object.hxx:99
qi::FutureSync< SignalLink > connect(const std::string &eventName, FUNCTOR_TYPE callback, MetaCallType threadingModel=MetaCallType_Direct)
qi::FutureSync< AnyValue > property(unsigned int id) const
Definition: object.hxx:113
void enableStats(bool enable)
Set statistics gathering status.
int findMethod(const std::string &name, const GenericFunctionParameters &parameters) const
Definition: object.hxx:62
void enableStats(bool enable) const
Definition: object.hxx:129
#define qiLogDebug(...)
Definition: log.hpp:68
bool unique() const
Definition: object.hxx:526
std::map< unsigned int, MethodStatistics > ObjectStatistics
Definition: manageable.hpp:120
virtual TypeKind kind()
Definition: type.hxx:99
void checkT()
Check tha value actually has the T interface.
Definition: object.hxx:487
bool operator<(const Object &b) const
Definition: object.hxx:474
qi::FutureSync< SignalLink > connect(unsigned int signal, const SignalSubscriber &subscriber) const
Definition: object.hxx:93
Honor the default behavior.
Definition: typeobject.hpp:23
qi::FutureSync< T > property(const std::string &name) const
Definition: object.hxx:104
#define QI_ASSERT(expr__)
Definition: assert.hpp:27
const ValueType & value(int msecs=FutureTimeout_Infinite) const
Definition: future_fwd.hpp:649
qi::FutureSync< SignalLink > connect(const std::string &eventName, FUNCTOR_TYPE callback, MetaCallType threadingModel=MetaCallType_Auto) const
Definition: object.hxx:84
void enableTrace(bool enable)
Definition: object.hxx:145
bool isStatsEnabled() const
int findMethod(const std::string &name, const GenericFunctionParameters &parameters)
T & asT() const
Definition: object.hxx:513
void post(const std::string &eventName, Args &&...args) const
Definition: object.hxx:79
static void deleteGenericObjectOnly(GenericObject *obj)
Definition: object.hxx:286
ManagedObjectPtr fromSharedPtr(Object< T > &dst, boost::shared_ptr< U > &other, boost::false_type)
Definition: object.hxx:413
R call(const std::string &methodName, Args &&...args) const
Definition: object.hxx:159
Object< T > lock()
Definition: object.hxx:329
unsigned use_count() const
Definition: object.hxx:274
void destroy()
Deletes storage.
WeakObject(const Object< U > &o)
Definition: object.hxx:327
boost::shared_ptr< class GenericObject > ManagedObjectPtr
boost::false_type Defined
Definition: object.hxx:177
ProxyGeneratorMap & proxyGeneratorMap()
void forceExecutionContext(boost::shared_ptr< qi::ExecutionContext > ec)
Definition: object.hxx:149
T to() const
Convert to anything or throw trying.
T * operator->() const
Definition: object.hxx:518
qi::FutureSync< void > disconnect(SignalLink linkId)
Disconnect an event link. Returns if disconnection was successful.
bool operator==(const Object< U > &b) const
Definition: object.hxx:479
Object< T > & operator=(const Object< U > &o)
Definition: object.hxx:372
detail::ManagedObjectPtr managedObjectPtr()
Definition: object.hxx:295
std::map< TypeInfo, boost::function< AnyReference(AnyObject)>> ProxyGeneratorMap
Definition: object.hxx:31
const MetaObject & metaObject() const
Definition: object.hxx:57
qi::FutureSync< void > setProperty(const std::string &name, const T &val)
void metaPost(unsigned int event, const GenericFunctionParameters &params) const
Definition: object.hxx:70
ObjectTypeInterface * type
void post(const std::string &eventName, qi::AutoAnyReference p1=qi::AutoAnyReference(), qi::AutoAnyReference p2=qi::AutoAnyReference(), qi::AutoAnyReference p3=qi::AutoAnyReference(), qi::AutoAnyReference p4=qi::AutoAnyReference(), qi::AutoAnyReference p5=qi::AutoAnyReference(), qi::AutoAnyReference p6=qi::AutoAnyReference(), qi::AutoAnyReference p7=qi::AutoAnyReference(), qi::AutoAnyReference p8=qi::AutoAnyReference())
void metaPost(unsigned int event, const GenericFunctionParameters &params)
virtual void destroy(void *)=0
Free all resources of a storage.
void enableTrace(bool enable)
qi::FutureSync< void > setProperty(unsigned int id, const AnyValue &val) const
Definition: object.hxx:117
static void keepReference(GenericObject *obj, boost::shared_ptr< U > ptr)
Definition: object.hxx:282
qi::FutureSync< T > property(const std::string &name)
MetaCallType
Definition: typeobject.hpp:21
const char * infoString()
ObjectTypeInterface * interface()
Definition: object.hxx:334
typename boost::mpl::if_< typename boost::is_same< Empty, Empty >::type, None, Object< Empty >>::type MaybeAnyObject
Definition: object.hxx:240
qi::FutureSync< SignalLink > connect(const std::string &name, const SignalSubscriber &functor) const
Definition: object.hxx:89
qi::Future< R > async(const std::string &methodName, Args &&...args) const
Definition: object.hxx:154
boost::shared_ptr< ExecutionContext > executionContext() const
const MetaObject & metaObject()
Object< Empty > AnyObject
Definition: anyobject.hpp:21
T & operator*() const
Definition: object.hxx:522
static void keepManagedObjectPtr(detail::ManagedObjectPtr ptr)
Definition: object.hxx:280
bool isTraceEnabled() const
static void noDelete(GenericObject *)
Definition: object.hxx:284
ObjectStatistics stats() const
Definition: object.hxx:133
const ValueType & value(int msecs=FutureTimeout_Infinite) const
Return the value associated to a Future.
Definition: future_fwd.hpp:214
bool operator!=(const Object< U > &b) const
Definition: object.hxx:475
static const int INHERITS_FAILED
Definition: typeobject.hpp:60
void reset()
Definition: object.hxx:534
qi::Future< AnyReference > metaCall(unsigned int method, const GenericFunctionParameters &params, MetaCallType callType=MetaCallType_Auto, Signature returnSignature=Signature()) const
Definition: object.hxx:58
void forceExecutionContext(boost::shared_ptr< ExecutionContext > eventLoop)
Override all ThreadingModel and force dispatch to given event loop.
qi::uint64_t SignalLink
Definition: signal.hpp:35
void clearStats()
Reset all statistical data.
qi::Future< AnyReference > metaCall(unsigned int method, const GenericFunctionParameters &params, MetaCallType callType=MetaCallType_Auto, Signature returnSignature=Signature())
ObjectStatistics stats() const
void init(qi::LogLevel verb=qi::LogLevel_Info, qi::LogContext context=qi::LogContextAttr_ShortVerbosity|qi::LogContextAttr_Tid|qi::LogContextAttr_Category, bool synchronous=true)
Initialization of the logging system (could be avoided)
std::enable_if< std::is_function< RF >::value, boost::function< RF > >::type bind(AF &&fun, Arg0 &&arg0, Args &&...args)
Definition: trackable.hxx:327
void metaPost(const std::string &nameWithOptionalSignature, const GenericFunctionParameters &in) const
Definition: object.hxx:74
static void deleteCustomDeleter(GenericObject *obj, boost::function< void(T *)> deleter)
Definition: object.hxx:289
ExecutionContext * executionContext() const
Definition: object.hxx:121
Description of the signals and methods accessible on an ObjectTypeInterface.
Definition: metaobject.hpp:25
static void deleteGenericObjectOnlyAndKeep(GenericObject *obj, U)
Definition: object.hxx:288