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
40namespace Pt {
41
42namespace Remoting {
43
46
49class 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
95
96 protected:
101 virtual void onCancel() = 0;
102
110 virtual void onReady() = 0;
111
112 private:
113 SerializationContext _context;
114 ServiceDefinition* _serviceDef;
115 ServiceProcedure* _proc;
116};
117
118} // namespace Remoting
119
120} // namespace Pt
121
122#endif // Pt_Remoting_Responder_h
Composes types during serialization.
Definition Composer.h:101
Manages the decomposition of types during serialization.
Definition Decomposer.h:121
NonCopyable()
Default constructor.
Definition NonCopyable.h:63
void cancel()
Resets to initial state.
Pt::Decomposer * endCall()
Ends the service procedure call.
Pt::Decomposer * call()
Synchronous call without EventLoop.
virtual ~Responder()
Destructor.
virtual void onCancel()=0
Cancels all operations.
const ServiceProcedure * activeProcedure() const
The currently executing procedure.
Definition Responder.h:74
Responder(ServiceDefinition &serviceDef)
Construct with Service.
virtual void onReady()=0
The service procedure has finished.
Pt::Composer ** setProcedure(const std::string &name)
Sets the service procedure.
void beginCall(System::EventLoop &loop)
Begins the service procedure call.
Remote service definition.
Definition ServiceDefinition.h:59
Service procedure.
Definition ServiceProcedure.h:46
Context for the serialization of types.
Definition Api-SerializationContext.h:26
Event loop of a thread or process.
Definition EventLoop.h:83
Remote services and clients.
Definition HttpService.h:39
Core module.
Definition Allocator.h:33