1 /*
2  * Copyright (C) 2011 Tommi Maekitalo
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * As a special exception, you may use this file as part of a free
10  * software library without restriction. Specifically, if other files
11  * instantiate templates or use macros or inline functions from this
12  * file, or you compile this file and link it with other files to
13  * produce an executable, this file does not by itself cause the
14  * resulting executable to be covered by the GNU General Public
15  * License. This exception does not however invalidate any other
16  * reasons why the executable file might be covered by the GNU Library
17  * General Public License.
18  *
19  * This library is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22  * Lesser General Public License for more details.
23  *
24  * You should have received a copy of the GNU Lesser General Public
25  * License along with this library; if not, write to the Free Software
26  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
27  */
28 
29 #include <cxxtools/bin/rpcclient.h>
30 #include "rpcclientimpl.h"
31 
32 namespace cxxtools
33 {
34 namespace bin
35 {
36 
RpcClient(SelectorBase & selector,const std::string & addr,unsigned short port,const std::string & domain)37 RpcClient::RpcClient(SelectorBase& selector, const std::string& addr, unsigned short port, const std::string& domain)
38     : _impl(new RpcClientImpl(selector, addr, port, domain))
39 {
40 }
41 
RpcClient(const std::string & addr,unsigned short port,const std::string & domain)42 RpcClient::RpcClient(const std::string& addr, unsigned short port, const std::string& domain)
43     : _impl(new RpcClientImpl(addr, port, domain))
44 {
45 }
46 
~RpcClient()47 RpcClient::~RpcClient()
48 {
49     delete _impl;
50 }
51 
setSelector(SelectorBase & selector)52 void RpcClient::setSelector(SelectorBase& selector)
53 {
54     if (!_impl)
55         _impl = new RpcClientImpl(std::string(), 0, std::string());
56     _impl->setSelector(selector);
57 }
58 
connect(const std::string & addr,unsigned short port,const std::string & domain)59 void RpcClient::connect(const std::string& addr, unsigned short port, const std::string& domain)
60 {
61     if (!_impl)
62         _impl = new RpcClientImpl(addr, port, domain);
63     else
64         _impl->connect(addr, port, domain);
65 }
66 
close()67 void RpcClient::close()
68 {
69     if (_impl)
70         _impl->close();
71 }
72 
beginCall(IComposer & r,IRemoteProcedure & method,IDecomposer ** argv,unsigned argc)73 void RpcClient::beginCall(IComposer& r, IRemoteProcedure& method, IDecomposer** argv, unsigned argc)
74 {
75     _impl->beginCall(r, method, argv, argc);
76 }
77 
endCall()78 void RpcClient::endCall()
79 {
80     _impl->endCall();
81 }
82 
call(IComposer & r,IRemoteProcedure & method,IDecomposer ** argv,unsigned argc)83 void RpcClient::call(IComposer& r, IRemoteProcedure& method, IDecomposer** argv, unsigned argc)
84 {
85     _impl->call(r, method, argv, argc);
86 }
87 
activeProcedure() const88 const IRemoteProcedure* RpcClient::activeProcedure() const
89 {
90     return _impl->activeProcedure();
91 }
92 
wait(std::size_t msecs)93 void RpcClient::wait(std::size_t msecs)
94 {
95     _impl->wait(msecs);
96 }
97 
cancel()98 void RpcClient::cancel()
99 {
100     _impl->cancel();
101 }
102 
domain() const103 const std::string& RpcClient::domain() const
104 {
105     return _impl->domain();
106 }
107 
domain(const std::string & p)108 void RpcClient::domain(const std::string& p)
109 {
110     _impl->domain(p);
111 }
112 
113 }
114 }
115