00001 #ifndef _BOOST_RPC_JSON_CLIENT_HPP_
00002 #define _BOOST_RPC_JSON_CLIENT_HPP_
00003 #include <boost/reflect/any_ptr.hpp>
00004 #include <boost/rpc/json.hpp>
00005 #include <boost/rpc/json/connection.hpp>
00006 #include <boost/enable_shared_from_this.hpp>
00007 #include <boost/rpc/message.hpp>
00008
00009 namespace boost { namespace rpc { namespace json {
00015 template<typename InterfaceType>
00016 class client : public boost::reflect::any_ptr<InterfaceType> {
00017 public:
00018 typedef boost::shared_ptr<client> ptr;
00019 typedef boost::reflect::any_ptr<InterfaceType> interface_type;
00020
00021 client( const connection::ptr& c)
00022 :m_con(c) {
00023 c->start();
00024 boost::reflect::visit( *this, visitor( *this ) );
00025 }
00026 private:
00027 struct visitor {
00028 visitor( client& s ) :m_self(s){};
00029
00030 template<typename Member, typename VTable>
00031 void operator()( Member VTable::* m, const char* name )const {
00032 detail::if_signal<Member::is_signal>::set_delegate( *m_self.m_con, (*m_self).*m, name );
00033 }
00034 client& m_self;
00035 };
00036
00037 connection::ptr m_con;
00038 };
00039
00040 } } }
00041
00042 #endif
00043