Responder.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_Responder_h
30 #define Pt_Remoting_Responder_h
31 
32 #include <Pt/Remoting/Api.h>
33 #include <Pt/System/EventLoop.h>
34 #include <Pt/SerializationContext.h>
35 #include <Pt/Composer.h>
36 #include <Pt/Decomposer.h>
37 #include <Pt/NonCopyable.h>
38 #include <Pt/Types.h>
39 
40 namespace Pt {
41 
42 namespace Remoting {
43 
44 class ServiceDefinition;
45 class ServiceProcedure;
46 
49 class PT_REMOTING_API Responder : private NonCopyable
50 {
51  public:
54  explicit Responder(ServiceDefinition& serviceDef);
55 
58  virtual ~Responder();
59 
61  SerializationContext& context()
62  { return _context; }
63 
65  void setReady()
66  { this->onReady(); }
67 
70  void cancel();
71 
75  { return _proc; }
76 
77  virtual bool isFailed() const = 0;
78 
79  protected:
82  Pt::Composer** setProcedure(const std::string& name);
83 
87 
91 
92  protected:
97  virtual void onCancel() = 0;
98 
106  virtual void onReady() = 0;
107 
108  private:
109  SerializationContext _context;
110  ServiceDefinition* _serviceDef;
111  ServiceProcedure* _proc;
112 };
113 
114 } // namespace Remoting
115 
116 } // namespace Pt
117 
118 #endif // Pt_Remoting_Responder_h
Core module.
Definition: Allocator.h:33
Manages the decomposition of types during serialization.
Definition: Decomposer.h:44
const ServiceProcedure * activeProcedure() const
The currently executing procedure.
Definition: Responder.h:74
void beginCall(System::EventLoop &loop)
Begins the service procedure call.
virtual ~Responder()
Destructor.
Remote service definition.
Definition: Api-ServiceDefinition.h:22
Pt::Decomposer * endCall()
Ends the service procedure call.
Context for the serialization of types.
Definition: Api-SerializationContext.h:22
virtual void onCancel()=0
Cancels all operations.
void cancel()
Resets to initial state.
Dispatches requests to a service procedure.
Definition: Responder.h:50
XML-RPC service procedure.
Definition: ServiceProcedure.h:45
Responder(ServiceDefinition &serviceDef)
Construct with Service.
virtual void onReady()=0
The service procedure has finished.
Thread-safe event loop supporting I/O multiplexing and Timers.
Definition: EventLoop.h:74
Composes types during serialization.
Definition: Composer.h:43
Protects derived classes from being copied.
Definition: NonCopyable.h:54
Pt::Composer ** setProcedure(const std::string &name)
Sets the service procedure.