7 #ifndef _QI_TYPE_DETAIL_GENERIC_OBJECT_HPP_
8 #define _QI_TYPE_DETAIL_GENERIC_OBJECT_HPP_
13 #include <boost/smart_ptr/enable_shared_from_this.hpp>
23 # pragma warning( push )
24 # pragma warning( disable: 4251 )
41 ,
public boost::enable_shared_from_this<GenericObject>
49 template <
typename R,
typename... Args>
50 R call(
const std::string& methodName, Args&&... args);
52 template <
typename R,
typename... Args>
70 void post(
const std::string& eventName,
88 template <
typename FUNCTOR_TYPE>
135 template <
typename FUNCTION_TYPE>
137 FUNCTION_TYPE callback,
147 template <
typename T>
149 template <
typename T>
151 template <
typename T>
162 template <
typename R,
typename... Args>
167 throw std::runtime_error(
"Invalid GenericObject");
170 return detail::extractFuture<R>(fmeta);
173 template <
typename R,
typename... Args>
178 return makeFutureError<R>(
"Invalid GenericObject");
191 return makeFutureError<T>(
"Property not found");
194 f.connect(
boost::bind(&detail::futureAdapterVal<T>,_1, p),
204 return makeFutureError<void>(
"Property not found");
225 return AnyReference((*val)->type, (*val)->value);
228 void set(
void** storage, AnyReference source)
override
232 if (source.type()->info() == info())
241 set(storage, source.content());
246 detail::ManagedObjectPtr op(
new GenericObject(static_cast<ObjectTypeInterface*>(source.type()), source.rawValue()));
251 PointerTypeInterface* ptype =
static_cast<PointerTypeInterface*
>(source.type());
254 qiLogInfo() <<
"Object will *not* track original shared pointer";
255 set(storage, *source);
258 throw std::runtime_error((std::string)
"Cannot assign non-object " + source.type()->infoString() +
" to Object");
261 using Methods = DefaultTypeImplMethods<detail::ManagedObjectPtr, TypeByPointerPOD<detail::ManagedObjectPtr>>;
268 # pragma warning( pop )
qi::Future< R > async(const std::string &methodName, Args &&...args)
qi::FutureSync< SignalLink > connect(const std::string &eventName, FUNCTOR_TYPE callback, MetaCallType threadingModel=MetaCallType_Direct)
qi::Future< AnyReference > metaCall(ExecutionContext *ec, ObjectThreadingModel objectThreadingModel, MetaCallType methodThreadingModel, MetaCallType callType, AnyObject manageable, unsigned int methodId, AnyFunction func, const GenericFunctionParameters ¶ms, bool noCloneFirst=false, unsigned int callerId=0, qi::os::timeval postTimestamp=qi::os::timeval())
#define qiLogCategory(Cat)
static AnyValue from(const T &r)
Honor the default behavior.
dll import/export and compiler message
#define qiLogWarning(...)
Log in warning mode.
Future< T > future() const
Get a future linked to this promise. Can be called multiple times.
boost::shared_ptr< class GenericObject > ManagedObjectPtr
R call(const std::string &methodName, Args &&...args)
Future< R > async(boost::function< R()> callback, uint64_t usDelay)
Force a synchronous call.
#define qiLogInfo(...)
Log in info mode.
#define _QI_BOUNCE_TYPE_METHODS(Bounce)
Implement all methods of Type as bouncers to Bouncer.
qi::FutureSync< void > setProperty(const std::string &name, const T &val)
ObjectTypeInterface * type
qi::FutureSync< T > property(const std::string &name)
const MetaObject & metaObject()
static AnyFunction from(F &&func)
static AnyReference from(const T &ref)
qi::Future< AnyReference > metaCall(unsigned int method, const GenericFunctionParameters ¶ms, MetaCallType callType=MetaCallType_Auto, Signature returnSignature=Signature())
Force an asynchronous call in an other thread.
std::enable_if< std::is_function< RF >::value, boost::function< RF > >::type bind(AF &&fun, Arg0 &&arg0, Args &&...args)
void adaptFutureUnwrap(Future< AnyReference > &f, Promise< R > &p)
Feed a promise from a generic future which may be unwrapped if it contains itself a future...