libqi-api  2.8.7.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Public Attributes | List of all members
qi::AutoService< T > Class Template Reference

#include <autoservice.hpp>

Public Member Functions

 AutoService (const std::string &name, qi::SessionPtr session)
 
 ~AutoService ()
 
qi::detail::Keeper< T > operator-> ()
 
qi::detail::Keeper< T > operator-> () const
 
T & operator* ()
 
T * get ()
 
const T * get () const
 
qi::FutureSync< void > waitForReady ()
 
qi::GenericObjectasGenericObject () const
 
- Public Member Functions inherited from qi::Trackable< AutoService< T > >
 Trackable ()
 Default constructor. More...
 
 QI_API_DEPRECATED_MSG (Use default constructor instead) Trackable(AutoService< T > *ptr)
 
 ~Trackable ()
 
boost::weak_ptr< AutoService< T > > weakPtr () const
 
void wait ()
 
- Public Member Functions inherited from qi::detail::GenericObjectBounce< AutoService< T > >
const MetaObjectmetaObject () const
 
qi::Future< AnyReferencemetaCall (unsigned int method, const GenericFunctionParameters &params, MetaCallType callType=MetaCallType_Auto, Signature returnSignature=Signature()) const
 
qi::Future< AnyReferencemetaCall (const std::string &nameWithOptionalSignature, const GenericFunctionParameters &params, MetaCallType callType=MetaCallType_Auto, Signature returnSignature=Signature()) const
 
int findMethod (const std::string &name, const GenericFunctionParameters &parameters) const
 
void metaPost (unsigned int event, const GenericFunctionParameters &params) const
 
void metaPost (const std::string &nameWithOptionalSignature, const GenericFunctionParameters &in) const
 
void post (const std::string &eventName, Args &&...args) const
 
qi::FutureSync< SignalLinkconnect (const std::string &eventName, FUNCTOR_TYPE callback, MetaCallType threadingModel=MetaCallType_Auto) const
 
qi::FutureSync< SignalLinkconnect (const std::string &name, const SignalSubscriber &functor) const
 
qi::FutureSync< SignalLinkconnect (unsigned int signal, const SignalSubscriber &subscriber) const
 
qi::FutureSync< SignalLinkconnect (unsigned int signal, AnyObject target, unsigned int slot) const
 
qi::FutureSync< void > disconnect (SignalLink linkId) const
 
qi::FutureSync< T > property (const std::string &name) const
 
qi::FutureSync< AnyValueproperty (unsigned int id) const
 
qi::FutureSync< void > setProperty (const std::string &name, const T &val) const
 
qi::FutureSync< void > setProperty (unsigned int id, const AnyValue &val) const
 
ExecutionContextexecutionContext () const
 
bool isStatsEnabled () const
 
void enableStats (bool enable) const
 
ObjectStatistics stats () const
 
void clearStats () const
 
bool isTraceEnabled () const
 
void enableTrace (bool enable)
 
void forceExecutionContext (boost::shared_ptr< qi::ExecutionContext > ec)
 
qi::Future< R > async (const std::string &methodName, Args &&...args) const
 
call (const std::string &methodName, Args &&...args) const
 

Public Attributes

qi::Signal< void > serviceAdded
 
qi::Signal< void > serviceRemoved
 

Additional Inherited Members

- Protected Member Functions inherited from qi::Trackable< AutoService< T > >
void destroy ()
 

Detailed Description

template<typename T>
class qi::AutoService< T >

Service remote that automatically reconnect

Wrapper around qi::Object<T> that automatically tries to reacquire the object from the session in case of disconnection. Throws if dereferenced while the service is unavailable. The class is templated and should be used with a remote class that will call the methods of the service. (see also the test_autoservice.cpp file)

Definition at line 38 of file autoservice.hpp.

Constructor & Destructor Documentation

template<typename T >
qi::AutoService< T >::AutoService ( const std::string &  name,
qi::SessionPtr  session 
)

Constuctor of AutoService

Automatically provides a connection to the service

Parameters
namethe name of the service to use
sessiona ref to the session that will be used to find the service.

Definition at line 6 of file autoservice.hxx.

template<typename T >
qi::AutoService< T >::~AutoService ( )

Definition at line 19 of file autoservice.hxx.

Member Function Documentation

template<typename T >
qi::GenericObject * qi::AutoService< T >::asGenericObject ( ) const

Definition at line 135 of file autoservice.hxx.

template<typename T >
T * qi::AutoService< T >::get ( )

Definition at line 112 of file autoservice.hxx.

template<typename T >
const T * qi::AutoService< T >::get ( ) const

Definition at line 102 of file autoservice.hxx.

template<typename T >
T & qi::AutoService< T >::operator* ( )

Provides an access to the <T> var stored in the AutoService

Exceptions
Ifthe connection to the Service is unavailable, throws a runtime_exception

Definition at line 122 of file autoservice.hxx.

template<typename T >
qi::detail::Keeper< T > qi::AutoService< T >::operator-> ( )

Provides an access to the service

Use this operator to call any method of the <T> variable stored in the AutoService. For exemple if you have a remote class called PingRemote that have a method called ping that call the matching service, you can create an AutoService<PingRemote> autoService and write autoService->ping();

Exceptions
Ifthe connection to the Service is unavailable, throws a runtime_exception

The compiler will recursively call operator-> on each returned object until he get a pointer We return an qi::detail::Keeper<T> to keep T* alive during the call (Object<T> will be temporary stored on stack while the call is pending)

Definition at line 80 of file autoservice.hxx.

template<typename T >
qi::detail::Keeper< T > qi::AutoService< T >::operator-> ( ) const

Definition at line 91 of file autoservice.hxx.

template<typename T >
qi::FutureSync< void > qi::AutoService< T >::waitForReady ( )

Notify when the service is available.

Returns
a Future that will be set when the service is available (or immediately if the service is available at the time of the call).

Definition at line 129 of file autoservice.hxx.

Member Data Documentation

template<typename T >
qi::Signal<void> qi::AutoService< T >::serviceAdded

This signal is triggered when your service register.

Definition at line 84 of file autoservice.hpp.

template<typename T >
qi::Signal<void> qi::AutoService< T >::serviceRemoved

This signal is triggered when your service is lost.

Definition at line 89 of file autoservice.hpp.


The documentation for this class was generated from the following files: