MACE  1.0.0
 All Classes Namespaces Files Functions Variables Enumerations Defines
libs/rpc/include/mace/rpc/connection_base.hpp
00001 #ifndef _MACE_RPC_CONNECTION_BASE_HPP_
00002 #define _MACE_RPC_CONNECTION_BASE_HPP_
00003 #include <boost/function.hpp>
00004 #include <mace/rpc/message.hpp>
00005 #include <mace/rpc/detail/pending_result.hpp>
00006 
00007 namespace mace { namespace rpc  {
00008 
00009   typedef boost::function<message(const message&)> method;
00010 
00011   namespace detail { class connection_base; }
00012   
00021   class connection_base : public boost::noncopyable {
00022     public:
00023       ~connection_base();
00024 
00028       const method* get_method( const std::string& name )const;
00029 
00033       void          add_method( const std::string& name, const method& );
00034 
00038       std::string   add_method( const method& m );
00039 
00046       cmt::future<datavec> raw_call( std::string&& mid, datavec&& param );
00047 
00048       std::string create_method_id();
00049 
00050       connection_base& operator=( connection_base&& m ) {
00051         std::swap(m.my,my);
00052         return *this;
00053       }
00054 
00055     protected:
00061       void raw_call( std::string&& meth, datavec&& param, 
00062                      const detail::pending_result::ptr& pr );
00063 
00064       connection_base( detail::connection_base* b );
00065       connection_base( connection_base&& m ):my(m.my) { m.my=0; }
00066 
00067       detail::connection_base* my;
00068     private:
00069       connection_base();
00070   };
00071 
00072 
00073 } }  // namespace mace::rpc
00074 
00075 #endif // _MACE_RPC_CONNECTION_BASE_HPP_