Client.h
1 /*
2  * Copyright (C) 2009-2014 by Dr. Marc Boris Duerner
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 #ifndef Pt_Remoting_Client_h
30 #define Pt_Remoting_Client_h
31 
32 #include <Pt/Remoting/Api.h>
33 #include <Pt/SerializationContext.h>
34 #include <Pt/Composer.h>
35 #include <Pt/Decomposer.h>
36 #include <Pt/NonCopyable.h>
37 #include <Pt/Types.h>
38 
39 namespace Pt {
40 
41 namespace Remoting {
42 
43 class RemoteCall;
44 
47 class PT_REMOTING_API Client : private NonCopyable
48 {
49  public:
52  Client();
53 
56  virtual ~Client();
57 
59  SerializationContext& context()
60  { return _ctx; }
61 
63  void beginCall(Composer& r, RemoteCall& call, Decomposer** argv, unsigned argc);
64 
66  void endCall();
67 
69  void call(Composer& r, RemoteCall& call, Decomposer** argv, unsigned argc);
70 
72  void cancelCall();
73 
76  const RemoteCall* activeProcedure() const
77  { return _method; }
78 
81  virtual bool isFailed() const = 0;
82 
85  void cancel();
86 
87  protected:
94  void setReady();
95 
96  virtual void onBeginCall(Composer& r, RemoteCall& method, Decomposer** argv, unsigned argc) = 0;
97 
98  virtual void onEndCall() = 0;
99 
100  virtual void onCall(Composer& r, RemoteCall& method, Decomposer** argv, unsigned argc) = 0;
101 
107  virtual void onCancel() = 0;
108 
109  private:
111  RemoteCall* _method;
112  Pt::varint_t _r1;
113  Pt::varint_t _r2;
114 };
115 
116 } // namespace Remoting
117 
118 } // namespace Pt
119 
120 #endif // Pt_Remoting_Client_h
Protects derived classes from being copied.
Definition: NonCopyable.h:54
const RemoteCall * activeProcedure() const
The currently executing procedure.
Definition: Client.h:76
Composes types during serialization.
Definition: Composer.h:42
Context for the serialization of types.
Definition: SerializationContext.h:20
A client for remote procedure calls.
Definition: Client.h:47
Manages the decomposition of types during serialization.
Definition: Decomposer.h:43