7 #ifndef _QI_MESSAGING_SESSION_HPP_
8 #define _QI_MESSAGING_SESSION_HPP_
16 #include <boost/shared_ptr.hpp>
21 # pragma warning( push )
22 # pragma warning( disable: 4251 )
37 class QI_API Session : boost::noncopyable,
public ::boost::enable_shared_from_this<Session> {
39 Session(
bool enforceAuthentication =
false);
43 ServiceLocality_All = 0,
44 ServiceLocality_Local = 1,
45 ServiceLocality_Remote = 2
52 bool isConnected()
const;
59 return service(aservice,
"");
63 const std::string &protocol);
67 std::vector<qi::Url> endpoints()
const;
68 bool setIdentity(
const std::string& key,
const std::string& crt);
88 void loadService(
const std::string& moduleName,
const std::string &renameModule =
"",
102 future.
then(
qi::bind(qi::detail::futureAdapterVal<T>, future, promise));
106 #define pushi(z, n, _) params.push_back(p ## n);
107 #define genCall(n, ATYPEDECL, ATYPES, ADECL, AUSE, comma) \
109 const std::string& moduleName, const std::string& renameModule, \
110 qi::AutoAnyReference pp0 comma \
111 QI_GEN_ARGSDECLSAMETYPE(n, qi::AutoAnyReference)) \
113 std::vector<qi::AnyReference> params; \
114 params.reserve(n+1); \
115 params.push_back(pp0); \
116 BOOST_PP_REPEAT(n, pushi, _) \
117 loadService(moduleName, renameModule, params); \
119 template <typename T> \
120 qi::FutureSync<T> callModule( \
121 const std::string& moduleName, \
122 qi::AutoAnyReference pp0 comma \
123 QI_GEN_ARGSDECLSAMETYPE(n, qi::AutoAnyReference)) \
125 std::vector<qi::AnyReference> params; \
126 params.reserve(n+1); \
127 params.push_back(pp0); \
128 BOOST_PP_REPEAT(n, pushi, _) \
129 return callModule<T>(moduleName, params); \
149 friend class SessionPrivate;
150 boost::shared_ptr<SessionPrivate>
_p;
166 # pragma warning( pop )
169 #endif // _QIMESSAGING_SESSION_HPP_
boost::shared_ptr< Session > SessionPtr
qi::FutureSync< qi::AnyObject > service(const std::string &aservice)
qi::FutureSync< T > callModule(const std::string &moduleName, const AnyReferenceVector &args=AnyReferenceVector())
qi::Signal< unsigned int, std::string > serviceRegistered
dll import/export and compiler message
qi::Signal< unsigned int, std::string > serviceUnregistered
boost::shared_ptr< AuthProviderFactory > AuthProviderFactoryPtr
boost::shared_ptr< ClientAuthenticatorFactory > ClientAuthenticatorFactoryPtr
Future< T > future() const
Get a future linked to this promise. Can be called multiple times.
#define genCall(n, ATYPEDECL, ATYPES, ADECL, AUSE, comma)
std::vector< AnyReference > AnyReferenceVector
QI_TYPE_ENUM(qi::Session::ServiceLocality)
boost::shared_ptr< AuthProvider > AuthProviderPtr
std::map< std::string, AnyValue > CapabilityMap
auto then(FutureCallbackType type, AF &&func) -> qi::Future< typename detail::DecayAsyncResult< AF, qi::Future< T >>::type >
Execute a callback when the future is finished.
boost::shared_ptr< SessionPrivate > _p
void setOnCancel(boost::function< void(qi::Promise< T > &)> cancelCallback)
qi::Signal< std::string > disconnected
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)