MACE  1.0.0
 All Classes Namespaces Files Functions Variables Enumerations Defines
libs/rpc/include/mace/rpc/json/client.hpp
00001 #ifndef _MACE_RPC_JSON_CLIENT_HPP_
00002 #define _MACE_RPC_JSON_CLIENT_HPP_
00003 #include <mace/stub/ptr.hpp>
00004 #include <mace/rpc/json/client_interface.hpp>
00005 #include <mace/rpc/json/client_base.hpp>
00006 
00007 namespace mace { namespace rpc {  namespace json {
00008 
00017   template<typename InterfaceType>
00018   class client : public mace::stub::ptr<InterfaceType, mace::rpc::json::client_interface>, 
00019                  public client_base {
00020     public:
00021       typedef boost::shared_ptr<client>   ptr;
00022 
00023       client(){}
00024       client( const client& c ):client_base(c) {
00025         mace::rpc::json::client_interface::set( *this );
00026       }
00027       bool operator!()const { return !m_con; }
00028 
00029       client& operator=( const client& c ) {
00030         if( &c != this )  {
00031             m_con = c.m_con;
00032             mace::rpc::json::client_interface::set( *this );
00033         }
00034         return *this;
00035       }
00036       client( const mace::rpc::json::connection::ptr& c) 
00037       :client_base(c) {
00038          mace::rpc::json::client_interface::set( *this );
00039       }      
00040 
00041       // TODO: client( endpoint )
00042       client( const std::string& host, uint16_t port ) 
00043       :client_base(host,port){
00044          mace::rpc::json::client_interface::set( *this );
00045       }
00046   };
00047 
00048 } } } // mace::rpc::json
00049 
00050 #endif