Bytemaster's Boost Libraries
|
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/rpc/mirror_interface.hpp> 00007 #include <boost/enable_shared_from_this.hpp> 00008 #include <boost/rpc/message.hpp> 00009 00010 namespace boost { namespace rpc { namespace json { 00016 template<typename InterfaceType> 00017 class client : public boost::reflect::any_ptr<InterfaceType, boost::rpc::mirror_interface> { 00018 public: 00019 typedef boost::shared_ptr<client> ptr; 00020 typedef boost::reflect::any_ptr<InterfaceType,boost::rpc::mirror_interface> interface_type; 00021 00022 client( const connection::ptr& c) 00023 :m_con(c) { 00024 c->start(); 00025 boost::reflect::visit( *this, visitor( *this ) ); 00026 } 00027 00028 private: 00029 struct visitor { 00030 visitor( client& s ) :m_self(s){}; 00031 00032 template<typename Member, typename VTable, Member (VTable::*m)> 00033 inline void operator()( const char* name )const { 00034 std::cerr<<"cname: " << name << std::endl; 00035 detail::if_signal<Member::is_signal>::set_delegate( *m_self.m_con, (*m_self).*m, name ); 00036 } 00037 client& m_self; 00038 }; 00039 00040 connection::ptr m_con; 00041 }; 00042 00043 } } } // boost::rpc::json 00044 00045 #endif 00046